模型概述
模型特點
模型能力
使用案例
🚀 Skywork獎勵模型系列
Skywork獎勵模型系列包含兩款先進的獎勵模型,分別基於特定架構構建,能有效處理複雜場景下的偏好問題,在RewardBench排行榜上成績優異。
🚀 快速開始
本部分將引導你快速瞭解Skywork獎勵模型系列的基本情況。
✨ 主要特性
- 高性能表現:Skywork-Reward-Gemma-2-27B和Skywork-Reward-Llama-3.1-8B分別基於gemma-2-27b-it和Meta-Llama-3.1-8B-Instruct架構構建。截至2024年9月,它們在RewardBench排行榜上分別位居第一和第三。
- 優質數據驅動:使用僅包含80K高質量偏好對的Skywork獎勵數據集合進行訓練,這些數據均來自公開可用的數據。
- 多領域適用:能夠處理複雜場景下的偏好問題,涵蓋數學、編碼和安全等多個領域。
📦 安裝指南
文檔未提供安裝步驟,暫不展示。
💻 使用示例
基礎用法
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
# Load model and tokenizer
device = "cuda:0"
model_name = "Skywork/Skywork-Reward-Llama-3.1-8B"
rm = AutoModelForSequenceClassification.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map=device,
attn_implementation="flash_attention_2",
num_labels=1,
)
rm_tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "Jane has 12 apples. She gives 4 apples to her friend Mark, then buys 1 more apple, and finally splits all her apples equally among herself and her 2 siblings. How many apples does each person get?"
response1 = "1. Jane starts with 12 apples and gives 4 to Mark. 12 - 4 = 8. Jane now has 8 apples.\n2. Jane buys 1 more apple. 8 + 1 = 9. Jane now has 9 apples.\n3. Jane splits the 9 apples equally among herself and her 2 siblings (3 people in total). 9 ÷ 3 = 3 apples each. Each person gets 3 apples."
response2 = "1. Jane starts with 12 apples and gives 4 to Mark. 12 - 4 = 8. Jane now has 8 apples.\n2. Jane buys 1 more apple. 8 + 1 = 9. Jane now has 9 apples.\n3. Jane splits the 9 apples equally among her 2 siblings (2 people in total). 9 ÷ 2 = 4.5 apples each. Each person gets 4 apples."
conv1 = [{"role": "user", "content": prompt}, {"role": "assistant", "content": response1}]
conv2 = [{"role": "user", "content": prompt}, {"role": "assistant", "content": response2}]
# Format and tokenize the conversations
conv1_formatted = rm_tokenizer.apply_chat_template(conv1, tokenize=False)
conv2_formatted = rm_tokenizer.apply_chat_template(conv2, tokenize=False)
conv1_tokenized = rm_tokenizer(conv1_formatted, return_tensors="pt").to(device)
conv2_tokenized = rm_tokenizer(conv2_formatted, return_tensors="pt").to(device)
# Get the reward scores
with torch.no_grad():
score1 = rm(**conv1_tokenized).logits[0][0].item()
score2 = rm(**conv2_tokenized).logits[0][0].item()
print(f"Score for response 1: {score1}")
print(f"Score for response 2: {score2}")
# Output:
# Score for response 1: 12.625
# Score for response 2: -15.25
高級用法
文檔未提供高級用法代碼,暫不展示。
📚 詳細文檔
數據混合
我們沒有依賴現有的大型偏好數據集,而是精心策劃了Skywork獎勵數據集合,目的是(1)包含高質量的偏好對;(2)針對特定的能力和知識領域。經過策劃的訓練數據集大約包含80K個樣本,這些樣本是從多個公開可用的數據源中二次採樣得到的,包括:
- HelpSteer2
- OffsetBias
- WildGuard (對抗性)
- Magpie DPO系列:Ultra、Pro (Llama-3.1)、Pro、Air。
聲明:除了對上述原始數據集進行二次採樣以創建Skywork獎勵數據集合外,我們沒有對其進行任何修改。
在數據集策劃過程中,我們採用了一些技巧,以在不影響整體性能的前提下,實現性能提升和各領域之間的平衡:
- 我們根據數據集中提供的平均ArmoRM分數,分別從合併後的Magpie數據集中的數學、代碼和其他類別中選擇頂級樣本。我們將Magpie-Air子集和Magpie-Pro子集中的ArmoRM平均分數分別減去0.1和0.05,以優先選擇Magpie-Ultra和Magpie-Pro-Llama-3.1樣本。
- 我們沒有將WildGuard中的所有偏好對都包含在內,而是首先在其他三個數據源上訓練了一個獎勵模型(RM)。然後,(1)使用這個RM對WildGuard中所有樣本的選擇響應和拒絕響應進行評分;(2)僅選擇選擇響應的RM分數大於拒絕響應的RM分數的樣本。我們觀察到,這種方法在提高安全性的同時,在很大程度上保留了聊天、困難聊天和推理的原始性能。對於這兩個模型,我們使用27B模型對WildGuard樣本進行評分。
RewardBench排行榜
我們使用官方測試腳本在RewardBench上對我們的模型進行了評估。截至2024年9月,Skywork-Reward-Gemma-2-27B和Skywork-Reward-Llama-3.1-8B在RewardBench排行榜上分別排名第一和第三。
排名 | 模型 | 聊天 | 困難聊天 | 安全 | 推理 | 分數 |
---|---|---|---|---|---|---|
1 | Skywork-Reward-Gemma-2-27B | 95.8 | 91.4 | 92.0 | 96.1 | 93.8 |
2 | SFR-LLaMa-3.1-70B-Judge-r | 96.9 | 84.8 | 92.2 | 97.6 | 92.8 |
3 | Skywork-Reward-Llama-3.1-8B | 95.8 | 87.3 | 90.6 | 96.2 | 92.5 |
4 | Nemotron-4-340B-Reward | 95.8 | 87.1 | 92.2 | 93.6 | 92.2 |
5 | ArmoRM-Llama3-8B-v0.1 | 96.9 | 76.8 | 92.2 | 97.3 | 90.8 |
6 | SFR-nemo-12B-Judge-r | 97.2 | 82.2 | 87.5 | 95.1 | 90.5 |
7 | internlm2-20b-reward | 98.9 | 76.5 | 89.9 | 95.8 | 90.3 |
聲明與許可協議
聲明
我們在此聲明,Skywork模型不得用於任何危害國家或社會安全的活動,或從事非法行為。此外,我們要求用戶在未進行適當的安全審查和記錄的情況下,不要將Skywork模型部署到互聯網服務中。我們希望所有用戶都能遵守這一原則,以確保技術進步在規範和合法的環境中進行。
我們已盡最大努力確保模型訓練過程中使用的數據的合規性。然而,儘管我們付出了巨大努力,但由於模型和數據的複雜性,仍可能存在不可預測的風險和問題。因此,如果因使用Skywork開源模型而出現任何問題,包括但不限於數據安全問題、輿論風險,或因模型被誤導、濫用、傳播或不當使用而產生的任何風險和問題,我們將不承擔任何責任。
許可協議
Skywork模型的社區使用需要遵循Skywork社區許可協議。Skywork模型支持商業使用。如果您計劃將Skywork模型或其衍生產品用於商業目的,則必須遵守Skywork社區許可協議中的條款和條件。
技術報告
Skywork-Reward: Bag of Tricks for Reward Modeling in LLMs
聯繫我們
如果您有任何問題,請隨時通過yuhao.liuu@kunlun-inc.com或liang.zeng@kunlun-inc.com與我們聯繫。
引用
如果您認為我們的工作有幫助,請使用以下BibTeX條目引用我們:
@article{liu2024skywork,
title={Skywork-Reward: Bag of Tricks for Reward Modeling in LLMs},
author={Liu, Chris Yuhao and Zeng, Liang and Liu, Jiacai and Yan, Rui and He, Jujie and Wang, Chaojie and Yan, Shuicheng and Liu, Yang and Zhou, Yahui},
journal={arXiv preprint arXiv:2410.18451},
year={2024}
}
🔧 技術細節
文檔未提供技術實現細節,暫不展示。
📄 許可證
Skywork模型的社區使用需要遵循Skywork社區許可協議。Skywork模型支持商業使用。如果您計劃將Skywork模型或其衍生產品用於商業目的,則必須遵守Skywork社區許可協議中的條款和條件。
⚠️ 重要提示
我們移除了兩個模型聊天模板中的BOS標記,以防止在
apply_chat_template
和分詞過程中重複添加。因此,請不要依賴apply_chat_template
來添加BOS標記。
💡 使用建議
為了使27B獎勵模型達到最佳性能,請確保您啟用了
flash_attention_2
或eager
實現。默認的spda
實現可能會導致錯誤,從而顯著降低該模型的性能。



