Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[T5 and Llama Tokenizer] remove warning #29346

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/transformers/models/llama/tokenization_llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def get_vocab(self):
return vocab

# Copied from transformers.models.t5.tokenization_t5.T5Tokenizer.tokenize
def tokenize(self, text: "TextInput", add_special_tokens=False, **kwargs) -> List[str]:
def tokenize(self, text: "TextInput", **kwargs) -> List[str]:
"""
Converts a string to a list of tokens. If `self.legacy` is set to `False`, a prefix token is added unless the
first token is special.
Expand All @@ -255,7 +255,7 @@ def tokenize(self, text: "TextInput", add_special_tokens=False, **kwargs) -> Lis
if self.add_prefix_space:
text = SPIECE_UNDERLINE + text

tokens = super().tokenize(text, add_special_tokens=add_special_tokens, **kwargs)
tokens = super().tokenize(text, **kwargs)

if len(tokens) > 1 and tokens[0] == SPIECE_UNDERLINE and tokens[1] in self.all_special_tokens:
tokens = tokens[1:]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def get_spm_processor(self, from_slow=False):
return tokenizer

# Copied from transformers.models.t5.tokenization_t5.T5Tokenizer.tokenize
def tokenize(self, text: "TextInput", add_special_tokens=False, **kwargs) -> List[str]:
def tokenize(self, text: "TextInput", **kwargs) -> List[str]:
"""
Converts a string to a list of tokens. If `self.legacy` is set to `False`, a prefix token is added unless the
first token is special.
Expand All @@ -459,7 +459,7 @@ def tokenize(self, text: "TextInput", add_special_tokens=False, **kwargs) -> Lis
if self.add_prefix_space:
text = SPIECE_UNDERLINE + text

tokens = super().tokenize(text, add_special_tokens=add_special_tokens, **kwargs)
tokens = super().tokenize(text, **kwargs)

if len(tokens) > 1 and tokens[0] == SPIECE_UNDERLINE and tokens[1] in self.all_special_tokens:
tokens = tokens[1:]
Expand Down
4 changes: 2 additions & 2 deletions src/transformers/models/t5/tokenization_t5.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def __setstate__(self, d):
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
self.sp_model.Load(self.vocab_file)

def tokenize(self, text: "TextInput", add_special_tokens=False, **kwargs) -> List[str]:
def tokenize(self, text: "TextInput", **kwargs) -> List[str]:
"""
Converts a string to a list of tokens. If `self.legacy` is set to `False`, a prefix token is added unless the
first token is special.
Expand All @@ -389,7 +389,7 @@ def tokenize(self, text: "TextInput", add_special_tokens=False, **kwargs) -> Lis
if self.add_prefix_space:
text = SPIECE_UNDERLINE + text

tokens = super().tokenize(text, add_special_tokens=add_special_tokens, **kwargs)
tokens = super().tokenize(text, **kwargs)

if len(tokens) > 1 and tokens[0] == SPIECE_UNDERLINE and tokens[1] in self.all_special_tokens:
tokens = tokens[1:]
Expand Down
Loading