Skip to content

Add Multi-IF: multi-turn, multilingual instruction following - #473

Merged
gregorybchris merged 4 commits into
mainfrom
chrisg/multi-if
Oct 16, 2026
Merged

gregorybchris merged 4 commits into
mainfrom
chrisg/multi-if

Conversation

@gregorybchris

@gregorybchris gregorybchris commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds Multi-IF (facebook/Multi-IF, pinned to 0ab97ce). 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.

uv run olmo-eval run -m my-model --harness multi_turn_chat -t multi_if
  • multi_turn_chat scaffold 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 in inference/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 in common/types beside LMRequest and LMOutput, so tasks don't import from the harness.

  • Same grader as IFEval and IFBench. IFEvalScorer's strict and loose verification loop is now verify_instructions(). IFEvalScorer (ifeval, ifeval_ood, ifeval_mt) and the new MultiIFScorer both call it; MultiIFScorer calls it once per turn. Multi-IF checks replies against the same ifbench registry, with three verifiers swapped for the reference implementation's multilingual versions in common/scorers/multilingual_instructions.py:

    • Word and sentence counts follow the reply's detected language. Chinese and Japanese count characters and split sentences on CJK punctuation, and Hindi splits sentences on the danda.
    • Curly and corner quotation marks also count as quotes.
    • Language detection uses its own seeded langdetect factory. The reference leaves langdetect unseeded, so the same reply can be counted differently on a rerun. emoji and langdetect are now direct dependencies.

    These three stay out of ifbench itself because changing them there would change IFEval and IFBench scores for non-English replies. The reference also has a Thai path that needs pythainlp. 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>_accuracy per language, and the primary accuracy, 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 ifeval and ifeval_ood: temperature 0.6, top-p 0.95, no token cap, with <think> traces stripped from each reply before checking. multi_if:paper uses the paper's settings: temperature 0.6, top-p 0.9, 1,024 max tokens.

Affected results

None. ifeval, ifeval_ood and the ifeval_mt tasks now call the shared verify_instructions(), but their verification behavior is unchanged, so no docs/result-compatibility.md entry is needed. Every other change adds new code: a task, scorer, metric, scaffold and preset.

Type of Change

  • Bug fix
  • New task, variant, or suite
  • New feature
  • Breaking change or change to existing results
  • Dependency or image update
  • Documentation update
  • Refactoring (no functional changes)

Validation

  • uv run ruff check src/ tests/ and uv run ruff format --check src/ tests/
  • uv run ty check src/: one warning about an unused type: ignore in harness/sandbox/executor.py, which also appears on main.
  • uv run pytest tests/ --ignore=tests/integration -v: 3,806 passed in the default environment, and 3,847 passed with the agents and litellm extras, after rebasing onto main at a963311 (SWE-bench Verified). uv lock --check passes.
  • Integration tests: not run. This PR changes no storage, provider or sandbox code.
  • New tests added for new behavior:
    • the scaffold: conversation order, request and harness system prompts, overflow on the first and a later turn, failed turns, the preset
    • the multilingual verifiers: counts checked against the reference implementation, including its own docstring example, and deterministic language detection
    • verify_instructions, including instructions it cannot build
    • the task, scorer and metrics, including extraction after trace stripping and equal weighting of languages

Loaded 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 main after 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 main and the interaction with #445 and #475, and found nothing to change.

Llama-3.1-8B-Instruct matches the paper

multi_if:paper on 1× L40 (ai2/neptune), Beaker experiment 01M4Y129QSQM3FADDTCR2YTEYA, 4,501 conversations:

Turn This PR Paper (Table 1) Difference
1 0.710 0.688 +2.2
2 0.625 0.615 +1.0
3 0.544 0.542 +0.2
Mean 0.627 0.615 +1.2

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_strict and gen_acc_loose from facebookresearch/Multi-IF and compared every instruction verdict:

  • 13,430 of 13,447 turns (99.9%) agree on every strict and loose verdict.
  • Upstream's pooled per-turn scores are 0.7192, 0.6332 and 0.5521. This PR's code, pooled the same way, gives 0.7192, 0.6333 and 0.5524.

The 17 differing turns all involve one of two sources of randomness in the reference:

  1. langdetect is nondeterministic on short or mixed-script text, and the Chinese word and sentence counts depend on which language it picks.
  2. Upstream builds each verifier separately for strict and for loose scoring, so a verifier with an unspecified kwarg draws different random values for each. The repo's scorer builds each verifier once, so strict and loose use the same criteria.

Other models in the default regime

Model Hardware Turn 1 Turn 2 Turn 3 Mean Beaker
Olmo-3-7B-Instruct 1× L40 0.742 0.597 0.468 0.602 01M4Y1SX3RKR3GH8M2H5PJQPYG
Qwen3-8B (thinking) 2× B300 0.867 0.787 0.697 0.784 01M4Y5449XFAASAWPE97YV74CH

For 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:

Language Olmo-3-7B-Instruct Qwen3-8B
English 0.757 0.820
Spanish 0.686 0.810
Portuguese 0.671 0.797
French 0.660 0.824
Chinese 0.626 0.762
Italian 0.600 0.827
Russian 0.509 0.720
Hindi 0.310 0.711

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 langdetect finds ambiguous, about 15 of 13,447 turns per model.

Remaining work

  • Per-turn generation counts. The generation counts main now 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.
  • Languages missing from a limited run. The dataset is sorted by language, so a run with a small limit contains only English, and the seven other <language>_accuracy metrics report 0.0. This matches AccuracyMetric for empty input. A sentinel value would need the dashboard to handle it.
  • Thai counting. The reference counts Thai words and sentences with pythainlp. No Multi-IF conversation needs it, so it is left out.

🤖 Generated with Claude Code

@gregorybchris
gregorybchris marked this pull request as ready for review October 14, 2026 23:13
@gregorybchris
gregorybchris requested a review from a team as a code owner October 14, 2026 23:13
gregorybchris and others added 4 commits October 16, 2026 13:17
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]>
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
gregorybchris merged commit 96e15c9 into main Oct 16, 2026
8 checks passed
@gregorybchris
gregorybchris deleted the chrisg/multi-if branch October 16, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant