TL;DR
Qwen2.5 is a family of large language models, from 0.5 to 72 billion parameters, plus two hosted mixture-of-experts models. The authors raised the pre-training data from 7 to 18 trillion tokens, then post-trained the models with over one million supervised examples, a round of preference optimisation, and reinforcement learning with a reward model. The 72B instruction-tuned model is reported to surpass Llama-3.1-405B-Instruct on several benchmarks.
Builds on: Transformer, Grouped-Query Attention, Rotary Position Embedding, Mixture of Experts, Instruction Tuning, Reinforcement Learning from Human Feedback (RLHF) · Leads to: Direct Preference Optimization, Group Relative Policy Optimization (GRPO)
Why it mattered
Qwen2.5 is one of the largest open-weight model families released with full technical detail. Its weights, quantised versions and base and instruction models were published for common use, so researchers and developers could fine-tune and deploy them without access to a closed API. The report also shows the recipe in the open: how data were filtered and mixed, how hyperparameters were chosen with scaling laws, and how post-training was staged. Specialised models such as Qwen2.5-Math and Qwen2.5-Coder were trained from the same base.
The problem
Before this release, open models were often trained on less data and tuned with simpler recipes, so their gap to closed models was wide. The authors set out to improve three things at once: the knowledge and reasoning that come from pre-training data, the usefulness of answers that come from post-training, and the practical limits of use, such as output length, structured output and context length. Each of these needs a different trade-off in compute, so the design has to balance them across model sizes.
How it works
The report is a pipeline. Each stage feeds the next, so we follow it in order.
- Curate the pre-training data. A Qwen2-Instruct model scores each training sample on quality, and low-scoring samples are removed. Math and code data from Qwen2.5-Math and Qwen2.5-Coder are added, and synthetic data is generated and then filtered by reward models.
- Balance the domains. Web data over-represents e-commerce and entertainment and under-represents science and technology. The authors down-sample the first and up-sample the second, so the mixture favours high-value content.
- Pre-train on 18 trillion tokens. The total is about 2.6 times (18 divided by 7) the 7 trillion used for Qwen2, and it is trained in stages with different mixtures.
- Set hyperparameters with scaling laws. Small experiments fit the best learning rate and batch size as functions of model size and data size, and these fits are used for the full models, dense and mixture-of-experts alike.
- Extend the context. Pre-training first uses 4,096-token sequences. The final stage moves to 32,768 tokens and raises the RoPE base from 10,000 to 1,000,000. Inference-time methods then reach 131,072 tokens for most models, and Qwen2.5-Turbo reaches 1 million.
- Supervised fine-tuning. More than one million instruction examples cover long outputs, mathematics, coding, instruction following, structured data, logic and multilingual cases. The model trains for two epochs with a learning rate decreasing from to .
- Offline reinforcement learning with DPO. About 150,000 preference pairs are built from checked responses. Responses that pass quality checks are positive, and those that fail are negative, for objective tasks such as maths and code.
- Online reinforcement learning with GRPO. A reward model scores several responses to the same query, and the policy is updated relative to the average score of the group. Queries whose scores vary most are prioritised. Eight responses are sampled per query.
- Evaluate. Base models and instruction models are scored on a suite of benchmarks, after removing training samples that overlap test data by n-gram matching.
flowchart LR D[curated data 18T tokens] --> P[pre-training with scaling-law hyperparameters] P --> C[context extension to 32K then 128K+] C --> S[SFT: over 1M examples] S --> O[offline RL: DPO on about 150K pairs] O --> N[online RL: GRPO with reward model] N --> E[evaluation]
The math
Grouped-query attention ratio. The 72B model has 64 query heads and 8 key-value heads, so each key-value head serves a group of 64 / 8 = 8 query heads. The 7B model has 28 query heads and 4 key-value heads, so each key-value head serves 7 query heads.
Rotary embedding base. RoPE rotates pairs of coordinates of the query and key by an angle that depends on the position and a frequency. For a pair of a head of size , the frequency is , where is the base. A larger base makes the slowest frequencies change more slowly, so the model can tell positions apart over longer distances. Raising from to is the change used for long context.
Offline stage, DPO. For a prompt , a preferred response and a rejected response , the DPO loss with reference model and scale is , where is the logistic function. The loss grows when the model prefers the rejected answer more than the reference does.
Online stage, GRPO advantage. For a group of responses to one query with rewards , each response gets advantage . The advantage is relative to the group, so no separate value model is needed.
Working the numbers
Use the GQA ratio for a cache estimate. For one token, one layer, the key and value cache holds numbers. Take an illustrative head size of 128 and compare 64 key-value heads with 8.
- With 64 key-value heads, one token in one layer stores numbers.
- With 8 key-value heads, it stores numbers.
- The cache is 8 times smaller, because 64 / 8 = 8 query heads share each key-value head.
The GRPO advantage for a group with rewards 1, 0, 0, 1 has mean 0.5 and standard deviation 0.5, so the advantages are . Responses that beat their group are reinforced and the rest are discouraged.
Try it: a query gets eight responses with rewards 1, 1, 1, 1, 0, 0, 0, 0. What are the advantages of a response with reward 1? Answer: the mean is 0.5 and the standard deviation is 0.5, so each reward-1 response has advantage .
Results
- Base models. The 72B base model scores 86.1 on MMLU against 85.2 for Llama-3-405B, and 62.1 on MATH against 50.9 for its predecessor Qwen2-72B. Its GSM8K score is 91.5 against 89.0 for Qwen2-72B.
- Limits in the same table. Llama-3-405B is ahead on HumanEval (61.0 against 59.1) and on WinoGrande (86.7 against 83.9). The base 72B model is not best on every task.
- Instruction models. The 72B instruction model is reported to surpass Llama-3.1-405B-Instruct on several benchmarks, including MMLU-redux, MATH and MBPP, although the 405B model has 405 billion parameters against 72 billion. The hosted Turbo model is compared with GPT-4o-mini and Plus with GPT-4o, and the paper reports both as competitive.
- Long context. Qwen2.5-Turbo handles up to 1 million tokens after the progressive extension and the inference-time methods YARN and DCA. The paper reports that these methods keep short-sequence quality.
- What the numbers mean. The results are the authors' own evaluations, mostly automatic, with n-gram decontamination against test sets. They show the recipe works across a wide benchmark set, not that the models are best on each task. Independent evaluation is needed for any single claim.
Reading guide
- Section 1, Introduction. Needs Instruction Tuning and Reinforcement Learning from Human Feedback (RLHF) to read the pipeline summary. The mixture-of-experts variants need Mixture of Experts.
- Section 2, Architecture and tokenizer. Needs Transformer, Grouped-Query Attention, Gated Linear Unit (GLU) for the feed-forward activation, Rotary Position Embedding, RMS Normalization and Subword Tokenization. Table 1 is the layer and head counts used in the math above.
- Section 3, Pre-training. Section 3.1 data needs Subword Tokenization. Section 3.2 scaling laws needs Neural Scaling Laws and Stochastic Gradient Descent. Section 3.3 long context needs Rotary Position Embedding and KV Cache.
- Section 4.1, Supervised fine-tuning. Needs Instruction Tuning and the rejection-sampling filter in Rejection Sampling.
- Section 4.2, Offline RL. Needs Direct Preference Optimization.
- Section 4.3, Online RL. Needs Reward Model, Group Relative Policy Optimization (GRPO) and Reinforcement Learning from Human Feedback (RLHF).
- Section 4.4 and 5, Long context and evaluation. Long-context fine-tuning uses the methods in section 3.3. The evaluation tables need the benchmark definitions, which the paper gives with their few-shot settings.