🚀 奖励模型概述
本奖励模型基于基础模型 mistralai/Mistral-7B-Instruct-v0.2 进行训练。
训练脚本可在 https://github.com/WeiXiongUST/RLHF-Reward-Modeling 找到。
有关训练细节(数据混合、参数等),可查看简短博客:https://www.notion.so/Reward-Modeling-for-RLHF-abe03f9afdac42b9a5bee746844518d0
✨ 主要特性
📦 安装指南
文档未提供安装步骤,故跳过此章节。
💻 使用示例
基础用法
from transformers import AutoTokenizer, pipeline
rm_tokenizer = AutoTokenizer.from_pretrained("weqweasdas/RM-Mistral-7B")
device = 0
rm_pipe = pipeline(
"sentiment-analysis",
model="weqweasdas/RM-Mistral-7B",
device=device,
tokenizer=rm_tokenizer,
model_kwargs={"torch_dtype": torch.bfloat16}
)
pipe_kwargs = {
"return_all_scores": True,
"function_to_apply": "none",
"batch_size": 1
}
chat = [
{"role": "user", "content": "Hello, how are you?"},
{"role": "assistant", "content": "I'm doing great. How can I help you today?"},
{"role": "user", "content": "I'd like to show off how chat templating works!"},
]
test_texts = [tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=False).replace(tokenizer.bos_token, "")]
pipe_outputs = rm_pipe(test_texts, **pipe_kwargs)
rewards = [output[0]["score"] for output in pipe_outputs]
📚 详细文档
模型详情
若你对该奖励模型或奖励建模有任何疑问,欢迎发送邮件至 wx13@illinois.edu 与我交流。
数据集预处理
该模型在以下数据集的混合数据上进行训练。我们还在 weqweasdas/preference_dataset_mixture2_and_safe_pku 中提供了混合数据。
此混合数据与原始数据集的差异:
- HH-RLHF:仅使用有用子集,并删除
chosen_response == rejected_response
的噪声样本;
- SHP:仅使用得分比 > 2 的样本,每个提示最多取 5 个比较样本,共 109526 个;
- Ultrafeedback:与 UltraFeedback-Binarized 类似,使用细粒度得分而非总体得分对样本进行排序。同时,每个提示取所有可能的 6 对比较样本。最后,删除得分相等的选定对,共 267416 个;
- HelpSteer:使用有用性和正确性的平均值对样本进行排序。同时,取所有可能的 6 对比较样本。最后,删除得分相等的选定对,共 21576 个。
训练
我们以 5e-6 的学习率、512 的批量大小对模型进行了一个 epoch 的训练,并采用了余弦学习率衰减,热身比例为 0.03。
结果
该奖励模型在 RewardBench 中排名第 2。
引用
本仓库是迭代拒绝采样微调(iterative rejection sampling fine-tuning)和迭代 DPO 的一部分。如果你认为本仓库的内容对你的工作有帮助,请考虑按以下方式引用:
@article{dong2023raft,
title={Raft: Reward ranked finetuning for generative foundation model alignment},
author={Dong, Hanze and Xiong, Wei and Goyal, Deepanshu and Pan, Rui and Diao, Shizhe and Zhang, Jipeng and Shum, Kashun and Zhang, Tong},
journal={arXiv preprint arXiv:2304.06767},
year={2023}
}
@misc{xiong2024iterative,
title={Iterative Preference Learning from Human Feedback: Bridging Theory and Practice for RLHF under KL-Constraint},
author={Wei Xiong and Hanze Dong and Chenlu Ye and Ziqi Wang and Han Zhong and Heng Ji and Nan Jiang and Tong Zhang},
year={2024},
eprint={2312.11456},
archivePrefix={arXiv},
primaryClass={cs.LG}
}