fix(afrixnli): use Jinja braces in prompt_1 doc_to_text so premise and hypothesis are substituted#3932
Open
AmosBunde wants to merge 1 commit into
Open
Conversation
The prompt_1 entry in gen_utils.py used Python .format() brace syntax in doc_to_text, which lm-eval renders through Jinja2. The premise and hypothesis were never substituted, so all 35 prompt_1 tasks scored a three-way choice against a constant, empty stem. Verified with --log_samples on afrixnli_eng_prompt_1 (200 docs): before the fix, 200 distinct doc_hash produce 1 distinct prompt_hash; after, 200 distinct prompt_hash. Regenerated the affected YAMLs with gen_utils.py. Also cleared a pre-existing ruff PLC0206 in the same file, which the pre-commit hook blocks on. Fixes EleutherAI#3930 Signed-off-by: AmosBunde <103738587+AmosBunde@users.noreply.github.com>
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
afrixnliprompt_1declared an inlinedoc_to_textusing Python.format()brace syntax ({premise},{hypothesis}).doc_to_textis rendered through Jinja2, where single braces are literal. The premise and hypothesis were never substituted, so every document in the task produced the same constant prompt and the model scored a three-way multiple choice against an empty stem.Evidence
Run with
--log_samplesonafrixnli_eng_prompt_1,Qwen/Qwen2.5-0.5B,--limit 200, CPU. English is used as a control so that "the model does not know the language" cannot explain the result.doc_hashprompt_hashTwo hundred distinct documents rendered one identical prompt. After the fix they render two hundred distinct prompts.
The rendered
arg_0before the fix:What does not change, stated up front
Accuracy and F1 are identical before and after:
acc 0.3300 (± 0.0333),f1 0.1638, on bothengandswa. Qwen2.5-0.5B collapses to a single label in both conditions, so the score cannot demonstrate the fix. A weighted F1 of 0.1638 is close to the 1/6 that always-predict-one-class yields on a balanced three-class set, which is what a constant prompt guarantees but is also what this model does anyway at this size.Runtime is the independent confirmation that the prompts really did change: the same 200-document run took 3 seconds before and 38 minutes after, since the prompts now carry the actual premise and hypothesis.
I do not have GPU access to run a model large enough to show a score delta. If a maintainer can run this at around 7B, I would expect the fixed task to separate from chance and the broken one not to.
Changes
lm_eval/tasks/afrixnli/gen_utils.py:prompt_1now uses{{premise}}and{{hypothesis}}, matching howprompt_3,prompt_4andprompt_5already write them.prompt_2is unaffected as it has no inlinedoc_to_text.direct/prompt_1/, 17 undertranslate/prompt_1/, 35 tasks total.ruff PLC0206ingen_utils.py(for lang in languages.keys()to.items()). This is unrelated to the bug, but the pre-commit hook fails on it and therefore blocks any change to that file. Regenerating after the lint fix produces byte-identical YAMLs.Notes for reviewers
Alternative approach.
lm_eval/tasks/afrixnli/direct/prompt_1/utils.pyalready contains a correctdoc_to_textfunction, but nothing references it, because the templates carry nodoc_to_textkey and the generated inline string is the only one in the chain. An alternative fix would be to adddoc_to_text: !function utils.doc_to_textto the templates and drop the inline strings entirely, which would also revive that dead function. That is a larger change and would want the same treatment across all five prompts, so I kept this PR minimal. Happy to do it that way instead if you prefer.Separate generator issue, not fixed here. Running
gen_utils.pyin translate mode emitstranslate/prompt_1/afrixnli_translate_eng.yaml, an English-to-English translate task that is not in the repo and was presumably removed deliberately. I deleted it after regenerating in order to preserve the committed state. The generator is not idempotent against the repo as committed. Worth a separate fix.I make no claim about any published results. This PR describes only what the harness renders today.
Testing
pytest --showlocals -s -vv -n=auto --ignore=tests/models/test_openvino.py: 607 passed, 16 skipped, matching the baseline onmain.pre-commit run --files <the changed files>: passing.