Skip to content

feat: multiturn support for ChatML - #2314

Open
ysjprojects wants to merge 2 commits into
mainfrom
sj/multiturn-prompt-chatml
Open

feat: multiturn support for ChatML#2314
ysjprojects wants to merge 2 commits into
mainfrom
sj/multiturn-prompt-chatml

Conversation

@ysjprojects

Copy link
Copy Markdown
Collaborator

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_multiturn attribute, introducing an add_generation_prompt parameter, and refactoring prompt application logic for consistency and extensibility.

Multi-turn and Prompt Formatting Enhancements:

  • Added a supports_multiturn attribute to PromptStyle and its subclasses (Llama3, R1Base, ChatML), indicating whether each style supports multi-turn conversations. [1] [2] [3] [4]
  • Updated the apply method signature for multi-turn styles to accept an add_generation_prompt argument, allowing control over whether a generation prompt is appended (for inference vs. training). [1] [2] [3]

Prompt Logic Refactoring:

  • Moved the has_system_prompt utility function to the module level for reuse and clarity, and updated its usage in prompt formatting logic. [1] [2] [3] [4]

Training/Inference Handling:

  • Modified prompt formatting logic in Llama3, R1Base, and ChatML to conditionally add the generation prompt based on the add_generation_prompt parameter, supporting both inference and training workflows. [1] [2] [3]

Testing Improvements:

  • Added and updated tests to verify that prompt formatting behaves correctly for both inference and training cases, specifically checking the behavior of the add_generation_prompt parameter.

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