Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
test/Microsoft.ML.Tokenizers.Tests/TiktokenTests.cs:511
- Since the Phi-4 model is now supported, adding 'phi-4' as an encoding name in a test case for negative scenarios appears to be a mistake. Consider removing it from TestEncodingNamesNegativeCases or moving it to a positive test case.
[InlineData("phi-4")]
Member
Author
stephentoub
approved these changes
Feb 23, 2025
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7396 +/- ##
=======================================
Coverage 68.89% 68.89%
=======================================
Files 1473 1473
Lines 270817 270836 +19
Branches 27883 27884 +1
=======================================
+ Hits 186568 186583 +15
- Misses 76975 76985 +10
+ Partials 7274 7268 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
Fixes #7337
Phi-4 model is using the Tiktoken tokenizer with the Cl100K_Base encoding file (like gpt-4 tokenizer). It uses different special tokens though
<|im_start|>,<|im_end|>, and<|im_sep|>.The tokenizer can be created by:
Note
The Phi-4 model on Hugging Face (https://huggingface.co/microsoft/phi-4/tree/main) converts the CL100K_Base encoding vocabulary into
vocab.jsonandmerges.txt, which are compatible with theGPT2TokenizerFasttokenizer in Python. This is likely intended for users who are not using the Tiktoken tokenizer, though both should generally produce the same results.