This repository was archived by the owner on Jun 3, 2025. It is now read-only.
Replace Fastchat Chat Templates with HF apply_chat_template#1499
Merged
Conversation
apply_chat_template
rahul-tuli
previously approved these changes
Dec 21, 2023
dsikka
reviewed
Dec 21, 2023
dsikka
previously approved these changes
Dec 21, 2023
Contributor
dsikka
left a comment
There was a problem hiding this comment.
LGTM pending merge conflicts fixed
bfineran
approved these changes
Dec 27, 2023
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Inspired by vllm-project/vllm#1365 and instigated by prefill benchmarking, using the HF Chat Templates hidden within the model's
tokenizerseems to be a more elegant approach.From a performance perspective, fastchat's default template adds over 400 tokens as a preamble to chat conversations, without actually using the right prompt format the model was trained on! Example below:
All of the above is just a default preamble, and then it proceeds to contain it within a
### Human: ... ### Assistant:format is not correct for our testedhf:neuralmagic/TinyLlama-1.1B-Chat-v0.4-pruned50-quant-ds, which prefers<s>[INST] ... <<SYS>> ... <</SYS>> ... [/INST]. HFtokenizer.apply_chat_templatehas no problem generating that right format and integrating the roles properly in the same list of dictionaries format.