🚀 RLHF報酬モデル
この報酬関数は、PPO、反復SFT、反復DPOなどのRLHFに使用できます。
🚀 クイックスタート
この報酬モデルは、Reward-Benchにおける2024年4月20日時点のSOTAオープンソースRMです。
- 論文: RLHF Workflow: From Reward Modeling to Online RLHF (TMLR, 2024年掲載)
- 著者: Hanze Dong*, Wei Xiong*, Bo Pang*, Haoxiang Wang*, Han Zhao, Yingbo Zhou, Nan Jiang, Doyen Sahoo, Caiming Xiong, Tong Zhang
- コード: https://github.com/RLHFlow/RLHF-Reward-Modeling/
✨ 主な機能
- この報酬関数は、PPO、反復SFT、反復DPOなどのRLHFに使用できます。
- この報酬モデルは、Reward-Benchにおける2024年4月20日時点のSOTAオープンソースRMです。
📦 インストール
ライセンスはPKU-Alignment/PKU-SafeRLHF-30K
から派生しています。
ベースモデルはmeta-llama/Meta-Llama-3-8B-Instruct
です。
訓練スクリプトはhttps://github.com/WeiXiongUST/RLHF-Reward-Modeling
を使用しています。
💻 使用例
基本的な使用法
from transformers import AutoTokenizer, pipeline
rm_tokenizer = AutoTokenizer.from_pretrained("sfairXC/FsfairX-LLaMA3-RM-v0.1")
device = 0
rm_pipe = pipeline(
"sentiment-analysis",
model="sfairXC/FsfairX-LLaMA3-RM-v0.1",
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 = [rm_tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=False).replace(rm_tokenizer.bos_token, "")]
pipe_outputs = rm_pipe(test_texts, **pipe_kwargs)
rewards = [output[0]["score"] for output in pipe_outputs]
📚 ドキュメント
結果
この報酬モデルは、Reward-Benchにおける2024年4月20日時点のSOTAオープンソースRMです。
指標 |
スコア |
Chat |
99.44 |
Chat Hard |
65.13 |
Safety |
88.76 |
Reasoning |
88.3 |
参考文献
このリポジトリは、反復拒否サンプリング微調整と反復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}
}
📄 ライセンス
ライセンスはCC BY-NC 4.0です。