Views
No views yet
Babelscape/Qwen2.5-Math-PRM-7B-PDDL-r is a Process Reward Model (PRM) obtained by continual fine-tuning from Qwen/Qwen2.5-Math-PRM-7B with the planning-based supervision introduced in PDDL2PRM.<extra_0> marker, and rewards are obtained from the positive-class probability at marker positions.1import torch
2import torch.nn.functional as F
3from transformers import AutoTokenizer, AutoModel
4
5repo_id = "Babelscape/Qwen2.5-Math-PRM-7B-PDDL-r"
6
7tokenizer = AutoTokenizer.from_pretrained(repo_id, trust_remote_code=True)
8model = AutoModel.from_pretrained(repo_id, trust_remote_code=True).eval()
9
10
11def build_messages(problem, steps):
12 return [
13 {
14 "role": "system",
15 "content": "Please reason step by step, and put your final answer within \\boxed{}."
16 },
17 {
18 "role": "user",
19 "content": problem
20 },
21 {
22 "role": "assistant",
23 "content": "<extra_0>".join(steps) + "<extra_0>"
24 }
25 ]
26
27
28def get_step_rewards(logits, marker_positions):
29 probs = F.softmax(logits, dim=-1)
30 # Positive-class probability at each <extra_0> marker position
31 return probs[0, marker_positions, 1].detach().cpu().tolist()
32
33
34problem = "If x + 3 = 10, find x."
35steps = [
36 "Subtract 3 from both sides: x = 10 - 3.",
37 "So x = 7."
38]
39
40messages = build_messages(problem, steps)
41prompt = tokenizer.apply_chat_template(
42 messages,
43 tokenize=False,
44 add_generation_prompt=False
45)
46
47inputs = tokenizer(prompt, return_tensors="pt")
48
49with torch.no_grad():
50 outputs = model(**inputs)
51
52logits = outputs.logits if hasattr(outputs, "logits") else outputs[0]
53
54marker_id = tokenizer.encode("<extra_0>", add_special_tokens=False)[0]
55marker_positions = (inputs["input_ids"][0] == marker_id).nonzero(as_tuple=True)[0]
56
57step_scores = get_step_rewards(logits, marker_positions)
58
59print("Step scores:", step_scores)
60
61first_bad = next((i for i, score in enumerate(step_scores) if score < 0.5), -1)
62print("First failing step index:", first_bad)<extra_0> must appear after every reasoning step.Qwen/Qwen2.5-Math-PRM-7B.<extra_0> marker positions.pred_scalar is read at marker positions.1@inproceedings{pisano2026prmplanning,
2 title={Process Reward Models Meet Planning: Generating Precise and Scalable Datasets for Step-Level Rewards},
3 author={Pisano, Raffaele and Navigli, Roberto},
4 booktitle={Proceedings of the Annual Meeting of the Association for Computational Linguistics (ACL)},
5 year={2026},
6 note={Accepted}
7}