# Qwen2 Technical Report

Qwen2 releases open models from 0.5 to 72 billion parameters that rival proprietary systems

An Yang, Baosong Yang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Zhou and 56 more · arXiv · 2024-7-15

- **Problem** Open-weight models already compete with GPT-4-level systems, so a new family must cover both phone-sized and large GPU deployments. Earlier releases did not match proprietary systems across language, coding and math benchmarks.
- **Method** Qwen2 is a family of dense and Mixture-of-Experts language models. It uses grouped query attention and Dual Chunk Attention with YARN for long inputs, then aligns the models with SFT, DPO and online RLHF.
- **Results** Qwen2-72B scores 84.2 on MMLU as a base model. That is 4.7 points above Llama-3-70B under the paper's setup.

## Why one family spans so many sizes

By the time Qwen2 was prepared, Llama-3 was widely treated as the leading open-weight series and as roughly GPT-4-level, which raised the bar for any new open release. The two smallest sizes are aimed at phones, earphones and smart glasses, while the larger ones are meant for GPUs of different scales.

## Attention and feed-forward changes in the dense models

Grouped Query Attention lets several query heads share one key-value head, which reduces the KV cache that must be kept during inference. The head counts in the configuration table show this concretely: the 0.5B model has 14 query heads sharing 2 KV heads, and the 72B model has 64 query heads sharing 8. Dual Chunk Attention splits a long input into chunks, and when the input fits in one chunk it gives the same result as ordinary attention; across chunks it still models relative positions.

YARN is applied on top of this to rescale attention weights so the model can extrapolate beyond its training length. The dense blocks also keep SwiGLU activations, RoPE positional embeddings, QKV bias, RMSNorm and pre-normalization, which the authors use for training stability.

## How the MoE layer routes and initialises experts

A gate computes scores for each token, a softmax turns them into weights p, and the layer output is the weighted sum of the top-k experts' outputs, written as \\( y=\\sum\_{i\\in \\mathrm{topk}(p)} p\_i E\_i(x) \\). Qwen2 departs from the common recipe of taking each expert as a full copy of the dense FFN, as Mixtral 8x7B does with two of its eight experts active; instead it uses smaller fine-grained experts and activates more of them at once.

At equal total and activated expert parameters, the authors argue that fine-grained experts give a richer set of expert combinations. The routing also combines shared experts that every token uses with routed experts that are chosen per token; the 57B-A14B model has 64 routed experts, 8 activated experts and 8 shared experts.

Initialisation follows the spirit of upcycling but spreads the dense weights more widely: the FFN is replicated the ceiling of n times h\_E divided by h\_FFN times, where n is the number of experts, h\_E the expert intermediate size and h\_FFN the original FFN intermediate size. Parameters are shuffled along the intermediate dimension in each copy, and then 50% of each fine-grained expert's parameters are randomly reinitialised.

Qwen2-57B-A14B is upscaled from Qwen2-7B, so the MoE model starts from a dense checkpoint rather than from scratch.

## Pre-training data scale and mix

Compared with Qwen1.5, the new corpus enlarges code, mathematics and multilingual data and is built with model-based filtering and model-generated synthetic text. The total grew from 3 trillion tokens in Qwen1.5 to 7 trillion tokens, and a 12 trillion token variant with a relaxed quality threshold did not clearly improve the 7 trillion token model.

The authors chose the 7 trillion token set for the larger models, and Qwen2-0.5B was trained on the 12 trillion token set, while the MoE model received an extra 4.5 trillion tokens.

## Raising the context length from 4,096 to 32,768 tokens

In the concluding phase of pre-training the context length was raised from 4,096 to 32,768 tokens, and longer high-quality documents were added. The RoPE base frequency was raised from 10,000 to 1,000,000, a change the authors tie to better behaviour in long-context settings. YARN and Dual Chunk Attention then let the model process sequences of up to 131,072 tokens, and the authors report minimal perplexity degradation in preliminary experiments.

## From demonstrations to preference optimisation

Demonstration data pairs an instruction with a satisfactory response, while preference data pairs an instruction with a preferred and a dispreferred response; SFT uses the first and RLHF uses the second. Instructions are first tagged with InsTag to extract an ontology, then selected by tag diversity and complexity, and evolved with added constraints.

Automated synthesis adds rejection sampling for problems with definite answers, execution feedback for code and a Python check for constraint following, and constitutional feedback for safety.

