Skip to content

Correct BPE pre-tokenization whitespace documentation - #7789

Merged
svick merged 1 commit into
dotnet:mainfrom
svick:fix/bpe-pretokenizer-whitespace-docs
Oct 15, 2026
Merged

svick merged 1 commit into
dotnet:mainfrom
svick:fix/bpe-pretokenizer-whitespace-docs

Conversation

@svick

@svick svick commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Adjusts the documentation added in #7716 by moving the whitespace guidance from BpeOptions.ByteLevel to BpeOptions.PreTokenizer.

Whitespace removal is not related to the ByteLevel setting. When no pre-tokenizer is specified, BPE uses PreTokenizer.CreateWordOrNonWord(), which discards whitespace with either value of ByteLevel. 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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c5e01d75-322d-4ff0-96a2-51fe6fca4882
@svick
svick marked this pull request as ready for review October 13, 2026 14:39
@svick
svick requested a balanced review from Copilot October 13, 2026 14:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

@svick

svick commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

/ba-g CodeCoverage failure is #7417

@svick
svick merged commit d8ef8a5 into dotnet:main Oct 15, 2026
25 of 27 checks passed
@svick
svick deleted the fix/bpe-pretokenizer-whitespace-docs branch October 15, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tokenizers] BpeOptions.ByteLevel=true silently drops spaces and newlines when PreTokenizer is not set

4 participants