Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Usage
|
| 2 |
+
|
| 3 |
+
This model outputs a reward for each reasoning step evaluating it.
|
| 4 |
+
|
| 5 |
+
`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**.
|
| 6 |
+
|
| 7 |
+
Unlike the other PRM checkpoints in this release, this model is not trained from the base/instruct model with a newly added scalar reward head. Instead, it starts from the original **Qwen2.5-Math-PRM-7B** checkpoint and continues its training on PDDL2PRM data. For this reason, it follows the original Qwen PRM reward interface: reasoning steps must be separated with the `<extra_0>` marker, and rewards are obtained from the positive-class probability at marker positions.
|
| 8 |
+
|
| 9 |
+
PDDL2PRM is the dataset introduced in:
|
| 10 |
+
|
| 11 |
+
**Process Reward Models Meet Planning: Generating Precise and Scalable Datasets for Step-Level Rewards**
|
| 12 |
+
Raffaele Pisano and Roberto Navigli, ACL 2026
|
| 13 |
+
|
| 14 |
+
Project page & paper: https://babelscape.github.io/prm-meets-planning/
|
| 15 |
+
arXiv: https://arxiv.org/abs/2604.17957
|
| 16 |
+
|
| 17 |
+
The paper proposes using symbolic planning problems written in **Planning Domain Definition Language (PDDL)** to generate precise step-level rewards for reasoning trajectories. In PDDL, actions, states, preconditions, effects, and goals are explicitly defined, so intermediate reasoning steps can be evaluated automatically.
|
| 18 |
+
|
| 19 |
+
## Example
|
| 20 |
+
|
| 21 |
+
```python
|
| 22 |
+
import torch
|
| 23 |
+
import torch.nn.functional as F
|
| 24 |
+
from transformers import AutoTokenizer, AutoModel
|
| 25 |
+
|
| 26 |
+
repo_id = "Babelscape/Qwen2.5-Math-PRM-7B-PDDL-r"
|
| 27 |
+
|
| 28 |
+
tokenizer = AutoTokenizer.from_pretrained(repo_id, trust_remote_code=True)
|
| 29 |
+
model = AutoModel.from_pretrained(repo_id, trust_remote_code=True).eval()
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def build_messages(problem, steps):
|
| 33 |
+
return [
|
| 34 |
+
{
|
| 35 |
+
"role": "system",
|
| 36 |
+
"content": "Please reason step by step, and put your final answer within \\boxed{}."
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"role": "user",
|
| 40 |
+
"content": problem
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"role": "assistant",
|
| 44 |
+
"content": "<extra_0>".join(steps) + "<extra_0>"
|
| 45 |
+
}
|
| 46 |
+
]
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def get_step_rewards(logits, marker_positions):
|
| 50 |
+
probs = F.softmax(logits, dim=-1)
|
| 51 |
+
# Positive-class probability at each <extra_0> marker position
|
| 52 |
+
return probs[0, marker_positions, 1].detach().cpu().tolist()
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
problem = "If x + 3 = 10, find x."
|
| 56 |
+
steps = [
|
| 57 |
+
"Subtract 3 from both sides: x = 10 - 3.",
|
| 58 |
+
"So x = 7."
|
| 59 |
+
]
|
| 60 |
+
|
| 61 |
+
messages = build_messages(problem, steps)
|
| 62 |
+
prompt = tokenizer.apply_chat_template(
|
| 63 |
+
messages,
|
| 64 |
+
tokenize=False,
|
| 65 |
+
add_generation_prompt=False
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 69 |
+
|
| 70 |
+
with torch.no_grad():
|
| 71 |
+
outputs = model(**inputs)
|
| 72 |
+
|
| 73 |
+
logits = outputs.logits if hasattr(outputs, "logits") else outputs[0]
|
| 74 |
+
|
| 75 |
+
marker_id = tokenizer.encode("<extra_0>", add_special_tokens=False)[0]
|
| 76 |
+
marker_positions = (inputs["input_ids"][0] == marker_id).nonzero(as_tuple=True)[0]
|
| 77 |
+
|
| 78 |
+
step_scores = get_step_rewards(logits, marker_positions)
|
| 79 |
+
|
| 80 |
+
print("Step scores:", step_scores)
|
| 81 |
+
|
| 82 |
+
first_bad = next((i for i, score in enumerate(step_scores) if score < 0.5), -1)
|
| 83 |
+
print("First failing step index:", first_bad)
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
# Notes
|
| 87 |
+
|
| 88 |
+
* The marker `<extra_0>` must appear after every reasoning step.
|
| 89 |
+
* This model follows the reward format of `Qwen/Qwen2.5-Math-PRM-7B`.
|
| 90 |
+
* Rewards are computed from the positive-class probability at `<extra_0>` marker positions.
|
| 91 |
+
* A threshold such as 0.5 can be used to identify potentially incorrect steps.
|
| 92 |
+
* This differs from the PRM800K-based checkpoints with a scalar reward head, where `pred_scalar` is read at marker positions.
|
| 93 |
+
|
| 94 |
+
# Citation
|
| 95 |
+
|
| 96 |
+
If you use this model or the PDDL2PRM dataset in your work, please cite:
|
| 97 |
+
|
| 98 |
+
```bibtex
|
| 99 |
+
@inproceedings{pisano2026prmplanning,
|
| 100 |
+
title={Process Reward Models Meet Planning: Generating Precise and Scalable Datasets for Step-Level Rewards},
|
| 101 |
+
author={Pisano, Raffaele and Navigli, Roberto},
|
| 102 |
+
booktitle={Proceedings of the Annual Meeting of the Association for Computational Linguistics (ACL)},
|
| 103 |
+
year={2026},
|
| 104 |
+
note={Accepted}
|
| 105 |
+
}
|
| 106 |
+
```
|