Repository navigation
Fix #35447 Tokenizer does not split text according to newly added input tokens - #35455
Closed
jiongjiongli wants to merge 1 commit into
Closed
jiongjiongli wants to merge 1 commit into
jiongjiongli wants to merge 1 commit into
Conversation
jiongjiongli
force-pushed
the
fix-tokenizer-text-split
branch
2 times, most recently
from
January 1, 2025 00:19
cf128ad to
fbd9036
Compare
Author
|
Hello @ArthurZucker , this issue repos using Below is repro code and actual result: # Code:
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("google-bert/bert-base-cased", use_fast=False)
tokenizer.add_tokens(["red", "e"])
output_tokens = tokenizer.tokenize("read")
print(f"Output tokens: {output_tokens}")
# Actual Output:
Output tokens: ['read'] |
jiongjiongli
force-pushed
the
fix-tokenizer-text-split
branch
from
January 12, 2025 22:19
12b6aa8 to
70d51bf
Compare
…newly added input tokens The root reason is Trie.split method didn't ignore partial match that should be removed Add test case to token split
jiongjiongli
force-pushed
the
fix-tokenizer-text-split
branch
from
January 20, 2025 04:37
70d51bf to
56c52db
Compare
ArthurZucker
left a comment
Collaborator
There was a problem hiding this comment.
Right, sorry!
Could you add another test with another model for example? 🤗
Seems to not work for ? for example or for emojis
Collaborator
|
Thanks for digging into the |
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.


Fix Bug
#35447 : Tokenizer does not split text according to newly added input tokens
Resolution
Method
Trie.split: Add steps to ignore partial match that should be removed@ArthurZucker and @itazap