PURE PRM 7B
これはQwen2.5-Math-7Bでトレーニングされたプロセス報酬モデルで、数学的推論能力を向上させるために使用されます
ダウンロード数 18
リリース時間 : 2/9/2025
モデル概要
このモデルはPRM800KデータセットでQwen2.5-Math-7Bをファインチューニングして取得され、主に数学的推論プロセスと中間ステップの品質を評価するために使用されます
モデル特徴
プロセス評価能力
最終結果ではなく、推論プロセスと中間ステップの品質評価に焦点を当てています
数学的推論最適化
数学的推論タスクに特化して最適化され、推論ステップの正確性を向上させます
ステップ分離評価
ダブル改行で解決策のステップを分離し、各ステップを独立して評価することをサポートします
モデル能力
数学的推論評価
プロセス報酬計算
ステップ品質分析
使用事例
数学教育
数学問題解決ステップ評価
学生の解答プロセスにおける各ステップの正確性を評価します
各ステップの報酬スコアを提供し、誤ったステップを特定するのに役立ちます
AIトレーニング
強化学習報酬モデル
強化学習における報酬モデルとして、AIの数学的推論能力の改善を指導します
AIモデルの数学的推論の正確性を向上させます
🚀 Qwen2.5-Math-7BをベースとしたPUREのPRM
このPRMは、大規模言語モデル(LLM)を微調整し、数学的推論能力を向上させるために使用されます。 詳細については、PUREのGitHubリポジトリを参照してください。これは、オープンソースデータセットPRM800KのトレーニングセットでQwen2.5-Math-7Bを微調整することで得られます。ベースモデルをベースラインと一致させるため、Qwen2.5-Math-7B-InstructではなくQwen2.5-Math-7Bを選択しました。 PRM800Kの元の1と0のラベルを正のラベルとして扱い、-1を負のラベルとして扱います。テストデータの汚染を排除するため、MATHテストセットと同じ数学的クエリを持つPRM800Kのトレーニングサンプルも削除しています。
🚀 クイックスタート
⚠️ 重要な注意
PUREのPRMは、通常、生成ではなく推論と中間ステップの品質に関するフィードバックを提供するために使用されるプロセス報酬モデルです。
前提条件
- ステップ分離: 解決策内の個々のステップを区切るために、二重改行("\n\n")の使用を推奨します。
- 報酬計算: 各ステップの後に、トークン "
\n
" を挿入します。報酬計算では、このトークンの確率スコアを抽出し、正の確率から負の確率を引き、-1から1の間の報酬値を得ます。報酬 > 0のステップを正しいと見なし、それ以外を誤りと見なします。
🤗 Hugging Face Transformers
- 以下に、
transformers
を使用してPRMを使う方法のコードスニペットを示します。
import torch
from transformers import AutoModelForTokenClassification, AutoTokenizer
def make_step_rewards(logits, token_masks):
all_scores_res = []
for sample, token_mask in zip(logits, token_masks):
# sample: (seq_len, num_labels)
probs = sample[token_mask].softmax(dim=-1) # (num_steps, 2)
process_reward = probs[:, 1] - probs[:, 0] # (num_steps,)
# weighted sum to approx. min, highly recommend when BoN eval and Fine-tuning LLM
# weight = torch.softmax(
# -process_reward / 0.1,
# dim=-1,
# )
# process_reward = weight * process_reward
all_scores_res.append(process_reward.cpu().tolist())
return all_scores_res
model_name = "jinachris/PURE-PRM-7B"
device = "auto"
tokenizer = AutoTokenizer.from_pretrained(
model_name,
trust_remote_code=True,
)
model = AutoModelForTokenClassification.from_pretrained(
model_name,
device_map=device,
torch_dtype=torch.bfloat16,
trust_remote_code=True,
).eval()
question = "Sue lives in a fun neighborhood. One weekend, the neighbors decided to play a prank on Sue. On Friday morning, the neighbors placed 18 pink plastic flamingos out on Sue's front yard. On Saturday morning, the neighbors took back one third of the flamingos, painted them white, and put these newly painted white flamingos back out on Sue's front yard. Then, on Sunday morning, they added another 18 pink plastic flamingos to the collection. At noon on Sunday, how many more pink plastic flamingos were out than white plastic flamingos?"
steps = [
"To find out how many more pink plastic flamingos were out than white plastic flamingos at noon on Sunday, we can break down the problem into steps. First, on Friday, the neighbors start with 18 pink plastic flamingos.",
"On Saturday, they take back one third of the flamingos. Since there were 18 flamingos, (1/3 \\times 18 = 6) flamingos are taken back. So, they have (18 - 6 = 12) flamingos left in their possession. Then, they paint these 6 flamingos white and put them back out on Sue's front yard. Now, Sue has the original 12 pink flamingos plus the 6 new white ones. Thus, by the end of Saturday, Sue has (12 + 6 = 18) pink flamingos and 6 white flamingos.",
"On Sunday, the neighbors add another 18 pink plastic flamingos to Sue's front yard. By the end of Sunday morning, Sue has (18 + 18 = 36) pink flamingos and still 6 white flamingos.",
"To find the difference, subtract the number of white flamingos from the number of pink flamingos: (36 - 6 = 30). Therefore, at noon on Sunday, there were 30 more pink plastic flamingos out than white plastic flamingos. The answer is (\\boxed{30})."
]
step_separator = "\n"
step_separator_token = tokenizer(
step_separator,
add_special_tokens=False,
return_tensors='pt',
)['input_ids']
input_ids = tokenizer(
question,
add_special_tokens=False,
return_tensors='pt',
)['input_ids']
score_ids = []
for step in steps:
step_ids = tokenizer(
step,
add_special_tokens=False,
return_tensors='pt',
)['input_ids']
input_ids = torch.cat(
[input_ids, step_ids, step_separator_token],
dim=-1,
)
score_ids.append(input_ids.size(-1) - 1)
input_ids = input_ids.to(model.device)
token_masks = torch.zeros_like(input_ids, dtype=torch.bool)
token_masks[0, score_ids] = True
assert torch.all(input_ids[token_masks].to("cpu") == step_separator_token)
logits = model(input_ids).logits
step_reward = make_step_rewards(logits, token_masks)
print(step_reward) # [[0.796875, 0.185546875, -0.0625, 0.078125]]
# For BoN eval,
# uncomment the weighted sum part in `make_step_rewards` func,
# then sum the rewards to get the final score (outcome reward):
# torch.tensor(step_reward).sum(dim=-1)
- さらに、RLHFlowのデータに対するBoN評価のコードを共有します。
import numpy as np
import torch
from datasets import load_dataset
from tqdm import tqdm
from transformers import AutoModelForTokenClassification, AutoTokenizer
ds_names = ["GSM8K", "MATH500"]
ds = [
load_dataset(
f"RLHFlow/Deepseek-{ds_name}-Test"
)['test'] for ds_name in ds_names
]
def make_step_rewards(logits, token_masks):
all_scores_res = []
for sample, token_mask in zip(logits, token_masks):
# sample: (seq_len, num_labels)
probs = sample[token_mask].softmax(dim=-1) # (num_steps, 2)
process_reward = probs[:, 1] - probs[:, 0] # (num_steps,)
# weighted sum to approx. min, highly recommend when BoN eval and Fine-tuning LLM
weight = torch.softmax(
-process_reward / 0.1,
dim=-1,
)
process_reward = weight * process_reward
all_scores_res.append(process_reward.cpu().tolist())
return all_scores_res
model_name = "jinachris/PURE-PRM-7B"
device = "auto"
tokenizer = AutoTokenizer.from_pretrained(
model_name,
trust_remote_code=True,
)
model = AutoModelForTokenClassification.from_pretrained(
model_name,
device_map=device,
torch_dtype=torch.bfloat16,
trust_remote_code=True,
).eval()
step_separator = "\n"
step_separator_token = tokenizer(
step_separator,
add_special_tokens=False,
return_tensors='pt',
)['input_ids']
for ds_item, ds_name in zip(ds, ds_names):
# sampled_ids = np.random.choice(range(len(ds_item)), size=100, replace=False)
correct = 0
total = 0
for idx in tqdm(range(len(ds_item)), desc=f"Processing questions in {ds_name}"):
question = ds_item['prompt'][idx]
answers = ds_item['answers'][idx]
labels = ds_item['label'][idx]
outcome_scores = []
question_ids = tokenizer(
question,
add_special_tokens=False,
return_tensors='pt',
)['input_ids']
for answer in tqdm(answers, desc="Processing answers"):
steps = [i.rstrip() for i in answer.split("\n\n")]
input_ids = question_ids.clone()
score_ids = []
for step in steps:
step_ids = tokenizer(
step,
add_special_tokens=False,
return_tensors='pt',
)['input_ids']
input_ids = torch.cat(
[input_ids, step_ids, step_separator_token],
dim=-1,
)
score_ids.append(input_ids.size(-1) - 1)
input_ids = input_ids.to(model.device, dtype=torch.long)
token_masks = torch.zeros_like(input_ids, dtype=torch.bool)
token_masks[0, score_ids] = True
assert torch.all(input_ids[token_masks].to("cpu") == step_separator_token)
with torch.no_grad():
logits = model(input_ids).logits
step_reward = make_step_rewards(logits, token_masks)
outcome_reward = torch.tensor(step_reward).sum(dim=-1)
# TODO: batch input & output
outcome_scores.append(outcome_reward.item())
best_idx = np.argmax(outcome_scores)
if labels[best_idx] == 1:
correct += 1
total += 1
print(f"Accuracy on {ds_name}: {correct / total}")
📚 詳細情報
必要条件
- Qwen2.5-Mathモデルには
transformers>=4.40.0
が必要です。最新バージョンの使用を推奨します。
注意事項
⚠️ 重要提示
このリポジトリは、QwenのPRM とは異なります。私たちは Qwen2.5-Math-7B をベースにPRMをトレーニングしていますが、QwenのPRMは Qwen2.5-Math-7B-Instruct をベースにしています。
引用
もし私たちの研究が役に立った場合は、以下のように引用していただけると幸いです。
@article{cheng2025stop,
title={Stop Summation: Min-Form Credit Assignment Is All Process Reward Model Needs for Reasoning},
author={Cheng, Jie and Qiao, Ruixi and Li, Lijun and Guo, Chao and Wang, Junle and Xiong, Gang and Lv, Yisheng and Wang, Fei-Yue},
journal={arXiv preprint arXiv:2504.15275},
year={2025}
}
📄 ライセンス
このプロジェクトは、Apache-2.0ライセンスの下でライセンスされています。
Phi 2 GGUF
その他
Phi-2はマイクロソフトが開発した小型ながら強力な言語モデルで、27億のパラメータを持ち、効率的な推論と高品質なテキスト生成に特化しています。
大規模言語モデル 複数言語対応
P
TheBloke
41.5M
205
Roberta Large
MIT
マスク言語モデリングの目標で事前学習された大型英語言語モデルで、改良されたBERTの学習方法を採用しています。
大規模言語モデル 英語
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERTはBERT基礎モデルの蒸留バージョンで、同等の性能を維持しながら、より軽量で高効率です。シーケンス分類、タグ分類などの自然言語処理タスクに適しています。
大規模言語モデル 英語
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instructは多言語大規模言語モデルで、多言語対話ユースケースに最適化されており、一般的な業界ベンチマークで優れた性能を発揮します。
大規模言語モデル 英語
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM - RoBERTaは、100言語の2.5TBのフィルタリングされたCommonCrawlデータを使って事前学習された多言語モデルで、マスク言語モデリングの目標で学習されています。
大規模言語モデル 複数言語対応
X
FacebookAI
9.6M
664
Roberta Base
MIT
Transformerアーキテクチャに基づく英語の事前学習モデルで、マスク言語モデリングの目標を通じて大量のテキストでトレーニングされ、テキスト特徴抽出と下流タスクの微調整をサポートします。
大規模言語モデル 英語
R
FacebookAI
9.3M
488
Opt 125m
その他
OPTはMeta AIが公開したオープンプリトレーニングトランスフォーマー言語モデルスイートで、パラメータ数は1.25億から1750億まであり、GPT-3シリーズの性能に対抗することを目指しつつ、大規模言語モデルのオープンな研究を促進するものです。
大規模言語モデル 英語
O
facebook
6.3M
198
1
transformersライブラリに基づく事前学習モデルで、様々なNLPタスクに適用可能
大規模言語モデル
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1はMetaが発表した多言語大規模言語モデルシリーズで、8B、70B、405Bのパラメータ規模を持ち、8種類の言語とコード生成をサポートし、多言語対話シーンを最適化しています。
大規模言語モデル
Transformers 複数言語対応

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5ベーシック版はGoogleによって開発されたテキスト-to-テキスト変換Transformerモデルで、パラメータ規模は2.2億で、多言語NLPタスクをサポートしています。
大規模言語モデル 複数言語対応
T
google-t5
5.4M
702
おすすめAIモデル
Llama 3 Typhoon V1.5x 8b Instruct
タイ語専用に設計された80億パラメータの命令モデルで、GPT-3.5-turboに匹敵する性能を持ち、アプリケーションシナリオ、検索拡張生成、制限付き生成、推論タスクを最適化
大規模言語モデル
Transformers 複数言語対応

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-TinyはSODAデータセットでトレーニングされた超小型対話モデルで、エッジデバイス推論向けに設計されており、体積はCosmo-3Bモデルの約2%です。
対話システム
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
RoBERTaアーキテクチャに基づく中国語抽出型QAモデルで、与えられたテキストから回答を抽出するタスクに適しています。
質問応答システム 中国語
R
uer
2,694
98