Update README.md
Browse files
README.md
CHANGED
|
@@ -6,4 +6,71 @@ language:
|
|
| 6 |
- en
|
| 7 |
base_model:
|
| 8 |
- Qwen/Qwen2.5-7B-Instruct
|
| 9 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
- en
|
| 7 |
base_model:
|
| 8 |
- Qwen/Qwen2.5-7B-Instruct
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# PairJudge RM
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
**PairJudge RM** is a pairwise judge reward model designed to enhance Best-of-N sampling for mathematical reasoning tasks. Instead of assigning arbitrary absolute scores to candidate solutions, PairJudge RM compares them in pairs using chain-of-thought (CoT) reasoning and selects the best answer via a knockout tournament strategy.
|
| 15 |
+
|
| 16 |
+
- Paper: https://arxiv.org/abs/2501.13007
|
| 17 |
+
- Code: https://github.com/THU-KEG/PairJudgeRM
|
| 18 |
+
- Dataset: https://huggingface.co/datasets/THU-KEG/PairJudge-432K
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
## Overview
|
| 22 |
+
|
| 23 |
+
- **Pairwise Judgment:** Evaluates two candidate solutions simultaneously to determine which is more correct.
|
| 24 |
+
- **Chain-of-Thought Reasoning:** Leverages CoT to transparently verify each step of the candidate solutions.
|
| 25 |
+
|
| 26 |
+
## Model Architecture & Training
|
| 27 |
+
|
| 28 |
+
PairJudge RM is built by fine-tuning a pre-trained language model (e.g., Qwen-2.5-7B-Instruct) on the PAIRJUDGE-432K dataset. Key training details include:
|
| 29 |
+
|
| 30 |
+
- **Optimizer:** Adam
|
| 31 |
+
- **Learning Rate:** 1×10⁻⁵
|
| 32 |
+
- **Batch Size:** 128
|
| 33 |
+
- **Epochs:** 8
|
| 34 |
+
|
| 35 |
+
## Usage
|
| 36 |
+
|
| 37 |
+
Below is an example of how to use PairJudge RM for evaluating candidate solutions:
|
| 38 |
+
|
| 39 |
+
```python
|
| 40 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 41 |
+
|
| 42 |
+
# template file is avaliable in [https://github.com/THU-KEG/PairwiseRM/blob/main/prompt/compare_0_ex.md]
|
| 43 |
+
TEMPLATE = open("prompts/compare_0_ex.md", "r").read()
|
| 44 |
+
|
| 45 |
+
# Load the tokenizer and model from Hugging Face
|
| 46 |
+
tokenizer = AutoTokenizer.from_pretrained("THU-KEG/PairJudgeRM")
|
| 47 |
+
model = AutoModelForCausalLM.from_pretrained("THU-KEG/PairJudgeRM")
|
| 48 |
+
|
| 49 |
+
# Example math problem and candidate solutions
|
| 50 |
+
question = "If one equilateral triangle in a regular hexagon has a perimeter of 21 inches, what is the hexagon’s perimeter?"
|
| 51 |
+
response_a = "Each side is 7 inches; hexagon perimeter is 42 inches."
|
| 52 |
+
response_b = "The triangle's perimeter is 21 inches; hexagon perimeter is 126 inches."
|
| 53 |
+
|
| 54 |
+
# Construct the input prompt for pairwise judgment
|
| 55 |
+
input_text = template.format(question=question, response_a=response_a, response_b=response_b)
|
| 56 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
| 57 |
+
|
| 58 |
+
# Generate the judgment with a chain-of-thought explanation
|
| 59 |
+
outputs = model.generate(**inputs, max_new_tokens=2048)
|
| 60 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
## Citation
|
| 65 |
+
If you find our work useful, please consider citing our paper:
|
| 66 |
+
|
| 67 |
+
```
|
| 68 |
+
@article{liu2025PairJudge,
|
| 69 |
+
title={PairJudge RM: Perform Best-of-N Sampling with Knockout Tournament},
|
| 70 |
+
author={Liu, Yantao and Yao, Zijun and Min, Rui and Cao, Yixin and Hou, Lei and Li, Juanzi},
|
| 71 |
+
journal={arXiv preprint arXiv:2501.13007},
|
| 72 |
+
year={2025},
|
| 73 |
+
note={in progress work},
|
| 74 |
+
url={https://doi.org/10.48550/arXiv.2501.13007}
|
| 75 |
+
}
|
| 76 |
+
```
|