Offline RLHF maximises the likelihood gap between preferred and dispreferred responses with DPO on a fixed preference set, and the online stage samples from the current policy, lets a reward model pick the most and least preferred responses, and applies DPO again. The Online Merging Optimizer is used in the online stage to reduce the alignment tax, which the authors define as the performance drop caused by aligning with human preferences.

## Base model results against open-weight baselines

Base models were evaluated with few-shot prompting unless a benchmark specifies otherwise, and MMLU uses five shots. Qwen2-72B reached 84.2 on MMLU against 79.5 for Llama-3-70B, a gap of 4.7 points, and 55.6 on MMLU-Pro against 52.8, a gap of 2.8 points. Its advantage on the scientific and coding sets is larger on some tasks: Theorem QA rises by 9.8 points over Llama-3-70B, and HumanEval reaches 64.6 with an 18.3-point gain over Qwen1.5-72B.

For the 7B class, Qwen2-7B scored 70.3 on MMLU against 66.6 for Llama-3-8B, and 51.2 on HumanEval against 33.5. Qwen2-57B-A14B is described as performing comparably to Yi-1.5-34B on natural language understanding and as ahead of the listed baselines on coding and mathematics, which is the basis for the authors' claim that it matches a 30 billion parameter dense model.

Among the smaller sizes, Qwen2-1.5B reaches 56.5 on MMLU against 52.7 for Phi-2, while the table shows Phi-2 ahead on several reasoning-oriented sets.

## Instruction-tuned results and where they fall short

Against the listed instruction-tuned baselines it leads on most language understanding, coding and mathematics sets, but it does not lead on GPQA or MBPP.

Qwen2-7B-Instruct reaches 79.9 on HumanEval against 62.2 for Llama-3-8B-Instruct, but its IFEval strict-prompt score of 54.7 is well below the 72.1 of that baseline. For the smaller models, Qwen2-1.5B-Instruct reaches 52.4 on MMLU against 43.7 for Qwen1.5-1.8B-Chat.

The authors attribute the English gap to the amount of English pre-training tokens and to the scale and diversity of post-training data.

## Long-context retrieval up to 128K tokens

The Needle in a Haystack test places facts at varying depths in texts from 8K to 128K tokens, with two instances per depth interval, and YARN is applied for contexts above 32K. Qwen2-72B-Instruct retrieves facts accurately across the full 128K context, Qwen2-7B-Instruct handles up to 128K, Qwen2-57B-A14B up to 64K, and the two smallest models up to 32K.

NeedleBench places two to five facts in a passage and requires multi-hop reasoning over them, and the authors report that adding YARN and DCA notably improves Qwen2 on it and on LV-Eval. Qwen2-72B-Instruct drops 6 points on NeedleBench as context grows, while ChatGLM4-9B-1M drops 11 points from a lower starting accuracy. For LV-Eval the authors replace the original stringent metric with keyword recall, and Qwen2-7B-Instruct reaches parity with ChatGLM4-9B-1M while declining more at longer lengths.

## Human multilingual scores and safety rejection rates

Each language has one professional annotator who grades responses from 1 to 5. Qwen2-72B-Instruct averages 3.93, against 3.16 for GPT-3.5-Turbo, 3.98 for GPT-4-Turbo, 4.09 for GPT-4o and 4.15 for Claude-3-Opus, so it is well above GPT-3.5-Turbo and close to the stronger proprietary systems.

On the jailbreak-oriented safety set, where a lower proportion of harmful responses is better, Qwen2-72B-Instruct's pornography score is 22.91 against 23.63 for GPT-4 and 33.82 for Mixtral-8x22B-Instruct. The authors still judge that the model has much room to improve in this category, which they say is hard to classify even for humans.

## Whether scores survive decontamination

Plain n-gram matching was first used to exclude contaminated training data, but it may miss many cases in mathematics and code because common expressions match. A longest-common-subsequence rule was added: after stripping symbols and punctuation, a training sequence is removed when some test sequence shares a common subsequence of at least 13 with it and at least 0.6 times the length of the shorter sequence.

For HumanEval, 75.0% of samples are contaminated, and Qwen2-72B-Instruct scores 86.0 on the original set and 87.0 on the non-contaminated set.

## Limitations

Instruction following is the clearest weakness of the 7B instruction model, with IFEval at 54.7 against 72.1 for Llama-3-8B-Instruct, and the authors plan to address it through better post-training data. On the Chinese in-house benchmark the MoE model trails Qwen1.5-32B-Chat on knowledge understanding, which the authors may attribute to fewer pre-training tokens; they state this as a possibility rather than a finding.

