Open
Conversation
a514bb3 to
49be32f
Compare
tomtseng
commented
Feb 14, 2026
| user_prefix="<|start_header_id|>user<|end_header_id|>\n\n", | ||
| assistant_prefix="<|start_header_id|>assistant<|end_header_id|>\n\n", | ||
| end_turn="<|eot_id|>", | ||
| ), |
Collaborator
Author
There was a problem hiding this comment.
this was missing <|begin_of_text|> at the start of a formatted conversation. If we want to apply this kind of formatting I think we should just specify a model name and take its tokenizer.chat_template so we are sure it matches exactly
05fafb2 to
18ff014
Compare
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.
Summary
Unify all eval prompt formatting on
tokenizer.apply_chat_template()by making the template choice an explicit config variable (template_nameonModelConfig).Motivation
The codebase had a few different formatting mechanisms: (1) manual f-string formatting with
user_prefix/assistant_prefix/end_turn, (2)tokenizer.apply_chat_template()using HF built-in Jinja2 templates. This has the risk of being error-prone since there a bunch of different code paths doing the same thing. This PR makes the template choice an explicit config variable and routes all formatting throughapply_chat_template().Child PR #97 refactors attack training data formatting and removes the now-redundant
user_prefix/assistant_prefix/end_turnfields fromModelConfig.Code changes
template_namefield toModelConfigwith four options:native(use tokenizer built-in template),generic_chat,instruction_response,plainTextTemplateprefix/suffix registry viaTextTemplate.to_jinja2()load_tokenizer()viaconfigure_tokenizer_template()so evals don't each need their own formatting logicformat_chat_promptandapply_chat_template_with_fallbackfromevals/utils.pytowhitebox/utils/models/chat_format.py— I hit a circular import otherwisellama3,qwen,gpt_chat) in favor ofnative— better to just use the template given by the model tokenizer, rather than rewriting it ourselves and potentially getting it wrongBehavior changes
format_chat_prompt(). Withtemplate: plainthis is a no-op. With other templates, prompts now get chat formatting -- this will change eval resultsChild PR: #97