開始使用免費開始

初始化獎勵

你正進入部署一個產生式模型的最後階段,這個模型用於線上書店的個人化推薦。為了讓模型更貼近人類偏好的推薦結果,你需要使用已收集的偏好資料來訓練一個獎勵模型。第一步是初始化模型與設定參數。

AutoTokenizerAutoModelForSequenceClassification 已從 transformers 預先載入。RewardConfig 已從 trl 預先載入。

本練習屬於課程

Reinforcement Learning from Human Feedback(RLHF)

檢視課程

練習說明

  • 使用 Hugging Face 的 AutoModelForSequenceClassification 載入序列分類任務的 GPT-1 模型 "openai-gpt"
  • 使用 "output_dir" 作為輸出目錄來初始化獎勵設定,並將權杖的最大長度設為 60

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Load the pre-trained GPT-1 model for text classification
model = ____

tokenizer = AutoTokenizer.from_pretrained("openai-gpt")

# Initialize the reward configuration and set max_length
config = ____(output_dir=____, max_length=____)
編輯並執行程式碼