Safety performance is still weak in the pornography category, and the Qwen2-72B-Instruct score of 22.91 is only slightly better than GPT-4's 23.63. The needle retrieval test stops at 128K tokens, so behaviour at longer inputs was not measured in this evaluation. Human multilingual evaluation uses a single annotator per language, and the decontamination of n-gram matching may miss many overlaps.

## Paper info

- **Authors**: An Yang, Baosong Yang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Zhou, Chengpeng Li, Chengyuan Li, Dayiheng Liu, Fei Huang, Guanting Dong, Haoran Wei, Huan Lin, Jialong Tang, Jialin Wang, Jian Yang, Jianhong Tu, Jianwei Zhang, Jianxin Ma, Jianxin Yang, Jin Xu, Jingren Zhou, Jinze Bai, Jinzheng He, Junyang Lin, Kai Dang, Keming Lu, Keqin Chen, Kexin Yang, Mei Li, Mingfeng Xue, Na Ni, Pei Zhang, Peng Wang, Ru Peng, Rui Men, Ruize Gao, Runji Lin, Shijie Wang, Shuai Bai, Sinan Tan, Tianhang Zhu, Tianhao Li, Tianyu Liu, Wenbin Ge, Xiaodong Deng, Xiaohuan Zhou, Xingzhang Ren, Xinyu Zhang, Xipin Wei, Xuancheng Ren, Xuejing Liu, Yang Fan, Yang Yao, Yichang Zhang, Yu Wan, Yunfei Chu, Yuqiong Liu, Zeyu Cui, Zhenru Zhang, Zhifang Guo, Zhihao Fan
- **Venue**: arXiv · Preprint
- **First published**: 2024-7-15
- **Added**: 2026-11-12
- **Updated**: 2024-9-10
- **Version**: v4
- **arXiv**: 2407.10671
- **Category**: cs.CL · cs.AI
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/2407.10671v4) · [PDF ↗](https://arxiv.org/pdf/2407.10671v4)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

An Yang, Baosong Yang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Zhou, Chengpeng Li, Chengyuan Li, Dayiheng Liu, Fei Huang, Guanting Dong, Haoran Wei, Huan Lin, Jialong Tang, Jialin Wang, Jian Yang, Jianhong Tu, Jianwei Zhang, Jianxin Ma, Jianxin Yang et al. (2024). Qwen2 Technical Report. arXiv:2407.10671v4. https://arxiv.org/abs/2407.10671v4

**BibTeX**

```
@misc{yang2024qwen2,
  title = {{Qwen2 Technical Report}},
  author = {An Yang and Baosong Yang and Binyuan Hui and Bo Zheng and Bowen Yu and Chang Zhou and Chengpeng Li and Chengyuan Li and Dayiheng Liu and Fei Huang and Guanting Dong and Haoran Wei and Huan Lin and Jialong Tang and Jialin Wang and Jian Yang and Jianhong Tu and Jianwei Zhang and Jianxin Ma and Jianxin Yang and Jin Xu and Jingren Zhou and Jinze Bai and Jinzheng He and Junyang Lin and Kai Dang and Keming Lu and Keqin Chen and Kexin Yang and Mei Li and Mingfeng Xue and Na Ni and Pei Zhang and Peng Wang and Ru Peng and Rui Men and Ruize Gao and Runji Lin and Shijie Wang and Shuai Bai and Sinan Tan and Tianhang Zhu and Tianhao Li and Tianyu Liu and Wenbin Ge and Xiaodong Deng and Xiaohuan Zhou and Xingzhang Ren and Xinyu Zhang and Xipin Wei and Xuancheng Ren and Xuejing Liu and Yang Fan and Yang Yao and Yichang Zhang and Yu Wan and Yunfei Chu and Yuqiong Liu and Zeyu Cui and Zhenru Zhang and Zhifang Guo and Zhihao Fan},
  year = {2024},
  eprint = {2407.10671},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.10671v4}
}
```

## Other paper commentary

- [OPT: Open Pre-trained Transformer Language Models](https://refivu.com/en/papers/dd696b35-00bf-4198-8591-a1a5b74fa7d4-opt-open-pre-trained-transformer-language-models.md)
- [Program Synthesis with Large Language Models](https://refivu.com/en/papers/91ec5a25-4d41-4e97-96c5-09d1f9e9480e-program-synthesis-with-large-language-models.md)
- [A Survey on Hallucination in Large Language Models: Principles, Taxonomy, Challenges, and Open Questions](https://refivu.com/en/papers/c1cfd3a7-67eb-4e85-ad04-a8242f75f562-a-survey-on-hallucination-in-large-language-models.md)
- [Qwen3-VL Technical Report](https://refivu.com/en/papers/a9ce03f9-9079-45df-9644-3195f785065b-qwen3-vl-technical-report.md)
- [Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena](https://refivu.com/en/papers/beb0d651-5eaa-425c-8bf2-ee14db24b3b0-judging-llm-as-a-judge-with-mt-bench.md)
- [Sparks of Artificial General Intelligence: Early experiments with GPT-4](https://refivu.com/en/papers/bf8f04ae-6d95-4b81-8fa4-4c3f7fdcc547-sparks-of-artificial-general-intelligence-early-experiments.md)
- [Efficient Processing of Deep Neural Networks: A Tutorial and Survey](https://refivu.com/en/papers/587cab8c-6795-4edf-94db-5f485a9b553b-efficient-processing-of-deep-neural-networks-a-tutorial.md)
- [Bidirectional LSTM-CRF Models for Sequence Tagging](https://refivu.com/en/papers/7f421939-0d02-43b3-b25f-86a13896fd18-bidirectional-lstm-crf-models-for-sequence-tagging.md)
- [A Random Forest Guided Tour](https://refivu.com/en/papers/6b2074eb-032d-4248-8e6a-fa64485f867d-a-random-forest-guided-tour.md)
- [UNet++: Redesigning Skip Connections to Exploit Multiscale Features in Image Segmentation](https://refivu.com/en/papers/5be5e543-8f10-4ce6-ae1e-1194b9773c52-unet-redesigning-skip-connections-to-exploit-multiscale.md)
- [High-Resolution Image Synthesis and Semantic Manipulation with Conditional GANs](https://refivu.com/en/papers/ad89d7a4-6049-4da7-8901-5fe971c7ff30-high-resolution-image-synthesis-and-semantic-manipulation.md)
- [Learning Transferable Features with Deep Adaptation Networks](https://refivu.com/en/papers/97cc84e7-8caf-4096-8372-c2986f3dff12-learning-transferable-features-with-deep-adaptation-networks.md)

## Terms in this paper

- [GSM8K](https://refivu.com/en/terms/e48f0e01064d-gsm8k)
- [MMLU](https://refivu.com/en/terms/3036c0ba5adb-mmlu)
- [HumanEval](https://refivu.com/en/terms/3c3dbcadfdda-humaneval)
- [supervised fine-tuning](https://refivu.com/en/terms/1a2c1f079517-supervised-fine-tuning)
- [RMSNorm](https://refivu.com/en/terms/9b1cafd281f0-rmsnorm)
- [SwiGLU](https://refivu.com/en/terms/9b64288c190e-swiglu)
- [Direct Preference Optimization](https://refivu.com/en/terms/81ed2010f707-direct-preference-optimization)
- [Rejection Sampling](https://refivu.com/en/terms/40f65d094f14-rejection-sampling)
- [reinforcement learning from human feedback](https://refivu.com/en/terms/1ea6c6d70955-reinforcement-learning-from-human-feedback)
- [transformer architecture](https://refivu.com/en/terms/30726b29c2c5-transformer-architecture)
- [IFEval](https://refivu.com/en/terms/da319c218f51-ifeval)
- [BBH](https://refivu.com/en/terms/01f777eaca51-bbh)
- [Grouped Query Attention](https://refivu.com/en/terms/a767540ddcc5-grouped-query-attention)
- [Rotary Positional Embeddings](https://refivu.com/en/terms/9694a7d9bff1-rotary-positional-embeddings)
- [Arena-Hard](https://refivu.com/en/terms/73f051c9dfee-arena-hard)
- [longest common subsequence](https://refivu.com/en/terms/b0a5cd89a6bb-longest-common-subsequence)
- [MT-Bench](https://refivu.com/en/terms/0cad66f1f433-mt-bench)
- [13-gram overlap](https://refivu.com/en/terms/ec3165f23fd1-13-gram-overlap)
- [keyword recall](https://refivu.com/en/terms/f1836d3149e5-keyword-recall)
- [Needle in a Haystack](https://refivu.com/en/terms/af6fdf647f90-needle-in-a-haystack)
- [Online Merging Optimizer](https://refivu.com/en/terms/2e3fe1b69379-online-merging-optimizer)
- [YARN](https://refivu.com/en/terms/3110363f5fbc-yarn)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/edc7be28-5a87-45ae-afa8-a9b7e9819cd7-qwen2-technical-report)
