Add custom chat template option #1261
Open
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.
#390
Right now the RL and SFT datasets use the chat template of the tokenizer to format the prompt. Some models do not have a chat template (for example
deepseek-ai/deepseek-coder-1.3b-base), and sometimes it can be useful to override this template. This adds the option to override the template when loading the tokenizer.For example, setting to
"{{ bos_token }}{{ messages }}"and assigning"string"to the dataset prompt key, will make the prompt_with_chat_template<bos>stringBy default the config value is null, so that the default model template is used.
I have added the required code to make this work with the RL dataset, SFT dataset, and main_ppo / main_ppo_split. If there are other parts of the code that should be updated to make this option work, let me know.
More info here https://huggingface.co/docs/transformers/main/en/chat_templating