設定 Trainer
在設定好訓練參數後,在實際使用微調後的模型之前,你需要先建立 trainer。
TrainingArguments 與 Trainer 已為你載入,同時也包含你先前的 model、tokenizer 和 training_args。
注意:為了加快執行,本練習已停用實際訓練。
本練習屬於課程
Python 的 LLM 入門
練習說明
- 建立
Trainer()物件。 - 指定先前定義的訓練參數與 tokenizer。
- 訓練模型。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Set up the trainer object
trainer = ____(
model=model,
# Assign the training arguments and tokenizer
____,
train_dataset=tokenized_training_data,
eval_dataset=tokenized_test_data,
____
)
# Train the model
____