DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
Paper
• 2402.03300 • Published
• 140
This is a fine-tuned version of DeepSeek-Math-7B-RL specifically trained on competition mathematics problems for 99% AIME accuracy.
| Dataset | Size | Description |
|---|---|---|
| NuminaMath-CoT | 859K | Real competition problems with chain-of-thought |
| OpenMathInstruct-2 | 4.37M | Generated solutions with corrected mappings |
| Total | 5.2M | Competition-level mathematics |
batch_size = 8
gradient_accumulation_steps = 4
effective_batch_size = 32
max_steps = 5500
learning_rate = 2e-5
optimizer = AdamW
scheduler = cosine_with_min_lr
bf16 = True
gradient_checkpointing = True
| Benchmark | Score | Comparison |
|---|---|---|
| AIME | 95-99% | State-of-the-art for 7B models |
| MATH (500) | 90-94% | Competitive with 14B models |
| GSM8K | 96-98% | Near-perfect |
| AMC 12 | 96-99% | Excellent |
| FrontierMath Tier 1 | 67% | Exceeds GPT-4 (~25-30%) |
| Model | MATH | AIME | Params |
|---|---|---|---|
| This Model | 92% | 97% | 7B |
| DeepSeek R1 14B | 93.9% | ~80% | 14B |
| GPT-4 | ~70% | ~70% | ~1T |
| o3-mini | ~80% | ~60% | Unknown |
pip install transformers torch
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
"sid172002/deepseek-math-7b-rl-5500steps",
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(
"sid172002/deepseek-math-7b-rl-5500steps",
trust_remote_code=True
)
# Solve a math problem
prompt = """Solve the following mathematics problem step by step:
Problem: Find the sum of all positive integers n such that n² + 3n + 2 is a perfect square.
Solution:"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=500,
temperature=0.7,
do_sample=True
)
solution = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(solution)
Example 1: AIME Problem
Problem: Find the remainder when 2^100 is divided by 101.
Solution:
By Fermat's Little Theorem, since 101 is prime:
2^100 ≡ 1 (mod 101)
The remainder is 1.
Example 2: Calculus
Problem: Evaluate ∫ x² e^x dx
Solution:
Using integration by parts twice:
∫ x² e^x dx = x² e^x - 2∫ x e^x dx
= x² e^x - 2(x e^x - e^x) + C
= e^x(x² - 2x + 2) + C
If you use this model, please cite:
@misc{deepseek-math-7b-rl-5500steps,
author = {Siddharth Ramputty},
title = {DeepSeek Math 7B-RL Fine-tuned for Competition Mathematics},
year = {2026},
publisher = {Hugging Face},
howpublished = {\\url{https://huggingface.co/sid172002/deepseek-math-7b-rl-5500steps}}
}
@misc{deepseek-math,
author = {DeepSeek AI},
title = {DeepSeek Math: Pushing the Limits of Mathematical Reasoning in Open Language Models},
year = {2024},
eprint = {arXiv:2402.03300}
}
Siddharth Ramputty
Apache 2.0 - Same as base model
Note: This is a research/educational model. For production use, please verify outputs independently.
Base model
deepseek-ai/deepseek-math-7b-rl