设置 Trainer
在设置好训练参数后,您需要继续配置 Trainer,才能开始使用微调后的模型。
TrainingArguments 和 Trainer 已为您加载,同时还包括之前的 model、tokenizer 和 training_args。
注意: 为加快运行速度,本练习已禁用实际训练。
本练习是课程的一部分
Python 中的 LLM 入门
练习说明
- 设置
Trainer()对象。 - 传入先前定义的训练参数和分词器。
- 训练模型。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# 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
____