-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix phi3 chat template confusion with zephyr #7449
Merged
Merged
Conversation
This file contains 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
tristandruyen
changed the title
Fix phi3 template matching vs zephyr
Fix phi3 chat template confusion with zephyr
May 22, 2024
mofosyne
added
model
Model specific
Review Complexity : Low
Trivial changes to code that most beginner devs (or those who want a break) can tackle. e.g. UI fix
labels
May 22, 2024
tristandruyen
commented
May 22, 2024
ngxson
reviewed
May 23, 2024
ngxson
approved these changes
May 23, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
OK I'll merge when CI passes |
The test failures seem unrelated to the changes, should be good to merge. |
teleprint-me
pushed a commit
to teleprint-me/llama.cpp
that referenced
this pull request
May 23, 2024
* Fix phi3 template matching vs zephyr * Add regression test for new phi3 chat template * Implement review suggestions * Fix phi3 jinja test templates & match by <|end|> * Apply suggestion Co-authored-by: Xuan Son Nguyen <thichthat@gmail.com> * Add all phi3 template variants in tests * Remove unneeded message trimming Co-authored-by: Xuan Son Nguyen <thichthat@gmail.com> * Fix tests to not expect trimmed messages --------- Co-authored-by: Xuan Son Nguyen <thichthat@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
model
Model specific
Review Complexity : Low
Trivial changes to code that most beginner devs (or those who want a break) can tackle. e.g. UI fix
testing
Everything test related
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