Add post_process_tokens and post_process_ids methods#1944
Open
ArthurZucker wants to merge 1 commit intomainfrom
Open
Add post_process_tokens and post_process_ids methods#1944ArthurZucker wants to merge 1 commit intomainfrom
ArthurZucker wants to merge 1 commit intomainfrom
Conversation
Add two new methods to PostProcessor trait and implementations: - post_process_tokens: processes tokens (strings) through the post-processor - post_process_ids: processes token IDs through the post-processor These methods enable working with token sequences directly without needing a full Encoding. Useful for understanding how special tokens are added without going through the full tokenization pipeline. Implemented for: BertProcessing, RobertaProcessing, TemplateProcessing, Sequence, and ByteLevel processors. Includes Python bindings and tests.
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
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.
Summary
post_process_tokensmethod to process tokens (strings) through post-processorspost_process_idsmethod to process token IDs through post-processorsMotivation
These methods enable working with token sequences directly without needing a full Encoding. This is useful for:
Test plan
cargo test --lib)cargo test --test serialization)pytest tests/bindings/test_processors.py tests/bindings/test_tokenizer.py)🤖 Generated with Claude Code