---
pipeline_tag: 文本分类
license: 其他
language:
- 英文
- 中文
tags:
- 奖励模型
---
# 书生·浦语
<div align="center">
<img src="https://github.com/InternLM/InternLM/assets/22529082/b9788105-8892-4398-8b47-b513a292378e" width="200"/>
<div> </div>
<div align="center">
<b><font size="5">InternLM2-1.8B-Reward</font></b>
</div>
[💻GitHub仓库](https://github.com/InternLM/InternLM) • [🤔问题反馈](https://github.com/InternLM/InternLM/issues/new) • [📜技术报告](https://arxiv.org/abs/2403.17297)
</div>
<p align="center">
👋 加入我们的<a href="https://discord.gg/xa29JuW87d" target="_blank">Discord</a>和<a href="https://github.com/InternLM/InternLM/assets/25839884/a6aad896-7232-4220-ac84-9e070c2633ce" target="_blank">微信群</a>
</p>
## 模型介绍
**InternLM2-1.8B-Reward**是基于InternLM2-Chat-1.8B-SFT训练的奖励模型。该模型使用超过240万条人工标注和AI合成的偏好样本进行训练,在保持实用性与安全性平衡的同时展现出卓越性能。
### 核心特性:
- **多尺寸可选**:我们开源了**1.8B、7B和20B**三种规格的奖励模型,各规格模型在不同指标上均表现优异。这些不同尺寸的模型旨在推动奖励模型缩放定律的研究。
- **全面的偏好覆盖**:训练使用了**240万**条涵盖对话、写作、诗歌、摘要、编程、数学等领域的偏好数据,同时兼顾了实用性与安全性的平衡。
- **双语支持**:基于高质量**中英文**偏好数据训练,在两种语言上均表现稳健。
该模型已应用于InternLM2-Chat的RLHF训练过程。[技术报告](https://arxiv.org/abs/2403.17297)中的奖励模型训练技术已在XTuner中开源,立即[体验](https://github.com/InternLM/xtuner)!
## RewardBench性能评估
| 模型 | 总分 | 对话 | 困难对话 | 安全性 | 推理 |
| --- | --- | --- | --- | --- | --- |
| InternLM2-20B-Reward | 89.5 | 98.6 | 74.1 | 89.4 | 95.7 |
| InternLM2-7B-Reward | 86.6 | 98.6 | 66.7 | 88.3 | 92.8 |
| InternLM2-1.8B-Reward | 80.6 | 95.0 | 58.1 | 81.8 | 87.4 |
- 评估基于[RewardBench](https://github.com/allenai/reward-bench)数据集
- 为公平比较,测试时未使用技术报告提出的条件系统提示
## 演示代码
### 基础用法
我们提供了易用的API接口:
```python
# 获取单条对话得分
score = model.get_score(tokenizer, chat)
# 批量获取分数
scores = model.get_scores(tokenizer, [chat1, chat2])
# 比较对话优劣
is_better = model.compare(tokenizer, chat1, chat2)
# 对话排序(返回排名索引)
rank_indices = model.rank(tokenizer, [chat1, chat2, chat3])
最优N选1采样
candidates = [llm.generate(prompt) for _ in range(10)]
best_response = max(candidates, key=lambda x: model.get_score(x))
开源许可
代码遵循Apache-2.0协议,模型权重完全开放学术研究并允许免费商用(需填写申请表)。商业合作请联系internlm@pjlab.org.cn。
引用文献
@misc{cai2024internlm2,
title={InternLM2技术报告},
author={蔡峥等},
year={2024},
journal={arXiv预印本},
doi={10.48550/arXiv.2403.17297}
}