Repository navigation
Add Multi-IF: multi-turn, multilingual instruction following - #473
Merged
Merged
Conversation
gregorybchris
marked this pull request as ready for review
October 14, 2026 23:13
gregorybchris
force-pushed
the
chrisg/multi-if
branch
from
October 16, 2026 20:04
33c8f2a to
cf6f4f4
Compare
Multi-IF asks IFEval instructions over two or three turns in eight languages, with each turn adding instructions to the ones before it. The model answers every turn itself, so a new multi_turn_chat scaffold plays the scripted user turns and carries each reply forward. Replies are checked with the ifbench verifiers, adapted as in the reference implementation: word and sentence counts follow the reply's language, and curly and corner quotation marks count as quotes. The IFEval scorer's verification loop is shared so both scorers use it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The paper's tables average the per-language scores, while pooling every conversation gives English, with twice as many conversations, double weight. Averaging languages brings Llama-3.1-8B-Instruct to within 0.2-2.2 points of the paper's per-turn numbers. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
- The multi_turn_chat scaffold now sends the harness's system prompt, falling back to the request's, as Harness does for direct requests. - The scripted-turn and reply metadata keys live beside LMRequest and LMOutput, so the Multi-IF task no longer imports from the harness. - Language detection for the multilingual verifiers uses its own seeded langdetect factory, so a rerun counts the same reply the same way. - emoji and langdetect are declared as direct dependencies. - The scaffold's unread overflow metadata key is removed; the overflow is still logged and the unasked turns still score as unanswered. - Tests for the system prompt, a first-turn overflow, verify_instructions errors, deterministic detection, and extraction after trace stripping. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
gregorybchris
force-pushed
the
chrisg/multi-if
branch
from
October 16, 2026 20:18
cf6f4f4 to
26b817f
Compare
8 of 13 tasks
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.
Description
Adds Multi-IF (
facebook/Multi-IF, pinned to0ab97ce). It has 4,501 conversations in eight languages: English, Chinese, French, Hindi, Italian, Portuguese, Russian and Spanish. Each conversation has two or three user turns, and each turn adds IFEval instructions to the ones before it. The model answers every turn itself, so later turns see its own earlier replies.multi_turn_chatscaffold and harness preset. The scaffold sends the first user turn, then each scripted follow-up, and carries each reply forward as an assistant message. It returns the replies in turn order. If the context window overflows, the conversation ends there and unasked turns score as failures. Any other provider error fails the instance. These rules match the BFCL multi-turn scaffold, and both use the same helpers ininference/errors.py. A system prompt set on the harness takes precedence over the request's, as it does for requests the harness sends directly. The scaffold knows nothing about Multi-IF, so other scripted multi-turn evals can reuse it. The metadata keys it reads and writes (FOLLOW_UP_TURNS_KEY,REPLIES_KEY) live incommon/typesbesideLMRequestandLMOutput, so tasks don't import from the harness.Same grader as IFEval and IFBench.
IFEvalScorer's strict and loose verification loop is nowverify_instructions().IFEvalScorer(ifeval,ifeval_ood,ifeval_mt) and the newMultiIFScorerboth call it;MultiIFScorercalls it once per turn. Multi-IF checks replies against the sameifbenchregistry, with three verifiers swapped for the reference implementation's multilingual versions incommon/scorers/multilingual_instructions.py:langdetectfactory. The reference leaveslangdetectunseeded, so the same reply can be counted differently on a rerun.emojiandlangdetectare now direct dependencies.These three stay out of
ifbenchitself because changing them there would change IFEval and IFBench scores for non-English replies. The reference also has a Thai path that needspythainlp. No conversation pairs a Thai reply with a length instruction, so this PR omits it.Metrics follow the paper's tables. A turn's score in one language is the mean of four IFEval accuracies: prompt-level and instruction-level, each under strict and loose scoring. Languages are then averaged with equal weight, as in the paper's Table 1. The upstream script instead pools all conversations, which gives English twice the weight of any other language. The task reports
turn_{1,2,3}_accuracy, one<language>_accuracyper language, and the primaryaccuracy, which is the mean of the three turns. Replies are trimmed before checking, as upstream does.Sampling. The default is the repo's reasoning regime, as for
ifevalandifeval_ood: temperature 0.6, top-p 0.95, no token cap, with<think>traces stripped from each reply before checking.multi_if:paperuses the paper's settings: temperature 0.6, top-p 0.9, 1,024 max tokens.Affected results
None.
ifeval,ifeval_oodand theifeval_mttasks now call the sharedverify_instructions(), but their verification behavior is unchanged, so nodocs/result-compatibility.mdentry is needed. Every other change adds new code: a task, scorer, metric, scaffold and preset.Type of Change
Validation
uv run ruff check src/ tests/anduv run ruff format --check src/ tests/uv run ty check src/: one warning about an unusedtype: ignoreinharness/sandbox/executor.py, which also appears onmain.uv run pytest tests/ --ignore=tests/integration -v: 3,806 passed in the default environment, and 3,847 passed with theagentsandlitellmextras, after rebasing ontomainat a963311 (SWE-bench Verified).uv lock --checkpasses.verify_instructions, including instructions it cannot buildLoaded the real dataset through the task: 4,501 conversations, 4,445 with three turns and 56 with two.
Merge order. The branch is rebased onto
mainafter SWE-bench Verified (#445) and MultiChallenge (#475) merged. MultiChallenge shares no code with this PR: it sends a fixed history and generates only the final turn, so it needs no scaffold.Reviews. Two reviews by separate Claude agents found no scoring bugs. The first one's design and consistency findings are addressed in the last commit. The second checked the rebase onto
mainand the interaction with #445 and #475, and found nothing to change.Llama-3.1-8B-Instruct matches the paper
multi_if:paperon 1× L40 (ai2/neptune), Beaker experiment01M4Y129QSQM3FADDTCR2YTEYA, 4,501 conversations:The remaining gap is within what one sampled run at temperature 0.6 can move. The paper does not say which vLLM version or chat template it used.
Per language, averaged over turns: English 0.717, French 0.676, Spanish 0.661, Italian 0.649, Portuguese 0.642, Chinese 0.606, Russian 0.531, Hindi 0.530.
Grading matches the reference implementation
I rescored the Llama run's saved replies with upstream's own
gen_acc_strictandgen_acc_loosefromfacebookresearch/Multi-IFand compared every instruction verdict:The 17 differing turns all involve one of two sources of randomness in the reference:
langdetectis nondeterministic on short or mixed-script text, and the Chinese word and sentence counts depend on which language it picks.Other models in the default regime
01M4Y1SX3RKR3GH8M2H5PJQPYG01M4Y5449XFAASAWPE97YV74CHFor both models, grading agrees with upstream on 13,434 of 13,447 turns. Olmo 3 drops 27 points from turn 1 to turn 3, against 17 for both Llama 3.1 and Qwen3. Per language, averaged over turns:
The Hindi score reflects the model, not the grading. For example, Olmo 3 follows "wrap your entire response in double quotation marks" in 8% of Hindi turns, against 89% in other languages, and its Hindi replies use
<<...>>or XML wrappers instead.Reasoning traces.
<think>stripping works per turn. For Qwen3, 125 of 13,340 replies (0.9%) end inside an unclosed trace and score as written. 71 conversations (1.6%) outgrew the 40k context before their last turn: 36 after turn 1 and 35 after turn 2. Their unasked turns score as unanswered, which is the trade-off of running with no token cap.Runtime. Olmo 3 took 2.1 hours on one L40, with 256 conversations in flight. Qwen3-8B with no token cap ran at 0.1 conversations per second on one L40, about 11 hours for the full set, so it was moved to 2× B300 on
ai2/holmes. That run used-o provider.kwargs.attention_backend=TRITON_ATTN -e VLLM_USE_FLASHINFER_SAMPLER=0, as in #414, and took 4.8 hours at 0.3 conversations per second.All three result sets predate seeding language detection. Seeding changes only replies whose language
langdetectfinds ambiguous, about 15 of 13,447 turns per model.Remaining work
mainnow reports (cap-hit, empty, unclosed-think) count one output per instance, so for Multi-IF they describe only each conversation's last turn. BFCL multi-turn and the agent scaffolds share this limitation, so it is better fixed for every scaffold in a separate change.limitcontains only English, and the seven other<language>_accuracymetrics report 0.0. This matchesAccuracyMetricfor empty input. A sentinel value would need the dashboard to handle it.pythainlp. No Multi-IF conversation needs it, so it is left out.🤖 Generated with Claude Code