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

Added control to tokenizer for pad_token #418

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions scripts/training/run_clm_sft_with_peft.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

from transformers.trainer_utils import PREFIX_CHECKPOINT_DIR

DEFAULT_PAD_TOKEN = "<pad>"

Check warning on line 56 in scripts/training/run_clm_sft_with_peft.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/training/run_clm_sft_with_peft.py#L56

Possible hardcoded password: '<pad>'

require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/language-modeling/requirements.txt")

Expand Down Expand Up @@ -340,6 +341,10 @@
if (len(tokenizer)) != 55296:
raise ValueError(f"The vocab size of the tokenizer should be 55296, but found {len(tokenizer)}.\n"
"Please use Chinese-LLaMA-2 tokenizer.")

Check notice on line 344 in scripts/training/run_clm_sft_with_peft.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/training/run_clm_sft_with_peft.py#L344

Trailing whitespace
if tokenizer.pad_token is None:
print(f"Adding pad token {DEFAULT_PAD_TOKEN}")
tokenizer.add_special_tokens(dict(pad_token=DEFAULT_PAD_TOKEN))

data_collator = DataCollatorForSupervisedDataset(tokenizer=tokenizer)
eval_dataset=None
Expand Down