Repository navigation
Correct BPE pre-tokenization whitespace documentation - #7789
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c5e01d75-322d-4ff0-96a2-51fe6fca4882
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The documentation accurately reflects the tokenizer implementation and introduces no runtime changes.
0 open findings
What changed in this PR
Corrects BPE whitespace documentation by associating it with pre-tokenization rather than byte-level mapping.
Changes:
- Documents default whitespace removal and segment boundaries.
- Removes misleading guidance from
ByteLevel.
| File | Description |
|---|---|
src/Microsoft.ML.Tokenizers/Model/BpeOptions.cs |
Corrects PreTokenizer and ByteLevel documentation. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
rosebyte
approved these changes
Oct 13, 2026
matouskozak
approved these changes
Oct 15, 2026
Member
Author
|
/ba-g CodeCoverage failure is #7417 |
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.
Adjusts the documentation added in #7716 by moving the whitespace guidance from
BpeOptions.ByteLeveltoBpeOptions.PreTokenizer.Whitespace removal is not related to the
ByteLevelsetting. When no pre-tokenizer is specified, BPE usesPreTokenizer.CreateWordOrNonWord(), which discards whitespace with either value ofByteLevel. Byte-level mapping operates on the retained segments; it does not configure pre-tokenization or preserve characters excluded by the pre-tokenizer.The remark also clarifies that each segment is encoded independently, so BPE merges cannot cross segment boundaries. To preserve whitespace during pre-tokenization, callers should select rules matching the model, such as the GPT-2 pattern where appropriate. No exception or runtime behavior change is needed.
Documentation-only change.
Closes #7715
/cc @lunosia