初始化奖励
您正处于部署生成式模型的最后阶段。该模型用于为一家在线书店提供个性化推荐。为使模型更贴合人类偏好的推荐,您需要利用已收集的偏好数据训练一个奖励模型。第一步是初始化模型和配置参数。
AutoTokenizer 与 AutoModelForSequenceClassification 已从 transformers 预加载。RewardConfig 已从 trl 预加载。
本练习是课程的一部分
来自人类反馈的强化学习(RLHF)
练习说明
- 使用 Hugging Face 的
AutoModelForSequenceClassification加载用于序列分类任务的 GPT-1 模型"openai-gpt"。 - 使用
"output_dir"作为输出目录来初始化奖励配置,并将 token 最长长度设置为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=____)