Skip to content
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>"

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 @@ def main():
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.")

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