Fix phi3 chat template confusion with zephyr#7449
Merged
ngxson merged 8 commits intoggml-org:masterfrom May 23, 2024
tristandruyen:master
Merged
Fix phi3 chat template confusion with zephyr#7449ngxson merged 8 commits intoggml-org:masterfrom tristandruyen:master
ngxson merged 8 commits intoggml-org:masterfrom
tristandruyen:master
Conversation
Contributor
tristandruyen
commented
May 22, 2024
ngxson
reviewed
May 23, 2024
ngxson
approved these changes
May 23, 2024
Collaborator
ngxson
left a comment
There was a problem hiding this comment.
LGTM overall. It would be nice to have all 4 templates in the test.
Co-authored-by: Xuan Son Nguyen <thichthat@gmail.com>
ngxson
requested changes
May 23, 2024
Co-authored-by: Xuan Son Nguyen <thichthat@gmail.com>
ngxson
approved these changes
May 23, 2024
Collaborator
|
OK I'll merge when CI passes |
Contributor
Author
|
The test failures seem unrelated to the changes, should be good to merge. |
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.




Reported in & Resolves #7432
Problem
Zephyr & Phi3 use similar tokens like
<|assistant|>&<|user|>, but they use different eos tokens, as the zephyr template appears first in the if else chain, phi3 is misdetected as zephyr, which causes wrong<|endoftext|>instead of<|end|>tokens to appear in the prompt as reported in the referenced issue.Root-Cause
Phi-3's template, seems to have changed sometime after my PR #6857 was merged.
Initially it didn't explicitly include <|user|> but spliced the role into there...
OLD:
NEW:
This causes this mis-matching as zephyr.
Solution
It's pretty simple, stop zephyr from applying to every model with <|user|> in the template by
adding an additional requirement.reordering the if else's