Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
datasets:
|
4 |
+
- xl-zhao/PromptCoT-DS-Dataset
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
base_model:
|
8 |
+
- deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B
|
9 |
+
---
|
10 |
+
# **PromptCoT: Synthesizing Olympiad-Level Problems for Mathematical Reasoning in Large Language Models**
|
11 |
+
|
12 |
+
[](http://arxiv.org/abs/2503.02324)
|
13 |
+
[](https://github.com/zhaoxlpku/PromptCoT)
|
14 |
+
|
15 |
+
---
|
16 |
+
|
17 |
+
## 🚀 **Overview**
|
18 |
+
The **PromptCoT-DS** series models are distilled mathematical reasoning models trained using **more challenging problem sets generated by the PromptCoT pipeline**. These models are derived from **DeepSeek-R1-Distill-Qwen** and benefit from an enhanced training dataset designed to improve mathematical reasoning capabilities.
|
19 |
+
|
20 |
+
✔ **PromptCoT-DS-1.5B** → Distilled from **DeepSeek-R1-Distill-Qwen-7B** (1.5B parameters)
|
21 |
+
✔ **PromptCoT-DS-7B** → Distilled from **DeepSeek-R1-Distill-Qwen-7B** (7B parameters)
|
22 |
+
|
23 |
+
For more details, refer to our **paper on ArXiv**: [🔗 PromptCoT: Synthesizing Olympiad-Level Problems for Mathematical Reasoning in Large Language Models](http://arxiv.org/abs/2503.02324).
|
24 |
+
|
25 |
+
---
|
26 |
+
|
27 |
+
|
28 |
+
## 🔥 **Quick Start: Using the Model**
|
29 |
+
|
30 |
+
### **1️⃣ Install Dependencies**
|
31 |
+
```bash
|
32 |
+
pip install transformers vllm torch accelerate
|
33 |
+
```
|
34 |
+
|
35 |
+
### **2️⃣ Load the Model with Hugging Face Transformers**
|
36 |
+
You can use **PromptCoT-DS** models to solve **mathematical problems** using Hugging Face’s `generate` API:
|
37 |
+
|
38 |
+
```python
|
39 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
40 |
+
|
41 |
+
model_name = "xl-zhao/PromptCoT-DS-1.5B"
|
42 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
43 |
+
model = AutoModelForCausalLM.from_pretrained(model_name).to("cuda")
|
44 |
+
|
45 |
+
problem_statement = (
|
46 |
+
"A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?"
|
47 |
+
)
|
48 |
+
|
49 |
+
prompt = (
|
50 |
+
"<|begin▁of▁sentence|>Please reason step by step, and put your final answer within \\boxed{{}}."
|
51 |
+
"<|User|>" + problem_statement + "<|Assistant|>"
|
52 |
+
)
|
53 |
+
|
54 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
55 |
+
|
56 |
+
with torch.no_grad():
|
57 |
+
output = model.generate(**inputs, max_length=32768, temperature=0.6)
|
58 |
+
|
59 |
+
generated_solution = tokenizer.decode(output[0], skip_special_tokens=True)
|
60 |
+
print(generated_solution)
|
61 |
+
```
|
62 |
+
|
63 |
+
---
|
64 |
+
|
65 |
+
## ⚡ **Using vLLM for Fast Inference**
|
66 |
+
For optimized inference, use `vLLM`:
|
67 |
+
```python
|
68 |
+
from vllm import LLM, SamplingParams
|
69 |
+
|
70 |
+
model_name = "xl-zhao/PromptCoT-DS-1.5B"
|
71 |
+
llm = LLM(model=model_name, tensor_parallel_size=1)
|
72 |
+
|
73 |
+
problem_statement = (
|
74 |
+
"A robe takes 2 bolts of blue fiber and half that much white fiber. How many bolts in total does it take?"
|
75 |
+
)
|
76 |
+
|
77 |
+
prompt = (
|
78 |
+
"<|begin▁of▁sentence|>Please reason step by step, and put your final answer within \\boxed{{}}."
|
79 |
+
"<|User|>" + problem_statement + "<|Assistant|>"
|
80 |
+
)
|
81 |
+
|
82 |
+
sampling_params = SamplingParams(temperature=0.6, max_tokens=32768)
|
83 |
+
outputs = llm.generate([prompt], sampling_params)
|
84 |
+
|
85 |
+
print(outputs[0].outputs[0].text)
|
86 |
+
```
|
87 |
+
|
88 |
+
---
|
89 |
+
|
90 |
+
## 🔗 **Full Usage & Advanced Options**
|
91 |
+
For advanced usage, including batch inference and evaluation on mathematical benchmarks, refer to the **full repository on GitHub**:
|
92 |
+
🔹 [GitHub: PromptCoT](https://github.com/zhaoxlpku/PromptCoT)
|
93 |
+
|
94 |
+
---
|
95 |
+
|
96 |
+
## 📜 **Citation**
|
97 |
+
If you use **PromptCoT**, please consider citing:
|
98 |
+
```
|
99 |
+
@article{zhao2025promptcot,
|
100 |
+
author = {Zhao, Xueliang and Wu, Wei and Guan, Jian and Kong, Lingpeng},
|
101 |
+
title = {PromptCoT: Synthesizing Olympiad-Level Problems for Mathematical Reasoning in Large Language Models},
|
102 |
+
year = {2025},
|
103 |
+
journal = {arXiv preprint arXiv:2503.02324},
|
104 |
+
url = {http://arxiv.org/abs/2503.02324}
|
105 |
+
}
|
106 |
+
```
|