Repository navigation
Description
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
math_data_processor,nemo_rl/data/processors.pylines 500–515 at702cd794f:sys = tokenizer.apply_chat_template([system], add_generation_prompt=False)followed bymessage = tokenizer.apply_chat_template([user_message], add_generation_prompt=True), thensys + message.multichoice_qa_processor, lines 873–890: same shape.
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
[-]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)[/+]test(data): cover eval processors with real chat templates