-
Notifications
You must be signed in to change notification settings - Fork 1.9k
BpeTokenizer Cleanup #7514
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
BpeTokenizer Cleanup #7514
Conversation
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.
Pull Request Overview
This PR implements cleanup improvements for the BPE tokenizer by adding support for special tokens that are not part of the main vocabulary and simplifying the decode method implementation.
- Enhances special token handling for BeginningOfSentenceToken and EndOfSentenceToken when they exist only in special tokens
- Refactors the Decode method to use a single loop instead of duplicated logic
- Adds comprehensive test coverage for the new special token functionality
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/Microsoft.ML.Tokenizers/Model/BPETokenizer.cs | Enhanced constructor to check special tokens for BOS/EOS tokens and streamlined Decode method implementation |
test/Microsoft.ML.Tokenizers.Tests/BpeTests.cs | Added comprehensive test case for special token handling with BOS/EOS tokens |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Eric StJohn <ericstj@microsoft.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7514 +/- ##
==========================================
+ Coverage 69.01% 69.02% +0.01%
==========================================
Files 1482 1482
Lines 274050 274092 +42
Branches 28266 28266
==========================================
+ Hits 189128 189195 +67
+ Misses 77526 77516 -10
+ Partials 7396 7381 -15
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
* BpeTokenizer Cleanup * Apply suggestions from code review Co-authored-by: Eric StJohn <ericstj@microsoft.com> --------- Co-authored-by: Eric StJohn <ericstj@microsoft.com>
This change is a simple clean-up for the BPE tokenizer:
BeginningOfSentenceToken
andEndOfSentenceToken
when these tokens are not present in the vocabulary but are instead provided as special tokens by the tokenizer.Decode
method.