license: other
language:
- en
- zh
tags:
- reward model
pipeline_tag: any-to-any
library_name: transformers
InternLM-XComposer-2.5-Reward
简介
InternLM-XComposer2.5-Reward 是基于 internlm/internlm-xcomposer2d5-7b 训练的多模态奖励模型。该模型通过文本、图像和视频领域的偏好样本进行训练,能够给出符合人类偏好的奖励分数。
性能评估
-
在 VLRewardBench 上的表现
模型 |
通用性 |
幻觉 |
推理 |
综合 |
宏观平均 |
InternLM-XComposer2.5-7B-Reward |
84.7 |
62.5 |
62.9 |
65.8 |
70.0 |
-
在 RewardBench 上的表现
| 模型 | 总分 | 对话 | 困难对话 | 安全性 | 推理 |
| --- | --- | --- | --- | --- | --- |
| InternLM-XComposer2.5-7B-Reward | 88.6 | 90.8 | 83.8 | 87.8 | 90.0 |
-
在 RM-Bench 上的表现
| 模型 | 对话 | 数学 | 代码 | 安全性 | 简单 | 中等 | 困难 | 平均 |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| InternLM-XComposer2.5-7B-Reward | 65.5 | 55.9 | 51.7 | 93.8 | 87.5 | 71.3 | 47.4 | 68.8 |
基础用法
以下示例展示了如何使用该模型获取对话的奖励分数、比较两个对话或对多个对话进行排序。
import torch
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained(
"internlm/internlm-xcomposer2d5-7b-reward",
device_map="cuda",
torch_dtype=torch.float16,
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained("internlm/internlm-xcomposer2d5-7b-reward", trust_remote_code=True)
model.tokenizer = tokenizer
chat_1 = [
{"role": "user", "content": '我想根据输入图片购买一辆车,分析其优缺点。'},
{"role": "assistant", "content": "图片中的车是奔驰G级。这是一款以坚固耐用、越野能力和标志性方正设计闻名的豪华SUV。以下是其优缺点分析:优点:越野能力:G级采用坚固的梯形车架底盘和强劲发动机,越野性能出色。配备低速分动箱、差速锁和高离地间隙。豪华舒适:尽管外观硬朗,G级内饰豪华,采用高品质材料,座椅舒适,配备先进科技功能。标志性设计:G级独特的方正造型使其成为经典,辨识度高且历久弥新。保值率高:由于其稀缺性和受欢迎程度,G级通常保值率较高。缺点:燃油效率:G级不以燃油效率见长,尤其是大排量发动机版本。行驶质感:为越野性能设计的硬悬架在铺装路面可能略显颠簸。价格:即使作为豪华SUV,G级价格也非常昂贵。尺寸与操控:G级的大尺寸在狭小空间停车和操控时可能带来挑战。"}
]
chat_2 = [
{"role": "user", "content": '我想根据输入图片购买一辆车,分析其优缺点。'},
{"role": "assistant", "content": "根据图片显示,这似乎是法拉利F8 Tributo。优点:性能:法拉利以卓越性能著称。F8 Tributo搭载强劲的双涡轮增压V8发动机,加速和极速表现令人振奋。操控:法拉利以精准操控和敏捷性闻名。F8 Tributo延续这一传统,先进空气动力学和复杂悬架系统确保激动人心的驾驶体验。设计:法拉利是标志性设计的代名词。F8 Tributo线条流畅,造型激进,极具视觉冲击力。独特性:拥有法拉利是身份象征,代表奢华、独特和对高性能汽车的热情。缺点:价格:法拉利价格昂贵。F8 Tributo也不例外,需要雄厚的财力支持。燃油效率:F8 Tributo这类高性能跑车不以燃油效率见长,油耗高于普通车辆。维护成本:法拉利的维护费用高于常规车型。实用性:F8 Tributo主要是双座跑车,日常使用或载客不太实用。驾乘舒适性:虽然F8 Tributo提供激动人心的驾驶体验,但其硬悬架可能不适合长途舒适驾驶。"}
]
image = ['./examples/cars1.jpg']
hd_num = 9
with torch.autocast(device_type='cuda', dtype=torch.float16):
score1 = model.get_score(chat_1, image, hd_num=hd_num)
score2 = model.get_score(chat_2, image, hd_num=hd_num)
print("score1: ", score1)
print("score2: ", score2)
with torch.autocast(device_type='cuda', dtype=torch.float16):
scores = model.get_scores([chat_1, chat_2], [image, image], hd_num=hd_num)
print("scores: ", scores)
with torch.autocast(device_type='cuda', dtype=torch.float16):
compare_res = model.compare(chat_1, image, chat_2, image, hd_num=hd_num)
print("compare_res: ", compare_res)
with torch.autocast(device_type='cuda', dtype=torch.float16):
rank_res = model.rank([chat_1, chat_2], [image, image], hd_num=hd_num)
print("rank_res: ", rank_res)
开源许可
代码采用Apache-2.0许可证,模型权重完全开放用于学术研究,并允许免费商业使用。如需申请商业许可证,请填写申请表(英文/中文)。其他问题或合作请联系 internlm@pjlab.org.cn。