Conversation
Collaborator
|
Hey! I'll have a look I am in the middle of a big refactoring for RC0! |
ArthurZucker
reviewed
Sep 2, 2026
ArthurZucker
left a comment
Collaborator
There was a problem hiding this comment.
hey, will re-consider after #2119
Author
|
okay |
Author
|
How鈥檚 it going? |
Collaborator
|
rc0 should shop soon if you want to rebase to that branch! from the PR |
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.
To address #2225, I made the following changes.
#2225 mainly discusses a highly fragmented situation that exists today: although tokenizers already has a mature special-token mechanism, the encoding pipelines of the vast majority of models deployed for inference with vLLM/SGLang still ignore special tokens. In the agent era, this fragmentation can amplify security risks and potentially undermine existing safety-alignment strategies.
So far, the only approach we have observed is that a small number of models choose to bypass Jinja, but this requires them to reimplement their own parsers. Examples include K3 (https://github.com/vllm-project/vllm/blob/d3e2888c7588fe3a7be93606c7c626dbfd304d2e/rust/src/chat/src/renderer/kimi_k3/encoding.rs#L29) and DeepSeek (https://github.com/vllm-project/vllm/blob/main/vllm/tokenizers/deepseek_v32_encoding.py).
We are introducing this abstraction into the tokenizer itself (with follow-up integration needed in Jinja and Transformers). This should help reduce duplicated work across the community and improve the overall security of the ecosystem.
Summary
Adds opt-in structured special-token JSON support via structured_special_tokens=True across sync, async, batch,
and fast encoding APIs.
Validation
Passed Rust formatting, Clippy, 299 Rust tests, 159 Python binding tests, and dedicated sync/async structured-
input coverage.