Baichuan 2: Open Large-scale Language Models

Aiyuan Yang, Bin Xiao, Bingning Wang, Borong Zhang, Ce Bian, Chao Yin, Chenxu Lv, Da Pan, Dian Wang, Dong Yan, Fan Yang, Fei Deng, Feng Wang, Feng Liu, Guangwei Ai, Guosheng Dong, Haizhou Zhao, Hang Xu, Haoze Sun, Hongda Zhang, Hui Liu, Jiaming Ji, Jian Xie, JunTao Dai, Kun Fang, Lei Su, Liang Song, Lifeng Liu, Liyun Ru, Luyao Ma, Mang Wang, Mickel Liu, MingAn Lin, Nuolan Nie, Peidong Guo, Ruiyang Sun, Tao Zhang, Tianpeng Li, Tianyu Li, Wei Cheng, Weipeng Chen, Xiangrong Zeng, Xiaochuan Wang, Xiaoxi Chen, Xin Men, Xin Yu, Xuehai Pan, Yanjun Shen, Yiding Wang, Yiyu Li, Youxin Jiang, Yuchen Gao, Yupeng Zhang, Zenan Zhou, Zhiying Wu

TL;DR

Baichuan 2 is a new generation of open-source large language models (7B and 13B parameters) trained from scratch on a massive 2.6 trillion tokens. By combining architectural optimizations like NormHead and Max-z loss with a heavy emphasis on multilingual data, these models match or outperform LLaMA 2 on general benchmarks and excel in specialized domains like medicine and law.

What Problem Does This Paper Address?

While the "LLM revolution" is in full swing, two major hurdles remain for the broader research community. First, the most capable models (like GPT-4 or Claude) are closed-source, leaving researchers in the dark about their inner workings. Second, existing open-source giants like LLaMA are predominantly English-centric, often failing to capture the nuances of other languages, particularly Chinese.

The Baichuan 2 project aims to democratize high-performance LLMs by providing a transparent, multilingual alternative. Crucially, the authors don't just release the final weights; they provide intermediate checkpoints, allowing researchers to study how these models actually learn over the course of trillions of tokens.

Methods

Baichuan 2 builds upon the standard Transformer architecture but introduces several key technical refinements to improve stability and performance:

  • Positional Embeddings: Interestingly, the authors use different approaches for different scales: RoPE (Rotary Positional Embedding) for the 7B model and ALiBi (Attention with Linear Biases) for the 13B model. This choice was made to facilitate research into how these different bias-based vs. multiplication-based attention mechanisms affect model behavior.
  • NormHead: The authors found that the norm of output embeddings (the "head") can become unstable during training. By normalizing these embeddings, they stabilized training dynamics and ensured the model focuses on cosine similarity for semantic encoding rather than L2 distance.
  • Max-z Loss: To prevent logits from exploding—which makes models overly sensitive to inference hyperparameters like repetition penalties—they added an auxiliary loss term ($L_{max-z} = 2e^{-4} * z^2$). This keeps the maximum logit value in check.
  • Activation: They utilize the SwiGLU activation function, a now-common variant that typically yields better results than standard ReLU.
  • Alignment: The models underwent a two-stage alignment process: Supervised Fine-Tuning (SFT) on 100k+ samples, followed by Reinforcement Learning from Human Feedback (RLHF) using the PPO algorithm.
Figure 5: An illustration of Baichuan 2’s RLHF process.

Datasets

The models were pre-trained on 2.6 trillion tokens, a significant increase over the 1.2T used for Baichuan 1.

  • Pre-training Corpus: A diverse mix of internet webpages, books, research papers, and code. The authors employed a sophisticated deduplication and clustering system to ensure high data quality (see Figure 2).
  • Evaluation Benchmarks: The models were tested on standard benchmarks including MMLU, GSM8K (math), and HumanEval (code).
  • Vertical & Multilingual Benchmarks: To test specific strengths, they used C-Eval and CMMLU (Chinese knowledge), MedQA (medicine), JEC-QA (Chinese law), and Flores-101 (multilingual translation).
  • Safety: The authors introduced the Baichuan Harmless Evaluation Dataset (BHED), covering seven major safety categories like financial privacy and mental health.
Figure 1: The distribution of different categories of Baichuan 2 training data.

Key Insights and Ideas

  • Data Quantity Matters: Even for smaller 7B models, performance continues to improve significantly as you scale from 1 trillion to 2.6 trillion tokens. The authors note that the 7B model hadn't even fully plateaued at the end of training.
  • Stability is Key: Techniques like NormHead and Max-z loss aren't just about final accuracy; they are essential for preventing "training spikes" and making the model more robust during real-world inference.
  • Vertical Excellence: By including high-quality domain-specific data, Baichuan 2 achieves a "clear performance advantage" in law and medicine compared to other open-source models, making it a strong candidate for specialized downstream applications.

Key Results

Baichuan 2 sets a new high bar for open-source models of its size:

  • General Performance: Baichuan 2-7B achieves nearly 30% higher performance than its predecessor on benchmarks like MMLU and CMMLU.
  • Math and Code: The improvements here are even more dramatic; the 7B model nearly doubles the scores of Baichuan 1 on GSM8K and HumanEval.
  • Comparison to LLaMA 2: Baichuan 2-13B outperforms LLaMA 2-13B across almost all major benchmarks, particularly in Chinese-language tasks and mathematical reasoning.
  • Training Dynamics: The released intermediate checkpoints show that while general knowledge (MMLU) starts to plateau, math problem-solving (GSM8K) continues to climb steadily with more FLOPs.
Figure 3: The pre-training loss of Baichuan 2.

Limitations and Future Work

Despite its strengths, the authors acknowledge several limitations:

  • Static Knowledge: Like all LLMs, the model's knowledge is frozen at the time of training and can become outdated.
  • Hallucinations and Bias: The model is still prone to generating incorrect information or reflecting biases present in its internet-sourced training data.
  • Language Balance: While excellent in Chinese and English, its performance in other languages is less optimized.
  • Safety Over-caution: The safety alignment process can sometimes make the model "over-cautious," refusing to answer benign prompts that tangentially relate to sensitive topics.

The team plans to continue optimizing these issues and releasing updated versions in the future.

Summary updated

BibTeX
@misc{yang2023baichuan,
  author = {Aiyuan Yang and Bin Xiao and Bingning Wang and Borong Zhang and Ce Bian and Chao Yin and Chenxu Lv and Da Pan and Dian Wang and Dong Yan and Fan Yang and Fei Deng and Feng Wang and Feng Liu and Guangwei Ai and Guosheng Dong and Haizhou Zhao and Hang Xu and Haoze Sun and Hongda Zhang and Hui Liu and Jiaming Ji and Jian Xie and JunTao Dai and Kun Fang and Lei Su and Liang Song and Lifeng Liu and Liyun Ru and Luyao Ma and Mang Wang and Mickel Liu and MingAn Lin and Nuolan Nie and Peidong Guo and Ruiyang Sun and Tao Zhang and Tianpeng Li and Tianyu Li and Wei Cheng and Weipeng Chen and Xiangrong Zeng and Xiaochuan Wang and Xiaoxi Chen and Xin Men and Xin Yu and Xuehai Pan and Yanjun Shen and Yiding Wang and Yiyu Li and Youxin Jiang and Yuchen Gao and Yupeng Zhang and Zenan Zhou and Zhiying Wu},
  title = {{Baichuan 2: Open Large-scale Language Models}},
  year = {2023},
  eprint = {2309.10305},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2309.10305},
}
Figure