DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models

Zhihong Shao, Peiyi Wang, Qihao Zhu, Runxin Xu, Junxiao Song, Mingchuan Zhang, Y. K. Li, Y. Wu, Daya Guo

2024 · arXiv

DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models

Problem

Framing

Open open-source LLMs lag badly on competition math, and PPO-style RL adds a full value model that inflates memory cost. DeepSeekMath closes both gaps with 120B curated math tokens and GRPO, a critic-free PPO variant. The 7B RL model reaches 51.7% on MATH, rising to 60.9% with 64-sample self-consistency.

Currently Used Methods

Foundational

Proposed Method

Architecture

The system has three stages: continual pretraining from DeepSeek-Coder-Base-v1.5 7B, mathematical instruction tuning, then RL with GRPO. The data pipeline iteratively trains a fastText retriever, mines Common Crawl, discovers math-heavy domains, and expands the seed set to 35.5M pages and 120B tokens.

Iterative data-mining pipeline: a fastText classifier recalls math pages from deduplicated Common Crawl, then domain discovery and URL annotation expand the seed corpus.

Loss / Objective

GRPO replaces PPO's learned baseline with group-relative normalization over sampled completions.

JGRPO(θ)=EqP(Q),{oi}i=1Gπθold(Oq)[1Gi=1G1oit=1oimin(ri,t(θ)A^i,t,clip(ri,t(θ),1ϵ,1+ϵ)A^i,t)βDKL ⁣(πθπref)]J_{\mathrm{GRPO}}(\theta)=\mathbb{E}_{q \sim P(Q),\{o_i\}_{i=1}^{G} \sim \pi_{\theta_{\mathrm{old}}}(O\mid q)}\left[\frac{1}{G}\sum_{i=1}^{G}\frac{1}{|o_i|}\sum_{t=1}^{|o_i|}\min\left(r_{i,t}(\theta)\hat{A}_{i,t},\operatorname{clip}\left(r_{i,t}(\theta),1-\epsilon,1+\epsilon\right)\hat{A}_{i,t}\right)-\beta D_{\mathrm{KL}}\!\left(\pi_\theta\|\pi_{\mathrm{ref}}\right)\right] ri,t(θ)=πθ(oi,tq,oi,<t)πθold(oi,tq,oi,<t),A^i=rimean({rj}j=1G)std({rj}j=1G)r_{i,t}(\theta)=\frac{\pi_\theta(o_{i,t}\mid q,o_{i,<t})}{\pi_{\theta_{\mathrm{old}}}(o_{i,t}\mid q,o_{i,<t})},\qquad \hat{A}_{i}=\frac{r_i-\operatorname{mean}(\{r_j\}_{j=1}^{G})}{\operatorname{std}(\{r_j\}_{j=1}^{G})}

Sampling Rule / Algorithm

Each prompt draws a group of completions from the old policy, scores them, normalizes rewards within the group, then updates the policy with clipped ratios and a KL penalty.

{oi}i=1Gπθold(Oq),ri=rϕ(q,oi),A^i=rirˉsr\{o_i\}_{i=1}^{G} \sim \pi_{\theta_{\mathrm{old}}}(O\mid q), \qquad r_i = r_\phi(q,o_i), \qquad \hat{A}_{i}=\frac{r_i-\bar{r}}{s_r}

Training Procedure

Evaluation

Datasets

Metrics

Headline results

Results plot: accuracy over training steps on GSM8K and MATH, comparing RFT, Online RFT, GRPO with outcome supervision, and GRPO with process supervision.

Ablations

Method Strengths and Weaknesses

Strengths

Weaknesses

Suggestions from the authors

Links

Prior Papers

Further Papers

No vault papers identified as further work yet.