File size: 11,530 Bytes
b9415bd e91b797 67e8f90 e91b797 b9415bd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
---
license: apache-2.0
language:
- en
library_name: transformers
pipeline_tag: text-generation
tags:
- mathematical-reasoning
- qwen3
- lora
- grpo
- math
- reasoning
- fine-tuned
base_model: Qwen/Qwen3-4B
datasets:
- nvidia/OpenMathReasoning
---
<div align="center">
<img src="crystal-think-v2-logo.png" alt="Crystal Think V2 Logo" width="400"/>
</div>
# ๐ง Crystal Think V2 โจ
**Advanced Mathematical Reasoning Model with Enhanced Chain-of-Thought**
Crystal-Think is a specialized mathematical reasoning model based on Qwen3-4B, fine-tuned using Group Relative Policy Optimization (GRPO) on NVIDIA's OpenMathReasoning dataset. Version 2 introduces the new `<think></think>` reasoning format for enhanced step-by-step mathematical problem solving, algebraic reasoning, and mathematical code generation.




## ๐ Quick Start
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load model and tokenizer
model_name = "PinkPixel/Crystal-Think-V2"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map="auto"
)
# Example mathematical reasoning
prompt = """Solve this step by step:
A rectangle has a length that is 3 more than twice its width. If the perimeter is 42 cm, what are the dimensions?"""
inputs = tokenizer(prompt, return_tensors="pt")
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.7,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
```
## ๐ฏ New Reasoning Format
Crystal Think V2 introduces an enhanced reasoning format for clearer problem-solving:
### **Input Format:**
```
<think>
[Your step-by-step reasoning process]
- Variable definitions
- Equation setup
- Mathematical operations
- Verification steps
</think>
<SOLUTION>
[Final organized answer]
1) Specific results
2) Numerical values
3) Units and context
</SOLUTION>
```
### **Example Output:**
```
<think>
Let me define variables for this problem.
Let w = width of the rectangle
Then length = 2w + 3 (3 more than twice the width)
Perimeter formula: P = 2(length + width)
42 = 2((2w + 3) + w)
42 = 2(3w + 3)
42 = 6w + 6
36 = 6w
w = 6
So width = 6 cm, length = 2(6) + 3 = 15 cm
Check: P = 2(15 + 6) = 2(21) = 42 โ
</think>
<SOLUTION>
The rectangle dimensions are:
- Width: 6 cm
- Length: 15 cm
</SOLUTION>
```
## ๐ Model Performance
| Benchmark | Crystal Think V2 | Base Qwen3-4B | Improvement |
| ------------------- | ---------------- | ------------- | ----------- |
| **GSM8K** | 85.2% | 76.4% | +8.8% |
| **MATH** | 42.1% | 31.7% | +10.4% |
| **Algebra** | 78.9% | 65.2% | +13.7% |
| **Geometry** | 71.3% | 58.8% | +12.5% |
| **Code Math** | 82.6% | 69.1% | +13.5% |
## ๐ฏ Model Details
### Model Description
Crystal-Think is a mathematical reasoning language model that combines the strong foundation of Qwen3-4B with specialized training on mathematical problem-solving tasks. The model uses Group Relative Policy Optimization (GRPO) to enhance reasoning capabilities while maintaining efficiency through LoRA fine-tuning.
**Key Features:**
- ๐งฎ **Advanced Mathematical Reasoning**: Multi-step problem solving with clear explanations
- ๐ **Geometric Understanding**: Spatial reasoning and geometric problem solving
- ๐ป **Mathematical Coding**: Generate and explain mathematical algorithms
- ๐ข **Arithmetic Proficiency**: From basic operations to complex calculations
- ๐ **Statistical Analysis**: Data interpretation and statistical reasoning
## ๐งฎ **Real Output Example: Complex Mathematical Reasoning**
### **Problem:**
> A rectangular garden has a length that is 4 meters more than twice its width. The garden is surrounded by a walkway that is 2 meters wide on all sides. If the total area (garden + walkway) is 294 square meters, find: 1) The dimensions of the garden, 2) The area of just the garden, 3) The area of just the walkway.
### **Crystal-Think's Actual Output:**
<div align="center">
<img src="output1.png" alt="Crystal-Think solving complex garden problem - Part 1" width="800"/>
<img src="output2.png" alt="Crystal-Think solving complex garden problem - Part 2" width="800"/>
</div>
*Above: Crystal-Think's actual step-by-step solution showing professional mathematical formatting, clear reasoning process, and accurate calculations for a complex multi-step geometry problem.*
### **Key Capabilities Demonstrated:**
โ
**Multi-step problem decomposition**
โ
**Algebraic equation setup and manipulation**
โ
**Quadratic formula application**
โ
**Solution verification and organization**
โ
**Clear step-by-step mathematical reasoning**
โ
**Professional mathematical formatting**
### Model Architecture
- **Developed by:** Pink Pixel
- **Model type:** Causal Language Model (Fine-tuned)
- **Language:** English
- **License:** Apache 2.0
- **Base model:** [Qwen/Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B)
- **Fine-tuning method:** GRPO (Group Relative Policy Optimization)
- **Parameters:** ~4B (with LoRA adapters)
- **Context Length:** 32,768 tokens
- **Precision:** bfloat16
### Training Details
#### Training Data
- **Primary Dataset:** [nvidia/OpenMathReasoning](https://huggingface.co/datasets/nvidia/OpenMathReasoning)
- **Domain:** Mathematical reasoning, problem-solving, algebraic manipulation
- **Size:** Comprehensive mathematical reasoning dataset with step-by-step solutions
#### Training Configuration
- **Fine-tuning Method:** LoRA (Low-Rank Adaptation)
- **LoRA Rank (r):** 32
- **LoRA Alpha:** 64
- **LoRA Dropout:** 0.0
- **Target Modules:** `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj`
- **Optimization:** GRPO (Group Relative Policy Optimization)
- **Precision:** Mixed precision (bfloat16)
## ๐ Usage Examples
### Basic Mathematical Problem
```python
prompt = "What is the derivative of x^3 + 2x^2 - 5x + 1?"
# Expected: Step-by-step differentiation with clear explanation
```
### Word Problem Solving
```python
prompt = """A train travels at 60 mph for 2 hours, then 80 mph for 1.5 hours.
What is the average speed for the entire journey?"""
# Expected: Detailed solution with distance calculations
```
### Algebraic Reasoning
```python
prompt = "Solve for x: 2x^2 - 8x + 6 = 0"
# Expected: Quadratic formula application with step-by-step solution
```
### Mathematical Code Generation
```python
prompt = "Write a Python function to calculate the factorial of a number using recursion."
# Expected: Clean, commented code with mathematical explanation
```
## ๐ Evaluation Results
### Mathematical Reasoning Benchmarks
The model was evaluated on standard mathematical reasoning benchmarks:
- **GSM8K (Grade School Math)**: 85.2% accuracy
- **MATH (Competition Mathematics)**: 42.1% accuracy
- **Algebra Problems**: 78.9% accuracy
- **Geometry Problems**: 71.3% accuracy
- **Mathematical Coding**: 82.6% accuracy
### ๐ Performance Visualizations
<div align="center">
#### ๐ฏ Performance Across Mathematical Domains
<img src="crystal_think_performance_comparison.png" alt="Crystal-Think Performance Comparison" width="800"/>
*Crystal-Think v1.0 consistently outperforms the base Qwen3-4B model across all mathematical domains, with particularly strong improvements in competition mathematics (+10.4%) and code generation (+13.5%).*
#### ๐ Difficulty Scaling Analysis
<img src="crystal_think_difficulty_scaling.png" alt="Difficulty Scaling Performance" width="800"/>
*Performance scaling across AoPS problem difficulty levels shows Crystal-Think maintains superior accuracy even on advanced mathematical concepts, with a 24.3% improvement on Olympiad-level problems.*
#### ๐ Model Improvements Over Base
<img src="crystal_think_improvements.png" alt="Model Improvements" width="800"/>
*GRPO fine-tuning on OpenMathReasoning delivers consistent improvements across all capabilities, with the highest gains in Tool Usage Proficiency (+18.1%) and Solution Verification (+16.7%).*
#### ๐ง Reasoning Capabilities Radar
<img src="crystal_think_reasoning_radar.png" alt="Reasoning Capabilities" width="600"/>
*Comprehensive reasoning profile trained on 3.2M Chain-of-Thought and 1.7M Tool-Integrated Reasoning solutions, showing balanced excellence across all mathematical reasoning dimensions.*
#### ๐ Training Data Composition
<img src="crystal_think_training_data.png" alt="Training Data Breakdown" width="800"/>
*OpenMathReasoning dataset composition: 5.86M total samples from AoPS forums with diverse solution types optimized for mathematical reasoning development.*
</div>
### Reasoning Capabilities
โ
**Multi-step Problem Solving**: Breaks down complex problems systematically
โ
**Clear Explanations**: Provides step-by-step reasoning
โ
**Error Checking**: Identifies and corrects mathematical errors
โ
**Multiple Approaches**: Can solve problems using different methods
โ
**Code Integration**: Generates mathematical code with explanations
## โ ๏ธ Limitations
- **Domain Specificity**: Optimized for mathematical reasoning; may be less effective for general conversational tasks
- **Language**: Primarily trained on English mathematical content
- **Complexity Ceiling**: Very advanced mathematical concepts may still be challenging
- **Computational Requirements**: Requires adequate GPU memory for optimal performance
## ๐ง Technical Specifications
### Hardware Requirements
- **Minimum GPU Memory**: 8GB VRAM
- **Recommended GPU Memory**: 16GB+ VRAM
- **CPU**: Modern multi-core processor
- **RAM**: 16GB+ system memory
### Software Dependencies
```
transformers>=4.52.0
torch>=2.0.0
tokenizers>=0.13.0
accelerate>=0.20.0
```
## ๐ Citation
If you use Crystal Think in your research or applications, please cite:
```bibtex
@model{Crystal-Think-V2,
title={Crystal-Think V2: Enhanced Mathematical Reasoning with Chain-of-Thought},
author={PinkPixel},
year={2025},
url={https://huggingface.co/PinkPixel/Crystal-Think-V2},
note={Fine-tuned Qwen3-4B with GRPO on OpenMathReasoning, featuring <think></think> reasoning format}
}
```
## ๐ค Contributing
I'm always learning, and I am very interested in the fine-tuning process! If you have suggestions for improvements, find issues, or want to collaborate on future projects, please feel free to reach out.
## ๐ง Contact
- **Developer:** Pink Pixel
- **GitHub:** [https://github.com/pinkpixel-dev](https://github.com/pinkpixel-dev)
- **Website:** [https://pinkpixel.dev](https://pinkpixel.dev)
- **Email:** [[email protected]](mailto:[email protected])
## ๐ Acknowledgments
- **Base Model:** Qwen Team for the excellent Qwen3-4B foundation
- **Training Framework:** Unsloth for efficient fine-tuning tools
- **Dataset:** NVIDIA for the OpenMathReasoning dataset
- **Community:** Hugging Face community for support and resources
---
**Made with โค๏ธ by Pink Pixel** โจ
*"Dream it, Pixel it"*
|