Update README.md
Browse files
README.md
CHANGED
@@ -3,197 +3,159 @@ library_name: transformers
|
|
3 |
tags: []
|
4 |
---
|
5 |
|
6 |
-
# Model Card for
|
7 |
-
|
8 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
-
|
10 |
-
|
11 |
|
12 |
## Model Details
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
|
|
|
|
17 |
|
18 |
-
|
19 |
|
20 |
-
- **
|
21 |
-
- **Funded by [optional]:** [More Information Needed]
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
- **
|
34 |
-
- **Demo [
|
35 |
|
36 |
## Uses
|
37 |
|
38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
-
|
40 |
### Direct Use
|
|
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
### Downstream Use [optional]
|
47 |
-
|
48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
-
|
50 |
-
[More Information Needed]
|
51 |
|
52 |
### Out-of-Scope Use
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
[More Information Needed]
|
57 |
|
58 |
## Bias, Risks, and Limitations
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
63 |
|
64 |
-
|
65 |
|
66 |
-
|
|
|
|
|
67 |
|
68 |
-
|
|
|
|
|
69 |
|
70 |
-
|
|
|
71 |
|
72 |
-
|
|
|
|
|
|
|
73 |
|
74 |
-
|
|
|
|
|
|
|
|
|
75 |
|
76 |
## Training Details
|
77 |
|
78 |
### Training Data
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
83 |
|
84 |
### Training Procedure
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
92 |
|
93 |
#### Training Hyperparameters
|
94 |
|
95 |
-
- **
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
## Evaluation
|
104 |
|
105 |
-
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
126 |
|
127 |
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
|
141 |
## Environmental Impact
|
142 |
|
143 |
-
|
144 |
-
|
145 |
-
Carbon
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
|
161 |
-
|
162 |
|
163 |
-
|
|
|
164 |
|
165 |
-
|
166 |
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
-
|
|
|
170 |
|
171 |
-
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
|
199 |
-
|
|
|
3 |
tags: []
|
4 |
---
|
5 |
|
6 |
+
# Model Card for _Qwen2.5-0.5B-Instruct (Fine-Tuned on OpenR1-Math-220k, 2% subset)_
|
|
|
|
|
|
|
|
|
7 |
|
8 |
## Model Details
|
9 |
|
10 |
+
**Model Name**: Qwen2.5-0.5B-Instruct (GRPO Fine-Tuned)
|
11 |
+
**Model ID**: `_Qwen2.5-0.5B-R1subset_`
|
12 |
+
**License**: [Apache 2.0 / or whichever applies]
|
13 |
+
**Finetuned From**: [Qwen/Qwen2.5-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct)
|
14 |
+
**Language(s)**: English (mathematical text)
|
15 |
|
16 |
+
**Developed By**: Christian Cooper and collaborators
|
17 |
+
**Funding**: Self-sponsored
|
18 |
+
**Shared By**: Christian Cooper
|
19 |
|
20 |
+
### Model Description
|
21 |
|
22 |
+
This model is a **Qwen2.5-0.5B** base LLM fine-tuned on a **2% subset** of the [OpenR1-Math-220k](https://huggingface.co/datasets/open-r1/OpenR1-Math-220k) dataset. I used **Group Relative Policy Optimization (GRPO)** from the `trl` library, guiding the model toward producing well-formatted chain-of-thought answers in:
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
+
```
|
25 |
+
<reasoning>
|
26 |
+
...
|
27 |
+
</reasoning>
|
28 |
+
<answer>
|
29 |
+
...
|
30 |
+
</answer>
|
31 |
+
```
|
32 |
|
33 |
+
It focuses on math reasoning tasks, learning to generate a step-by-step solution (`<reasoning>`) and a numeric or final textual answer (`<answer>`). We incorporate reward functions that encourage correct chain-of-thought structure, numeric answers, and correctness.
|
34 |
|
35 |
+
### Model Sources
|
36 |
+
- **GitHub or Repo**: *[Pending]*
|
37 |
+
- **Paper/Demo**: *[Pending]*
|
38 |
|
39 |
## Uses
|
40 |
|
|
|
|
|
41 |
### Direct Use
|
42 |
+
- **Math Problem Solving**: The model tries to reason through math word problems, providing step-by-step reasoning and a final answer.
|
43 |
|
44 |
+
### Downstream Use
|
45 |
+
- **Educational Tools**: Potentially used in tutoring or step-by-step solution generation.
|
46 |
+
- **Math Chatbots**: A math helper that can respond in a structured `<reasoning>/<answer>` format.
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
### Out-of-Scope Use
|
49 |
+
- **High-Stakes Decisions**: Model is not guaranteed to be correct for advanced or critical math scenarios (finance, medical, engineering safety).
|
50 |
+
- **Non-English**: Primary training data is English math text, so reliability in other languages is minimal.
|
|
|
|
|
51 |
|
52 |
## Bias, Risks, and Limitations
|
53 |
|
54 |
+
- **Bias**: Although this is a math-focused dataset, any language model can exhibit unintended biases.
|
55 |
+
- **Risks**: The model may produce mathematically incorrect or incomplete solutions. The partial coverage (2% of the dataset) further limits accuracy.
|
56 |
+
- **Limitations**:
|
57 |
+
- Only partially fine-tuned on 2% of the data, so correctness is not guaranteed.
|
58 |
+
- The chain-of-thought is for interpretability but may still contain flawed reasoning or leaps.
|
59 |
|
60 |
+
## How to Get Started
|
61 |
|
62 |
+
```python
|
63 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
64 |
+
import torch
|
65 |
|
66 |
+
model_name = "HarleyCooper/Qwen.5B-OpenR1Math" # Will keep the same name through all % iterations.
|
67 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
68 |
+
model = AutoModelForCausalLM.from_pretrained(model_name).to("cuda")
|
69 |
|
70 |
+
prompt = """<reasoning>
|
71 |
+
Question: It is known that in a convex $n$-gon ($n>3$) no three diagonals pass through the same point.
|
72 |
|
73 |
+
Find the number of points (distinct from the vertices) of intersection of pairs of diagonals.
|
74 |
+
</reasoning>
|
75 |
+
<answer>
|
76 |
+
"""
|
77 |
|
78 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
79 |
+
outputs = model.generate(**inputs, max_new_tokens=2000)
|
80 |
+
answer = tokenizer.decode(outputs[0])
|
81 |
+
print(answer)
|
82 |
+
```
|
83 |
|
84 |
## Training Details
|
85 |
|
86 |
### Training Data
|
87 |
|
88 |
+
- **Dataset**: A 2% subsample (~4.4k problems) of [OpenR1-Math-220k](https://huggingface.co/datasets/open-r1/OpenR1-Math-220k).
|
89 |
+
- **Data Format**: Each sample has `problem`, `solution`, `answer`. We transform them into:
|
90 |
+
- `"prompt"`: A single string containing system instructions + the problem text.
|
91 |
+
- `"answer"`: A string with `<reasoning>` + `<answer>` blocks.
|
92 |
|
93 |
### Training Procedure
|
94 |
|
95 |
+
- **Framework**: [TRL (v0.4+)](https://github.com/lvwerra/trl) with Group Relative Policy Optimization (GRPO).
|
96 |
+
- **Objective**: Reinforcement learning on chain-of-thought format, numeric correctness, and final-answer consistency.
|
97 |
+
- **Reward Functions**:
|
98 |
+
1. **`xmlcount_reward_func`**: Encourages `<reasoning>`/`<answer>` structure.
|
99 |
+
2. **`soft_format_reward_func`**: Checks for `<reasoning>.*</reasoning><answer>.*</answer>` in any multiline arrangement.
|
100 |
+
3. **`strict_format_reward_func`**: Strict multiline regex for exact formatting.
|
101 |
+
4. **`int_reward_func`**: Partial reward if the final `<answer>` is purely numeric.
|
102 |
+
5. **`correctness_reward_func`**: Binary reward if the final extracted answer exactly matches the known correct answer.
|
103 |
|
104 |
#### Training Hyperparameters
|
105 |
|
106 |
+
- **Base Model**: Qwen2.5-0.5B
|
107 |
+
- **Learning Rate**: ~5e-6
|
108 |
+
- **Batch Size**: 1–2 (due to GPU constraints)
|
109 |
+
- **Optimizer**: AdamW (β1=0.9, β2=0.99)
|
110 |
+
- **Scheduler**: Cosine with warmup_ratio=0.1
|
111 |
+
- **Num Generations**: 16 (GRPO config)
|
112 |
+
- **Number of Training Epochs**: 1 epoch on 2% data
|
113 |
+
- **Hardware**: Single A100 40GB on Colab
|
114 |
+
- **Max Prompt Length**: 256 tokens
|
115 |
+
- **Max Completion Length**: 200 tokens
|
116 |
+
|
117 |
+
### Speeds, Sizes, Times
|
118 |
+
- **Approx. Steps**: ~200–300 steps for 2% subset
|
119 |
+
- **Run Time**: Varies from ~1 to 2 hours on Colab A100
|
120 |
|
121 |
## Evaluation
|
122 |
|
123 |
+
### Testing Data
|
124 |
+
- Currently trained + tested on the same subset (2%). Next step would be to evaluate on a withheld portion or the full set to measure true correctness.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
|
126 |
+
### Metrics
|
127 |
+
- **Format Rewards**: `xmlcount`, `soft_format`, `strict_format`
|
128 |
+
- **Correctness**: Exact match final numeric/string answer
|
129 |
+
- **Partial Numeric**: `int_reward_func`
|
130 |
|
131 |
### Results
|
132 |
+
- The model shows a strong improvement in output format (70–80% format compliance) but relatively low exact numeric correctness. Additional epochs or a larger training fraction are needed for better correctness.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
|
134 |
## Environmental Impact
|
135 |
|
136 |
+
- **Hardware**: Single A100 40GB GPU in a Colab environment
|
137 |
+
- **Train Time**: ~1–2 hours on 2% data
|
138 |
+
- **Carbon Footprint**: Not measured exactly, but minimal compared to large-scale runs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
|
140 |
+
## Model Architecture & Objective
|
141 |
|
142 |
+
- **Architecture**: Transformer-based causal language model (Qwen2.5-0.5B)
|
143 |
+
- **Objective**: RL-based chain-of-thought generation for math reasoning
|
144 |
|
145 |
+
## Citation
|
146 |
|
147 |
+
```
|
148 |
+
@misc{cooperQwen2.5-0.5B,
|
149 |
+
title={Qwen2.5-0.5B Fine-Tuned on OpenR1 (2% subset)},
|
150 |
+
author={Christian H. Cooper.},
|
151 |
+
howpublished={\url{https://huggingface.co/Christian-cooper-us/Qwen2.5-0.5B-R1subset}},
|
152 |
+
year={2025},
|
153 |
+
}
|
154 |
+
```
|
155 |
|
156 |
+
## Contact
|
157 |
+
- Maintainers: Christian Cooper (GitHub: [@christian-cooper-us](https://huggingface.co/HarleyCooper)), others.
|
158 |
|
159 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
+
**Disclaimer**: This model is experimental, trained on only 2% of the dataset. It may produce inaccurate math solutions and is not suitable for high-stakes or time-sensitive deployments.
|