feat: multiturn support for ChatML - #2314
Open
ysjprojects wants to merge 2 commits into
Open
Conversation
ysjprojects
requested review from
andyland,
k223kim,
lianakoleva and
t-vi
as code owners
August 30, 2026 23:01
for more information, see https://pre-commit.ci
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.
This pull request enhances the prompt formatting system to better support multi-turn conversations and training/inference scenarios for several prompt styles. The most important changes include adding a
supports_multiturnattribute, introducing anadd_generation_promptparameter, and refactoring prompt application logic for consistency and extensibility.Multi-turn and Prompt Formatting Enhancements:
supports_multiturnattribute toPromptStyleand its subclasses (Llama3,R1Base,ChatML), indicating whether each style supports multi-turn conversations. [1] [2] [3] [4]applymethod signature for multi-turn styles to accept anadd_generation_promptargument, allowing control over whether a generation prompt is appended (for inference vs. training). [1] [2] [3]Prompt Logic Refactoring:
has_system_promptutility function to the module level for reuse and clarity, and updated its usage in prompt formatting logic. [1] [2] [3] [4]Training/Inference Handling:
Llama3,R1Base, andChatMLto conditionally add the generation prompt based on theadd_generation_promptparameter, supporting both inference and training workflows. [1] [2] [3]Testing Improvements:
add_generation_promptparameter.