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

Feature: Allow for overriding pad_token_id #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions src/xllm/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,12 @@ class Config:
"help": "Padding side of the collator: None, right or left",
},
)
tokenizer_padding_token: Optional[str] = field(
default=None,
metadata={
"help": "Padding token for tokenizer",
},
)

# collator
collator_key: str = field(
Expand Down
6 changes: 6 additions & 0 deletions src/xllm/core/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ def build_tokenizer(config: Config, use_fast: Optional[bool] = None) -> PreTrain
**kwargs,
)

if config.tokenizer_padding_token is not None:
tokenizer.pad_token = config.tokenizer_padding_token
dist_logger.info(
f"Overrode tokenizer pad token with {config.tokenizer_padding_token}", local_rank=config.local_rank
)

if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
dist_logger.info(message="Tokenizer pad token set to eos token", local_rank=config.local_rank)
Expand Down