Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
datasets:
|
4 |
+
- xl-zhao/PromptCoT-Problem-Generation-Dataset
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
base_model:
|
8 |
+
- meta-llama/Llama-3.1-8B
|
9 |
+
---
|
10 |
+
# **PromptCoT: Synthesizing Olympiad-Level Problems for Mathematical Reasoning in Large Language Modelsg**
|
11 |
+
|
12 |
+
[](http://arxiv.org/abs/2503.02324)
|
13 |
+
[](https://github.com/zhaoxlpku/PromptCoT)
|
14 |
+
|
15 |
+
---
|
16 |
+
|
17 |
+
## 🚀 **Overview**
|
18 |
+
The **PromptCoT Problem Generation Model** is a lightweight yet powerful model for synthesizing high-quality Olympiad-level mathematical problems. It enables the scalable construction of problem sets to facilitate post-training tasks such as **Supervised Fine-Tuning (SFT) and Reinforcement Learning (RL)**. By systematically modeling expert problem design, PromptCoT helps generate logically consistent and intellectually demanding problems at scale.
|
19 |
+
|
20 |
+
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).
|
21 |
+
|
22 |
+
---
|
23 |
+
|
24 |
+
## 🔥 **Quick Start: Using the Model**
|
25 |
+
|
26 |
+
### **1️⃣ Install Dependencies**
|
27 |
+
```bash
|
28 |
+
pip install transformers vllm torch accelerate
|
29 |
+
```
|
30 |
+
|
31 |
+
### **2️⃣ Load the Model with Hugging Face Transformers**
|
32 |
+
You can use the model for **direct inference** using Hugging Face’s `generate` API:
|
33 |
+
```python
|
34 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
35 |
+
|
36 |
+
model_name = "xl-zhao/PromptCoT-Problem-Generation-Model"
|
37 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
38 |
+
model = AutoModelForCausalLM.from_pretrained(model_name).to("cuda")
|
39 |
+
|
40 |
+
foundational_concepts = [
|
41 |
+
"Ability to apply quantitative reasoning and estimation techniques to solve problems, including making approximations and using logical deductions to arrive at a solution.",
|
42 |
+
"Ability to solve equations involving complex numbers, including finding conditions under which two complex numbers are equal, particularly in the context of their magnitudes and arguments.",
|
43 |
+
"Fractional arithmetic: Performing calculations with fractions to determine the final probability.",
|
44 |
+
"Interpreting and solving problems involving nested operations or functions.",
|
45 |
+
"Using logical reasoning to connect given data points and derive conclusions."
|
46 |
+
]
|
47 |
+
|
48 |
+
difficulty_level = "HMMT-Feb"
|
49 |
+
|
50 |
+
prompt = (
|
51 |
+
"Given foundational concepts and difficulty level, identify connections and develop a question "
|
52 |
+
"that integrates these concepts with appropriate complexity.\n\n"
|
53 |
+
"Foundational Concepts:\n"
|
54 |
+
+ "\n".join(f"{i+1}. {concept}" for i, concept in enumerate(foundational_concepts))
|
55 |
+
+ f"\n\nDifficulty Level: {difficulty_level}"
|
56 |
+
)
|
57 |
+
|
58 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
59 |
+
|
60 |
+
with torch.no_grad():
|
61 |
+
output = model.generate(**inputs, max_length=4096, temperature=0.6)
|
62 |
+
|
63 |
+
generated_problem = tokenizer.decode(output[0], skip_special_tokens=True)
|
64 |
+
print(generated_problem)
|
65 |
+
```
|
66 |
+
|
67 |
+
---
|
68 |
+
|
69 |
+
## ⚡ **Using vLLM for Fast Inference**
|
70 |
+
For optimized inference, use `vLLM`:
|
71 |
+
```python
|
72 |
+
from vllm import LLM, SamplingParams
|
73 |
+
|
74 |
+
model_name = "xl-zhao/PromptCoT-Problem-Generation-Model"
|
75 |
+
llm = LLM(model=model_name, tensor_parallel_size=1)
|
76 |
+
|
77 |
+
foundational_concepts = [
|
78 |
+
"Ability to apply quantitative reasoning and estimation techniques to solve problems, including making approximations and using logical deductions to arrive at a solution.",
|
79 |
+
"Ability to solve equations involving complex numbers, including finding conditions under which two complex numbers are equal, particularly in the context of their magnitudes and arguments.",
|
80 |
+
"Fractional arithmetic: Performing calculations with fractions to determine the final probability.",
|
81 |
+
"Interpreting and solving problems involving nested operations or functions.",
|
82 |
+
"Using logical reasoning to connect given data points and derive conclusions."
|
83 |
+
]
|
84 |
+
|
85 |
+
difficulty_level = "HMMT-Feb"
|
86 |
+
|
87 |
+
prompt = (
|
88 |
+
"Given foundational concepts and difficulty level, identify connections and develop a question "
|
89 |
+
"that integrates these concepts with appropriate complexity.\n\n"
|
90 |
+
"Foundational Concepts:\n"
|
91 |
+
+ "\n".join(f"{i+1}. {concept}" for i, concept in enumerate(foundational_concepts))
|
92 |
+
+ f"\n\nDifficulty Level: {difficulty_level}"
|
93 |
+
)
|
94 |
+
|
95 |
+
sampling_params = SamplingParams(temperature=0.6, max_tokens=4096)
|
96 |
+
outputs = llm.generate([prompt], sampling_params)
|
97 |
+
|
98 |
+
print(outputs[0].outputs[0].text)
|
99 |
+
```
|
100 |
+
|
101 |
+
---
|
102 |
+
|
103 |
+
## 🔗 **Full Usage & Advanced Options**
|
104 |
+
For advanced usage, including **batch inference and rejection sampling for filtering high-quality problems**, refer to the **full repository on GitHub**:
|
105 |
+
🔹 [GitHub: PromptCoT](https://github.com/zhaoxlpku/PromptCoT)
|
106 |
+
|
107 |
+
---
|
108 |
+
|
109 |
+
## 📜 **Citation**
|
110 |
+
If you use **PromptCoT**, please consider citing:
|
111 |
+
```
|
112 |
+
@article{zhao2025promptcot,
|
113 |
+
author = {Zhao, Xueliang and Wu, Wei and Guan, Jian and Kong, Lingpeng},
|
114 |
+
title = {PromptCoT: Synthesizing Olympiad-Level Problems for Mathematical Reasoning in Large Language Models},
|
115 |
+
year = {2025},
|
116 |
+
journal = {arXiv preprint arXiv:2503.02324},
|
117 |
+
url = {http://arxiv.org/abs/2503.02324}
|
118 |
+
}
|
119 |
+
```
|
120 |
+
|
121 |
+
|
122 |
+
|