Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
# Qwen2.5-Math-RM-72B
|
4 |
+
|
5 |
+
## Introduction
|
6 |
+
|
7 |
+
Over the past year, we have dedicated significant effort to researching and enhancing the reasoning capabilities of large language models, with a particular focus on their ability to solve arithmetic and mathematical problems. We introduce a serise of math-specific large language models of our Qwen2.5 series, Qwen2.5-Math, Qwen2.5-Math-Instruct-1.5B/7B/72B and Qwen2.5-Math-RM-72B. Qwen2.5-Math is a series of specialized math language models built upon the Qwen2.5 LLMs, which significantly outperforms the mathematical capabilities of open-source models and even closed-source models (e.g., GPT4o). We hope that Qwen2.5-Math can contribute to the scientific community for solving advanced mathematical problems that require complex, multi-step logical reasoning.
|
8 |
+
|
9 |
+
|
10 |
+
## Model Details
|
11 |
+
|
12 |
+
|
13 |
+
For more details, please refer to our [blog post](https://qwenlm.github.io/blog/qwen2-math/) and [GitHub repo](https://github.com/QwenLM/Qwen2-Math).
|
14 |
+
|
15 |
+
|
16 |
+
## Requirements
|
17 |
+
* `transformers>=4.40.0` for Qwen2-Math models. The latest version is recommended.
|
18 |
+
|
19 |
+
> [!Warning]
|
20 |
+
> <div align="center">
|
21 |
+
> <b>
|
22 |
+
> 🚨 This is a must because `transformers` integrated Qwen2 codes since `4.37.0`.
|
23 |
+
> </b>
|
24 |
+
> </div>
|
25 |
+
|
26 |
+
For requirements on GPU memory and the respective throughput, see similar results of Qwen2 [here](https://qwen.readthedocs.io/en/latest/benchmark/speed_benchmark.html).
|
27 |
+
|
28 |
+
## Quick Start
|
29 |
+
|
30 |
+
> [!Important]
|
31 |
+
>
|
32 |
+
> **Qwen2.5-Math-RM-72B** is a reward model typically used for offering feedback on the quality of reasoning and intermediate steps, serving in RLHF and Rejection Sampling.
|
33 |
+
|
34 |
+
### 🤗 Hugging Face Transformers
|
35 |
+
|
36 |
+
Here we show a code snippet to show you how to use the Qwen2.5-Math-RM-72B with `transformers`:
|
37 |
+
|
38 |
+
```python
|
39 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
40 |
+
|
41 |
+
model_name = "Qwen/Qwen2.5-Math-RM-72B"
|
42 |
+
device = "auto" # the device to load the model onto
|
43 |
+
|
44 |
+
model = AutoModel.from_pretrained(
|
45 |
+
model_name,
|
46 |
+
device_map=device,
|
47 |
+
torch_dtype=torch.bfloat16,
|
48 |
+
trust_remote_code=True,
|
49 |
+
).eval()
|
50 |
+
|
51 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
52 |
+
|
53 |
+
chat = [
|
54 |
+
{"role": "system", "content": "Please reason step by step, and put your final answer within \\boxed{}."},
|
55 |
+
{"role": "user", "content": "Janet’s ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?"},
|
56 |
+
{"role": "assistant", "content": "To determine how much Janet makes from selling the duck eggs at the farmers' market, we need to follow these steps:\n\n1. Calculate the total number of eggs laid by the ducks each day.\n2. Determine how many eggs Janet eats and bakes for herself each day.\n3. Find out how many eggs are left to be sold.\n4. Calculate the revenue from selling the remaining eggs at $2 per egg.\n\nLet's start with the first step:\n\n1. Janet's ducks lay 16 eggs per day.\n\nNext, we calculate how many eggs Janet eats and bakes for herself each day:\n\n2. Janet eats 3 eggs for breakfast every morning.\n3. Janet bakes 4 eggs for her friends every day.\n\nSo, the total number of eggs Janet eats and bakes for herself each day is:\n\\[ 3 + 4 = 7 \\text{ eggs} \\]\n\nNow, we find out how many eggs are left to be sold:\n\\[ 16 - 7 = 9 \\text{ eggs} \\]\n\nFinally, we calculate the revenue from selling the remaining eggs at $2 per egg:\n\\[ 9 \\times 2 = 18 \\text{ dollars} \\]\n\nTherefore, Janet makes \\(\\boxed{18}\\) dollars every day at the farmers' market."}
|
57 |
+
] # 3.75
|
58 |
+
|
59 |
+
conversation_str = tokenizer.apply_chat_template(
|
60 |
+
chat,
|
61 |
+
tokenize=False,
|
62 |
+
add_generation_prompt=False
|
63 |
+
)
|
64 |
+
input_ids = tokenizer.encode(
|
65 |
+
conversation_str,
|
66 |
+
return_tensors="pt",
|
67 |
+
add_special_tokens=False
|
68 |
+
).to(model.device)
|
69 |
+
|
70 |
+
outputs = model(input_ids=input_ids)
|
71 |
+
print(outputs[0])
|
72 |
+
```
|
73 |
+
|
74 |
+
### 🤖 ModelScope
|
75 |
+
We strongly advise users, especially those in mainland China, to use ModelScope. `snapshot_download` can help you solve issues concerning downloading checkpoints.
|
76 |
+
|
77 |
+
|
78 |
+
## Citation
|
79 |
+
|
80 |
+
If you find our work helpful, feel free to give us a citation.
|
81 |
+
|
82 |
+
```
|
83 |
+
@article{yang2024qwen2,
|
84 |
+
title={Qwen2 technical report},
|
85 |
+
author={Yang, An and Yang, Baosong and Hui, Binyuan and Zheng, Bo and Yu, Bowen and Zhou, Chang and Li, Chengpeng and Li, Chengyuan and Liu, Dayiheng and Huang, Fei and others},
|
86 |
+
journal={arXiv preprint arXiv:2407.10671},
|
87 |
+
year={2024}
|
88 |
+
}
|
89 |
+
```
|