設定 reward trainer
你的專案持續進行中。你現在已經有可以開始訓練獎勵模型的 model 與 config 物件。
訓練與評估資料集已預先載入為 train_data 與 eval_data。RewardTrainer 已從 trl 匯入。
本練習屬於課程
Reinforcement Learning from Human Feedback(RLHF)
練習說明
- 透過指派模型、tokenizer、訓練資料集、評估資料集與獎勵組態到其屬性,初始化
RewardTrainer()。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
tokenizer = AutoTokenizer.from_pretrained("openai-gpt")
model = AutoModelForSequenceClassification.from_pretrained('openai-gpt')
config = RewardConfig(output_dir='output_dir', max_length=60)
# Initialize the reward trainer
trainer = ____