Skip to content

Commit

Permalink
Ensure correct padding token for Phi and Pythia models (#3899)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnavgarg1 committed Jan 18, 2024
1 parent 6e93ea7 commit ea50811
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ludwig/utils/tokenizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,11 +845,16 @@ def get_unk_token(self) -> str:
def _set_pad_token(self) -> None:
"""Sets the pad token and pad token ID for the tokenizer."""

# CodeGenTokenizer Used by Phi-2
# GPTNeoXTokenizerFast Used by Pythia
from transformers import (
CodeGenTokenizer,
CodeGenTokenizerFast,
CodeLlamaTokenizer,
CodeLlamaTokenizerFast,
GPT2Tokenizer,
GPT2TokenizerFast,
GPTNeoXTokenizerFast,
LlamaTokenizer,
LlamaTokenizerFast,
)
Expand All @@ -865,12 +870,15 @@ def _set_pad_token(self) -> None:
if any(
isinstance(self.tokenizer, t)
for t in [
CodeGenTokenizer,
CodeGenTokenizerFast,
CodeLlamaTokenizer,
CodeLlamaTokenizerFast,
GPT2Tokenizer,
GPT2TokenizerFast,
GPTNeoXTokenizerFast,
LlamaTokenizer,
LlamaTokenizerFast,
CodeLlamaTokenizer,
CodeLlamaTokenizerFast,
]
):
if hasattr(self.tokenizer, "eos_token") and self.tokenizer.eos_token is not None:
Expand Down

0 comments on commit ea50811

Please sign in to comment.