Skip to content

Evaluation-path processors render a duplicated default system block (two chat-template calls) #4185

Closed

Description

@Alvorecer721

Summary

math_data_processor and multichoice_qa_processor render the system message and the user message with two separate tokenizer.apply_chat_template calls and concatenate the strings. Chat templates that inject a default system message whenever the first message is not system emit that default block again on the user-only call. The rendered prompt then differs from what the same tokenizer produces for the same conversation at serving time.

math_hf_data_processor, which the shipped training recipes use, already builds one message list with the system and user turns and renders it in a single call; the two evaluation-path processors should do the same.

Where

Both are reached through run_eval: math_data_processor via MathDataset and LocalMathDataset (nemo_rl/data/datasets/eval_datasets/__init__.py), multichoice_qa_processor via the multiple-choice evaluation datasets.

Reproduction

Qwen/Qwen2.5-Math-1.5B-Instruct, system prompt Answer inside \boxed{}., user turn What is 2+2?:

sys_part  = tok.apply_chat_template([{"role": "system", "content": SYSTEM}], tokenize=False, add_generation_prompt=False)
user_part = tok.apply_chat_template([{"role": "user", "content": PROBLEM}], tokenize=False, add_generation_prompt=True)
two_calls = sys_part + user_part                      # what the eval processors build
one_call  = tok.apply_chat_template([{"role": "system", "content": SYSTEM}, {"role": "user", "content": PROBLEM}], tokenize=False, add_generation_prompt=True)

| | tokens | <|im_start|>system blocks |
|---|---|---|
| two calls (current eval processors) | 45 | 2 |
| one call (what math_hf_data_processor does) | 25 | 1 |

Two-call output:

<|im_start|>system
Answer inside \boxed{}.<|im_end|>
<|im_start|>system
Please reason step by step, and put your final answer within \boxed{}.<|im_end|>
<|im_start|>user
What is 2+2?<|im_end|>
<|im_start|>assistant

One-call output:

<|im_start|>system
Answer inside \boxed{}.<|im_end|>
<|im_start|>user
What is 2+2?<|im_end|>
<|im_start|>assistant

The user's system prompt is followed by a second, model-default system block that can contradict it. Templates that also prepend BOS on every render additionally produce two BOS tokens in one prompt.

Exposure

The shipped eval configs (examples/configs/evals/*.yaml) set system_prompt_file: null, so with no system message there is a single call and the output matches serving. The two-call rendering diverges from the single-call one for most templates in the shipped recipes. Rendered with each model's own chat template: the Qwen 2.5 family, Nemotron 3 Nano/Super/Lightning, Moonlight and gpt-oss insert a default system block; DeepSeek-R1-Distill, GLM 4.7/5.1/5.2, Phi-4-mini and Mistral-Nemo duplicate or restructure their sequence-start tokens; the Qwen 3 family renders both ways identically. Llama 3.1/3.2 Instruct were not rendered (gated). For a user who trains with math_hf_data_processor and evaluates through run_eval with the same system prompt, the evaluation prompt differs from the training prompt.

Proposed fix

Give both evaluation processors the single-call shape that math_hf_data_processor already has, plus a regression test with a fake template that injects a default system block, asserting exactly one system block in the output. Happy to open a PR.

Activity

  1. added
    bug
    on Sep 17, 2026
  2. changed the title [-]math_hf_data_processor renders a second BOS and the template's default system block when a system prompt is set[/-] [+]Evaluation-path processors render a duplicated default system block (two chat-template calls)[/+] on Sep 17, 2026
  3. added
    waiting-on-maintainers
    and removed
    waiting-on-maintainers
    on Sep 20, 2026
  4. added
    waiting-on-maintainers
    and removed
    waiting-on-maintainers
    on Oct 5, 2026
  5. removed
    waiting-on-maintainers
    on Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugcommunity-request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions