Repository navigation
fix(luke): set post-processor to add <s></s> special tokens in plain-text encoding - #48555
Closed
Larslllllll wants to merge 1 commit into
Closed
Larslllllll wants to merge 1 commit into
Larslllllll wants to merge 1 commit into
Conversation
…text encoding Fixes LukeTokenizer dropping <s></s> special tokens when encoding plain text (without entity_spans). Root cause: LukeTokenizer.__init__ builds a raw BPE tokenizer with a pre-tokenizer and decoder but no post-processor. Previously the slow tokenizer path routed every call through build_inputs_with_special_tokens, which added the special tokens. After #40936 switched to the tokenizers backend, plain-text calls skip build_inputs_with_special_tokens entirely. Fix: after super().__init__(), set the RobertaProcessing post-processor (if cls/sep token IDs are available), matching RoBERTa tokenizer behavior. This resolves the test_sequence_builders regression and makes `tok("Hello world")["input_ids"]` return [0, 31414, 232, 2] instead of the incorrect [31414, 232].
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: luke |
Contributor
CI recapDashboard: View test results in Grafana |
vasqu
reviewed
Sep 7, 2026
vasqu
left a comment
Collaborator
There was a problem hiding this comment.
Imo doesnt make sense because that would change existing behavior is there any reason. Seems like an agent maybe :D
Collaborator
|
cc @itazap tho! |
Collaborator
|
#48408 will fix this |
Collaborator
|
PR is merged, closing |
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
Fixes LukeTokenizer dropping
<s></s>special tokens when encoding plain text.Problem
LukeTokenizerwas returning[31414, 232]instead of the expected[0, 31414, 232, 2]for plain text input:The
add_special_tokens=Falseflag was also being ignored, andspecial_tokens_maskwas returning[0, 0]instead of[1, 0, 0, 1].Root Cause
LukeTokenizer.__init__builds a raw BPE tokenizer with a pre-tokenizer and decoder but no post-processor. After #40936 switched to thetokenizersbackend, plain-text calls no longer route throughbuild_inputs_with_special_tokens. LUKE is the only tokenizer that definesbuild_inputs_with_special_tokenswithout a post-processor set.Fix
After
super().__init__(), set theRobertaProcessingpost-processor (ifcls/septoken IDs are available), matching howRobertaTokenizerhandles this:Testing
RUN_SLOW=1 pytest tests/models/luke/test_tokenization_luke.py::LukeTokenizerTest::test_sequence_builders— previously failing, now passes