LLaMA Pro: Progressive LLaMA with Block Expansion

Chengyue Wu, Yukang Gan, Yixiao Ge, Zeyu Lu, Jiahao Wang, Ye Feng, Ping Luo, Ying Shan · DOI

Abstract

LLaMA Pro introduces a novel "block expansion" method to enhance pre-trained Large Language Models (LLMs) with specialized knowledge without compromising their general-purpose capabilities. By expanding the architecture of LLaMA2-7B with additional Transformer blocks initialized as identity mappings and freezing the original weights during post-pretraining, the authors developed LLaMA Pro-8.3B. This model achieves superior performance across general reasoning, mathematics, and programming benchmarks, effectively overcoming the challenge of catastrophic forgetting and shifting the Pareto frontier for model specialization.

The Challenge of Catastrophic Forgetting

A significant hurdle in fine-tuning Large Language Models (LLMs) is catastrophic forgetting. When a general-purpose model like LLaMA2 is further trained on a specific domain—such as programming code or advanced mathematics—it often gains expertise in that area at the expense of its original reasoning and natural language capabilities. For instance, while CodeLLaMA excels at Python, it performs significantly worse than the base LLaMA2 on general knowledge tasks like MMLU.

Existing solutions, such as Low-Rank Adaptation (LoRA) or full fine-tuning, often struggle to balance this trade-off. LLaMA Pro proposes a method to "inject" new knowledge into a model while keeping its foundational "brain" intact, allowing the model to grow progressively.

Methodology: Progressive Block Expansion

The core innovation of this work is Block Expansion. Rather than tuning existing weights, the researchers expanded the model architecture through a four-step process:

  1. Expansion: The researchers took the 32-block LLaMA2-7B and inserted 8 new Transformer blocks, resulting in a 40-block, 8.3B parameter model.
  2. Identity Initialization: To ensure the model remained stable at the start of training, new blocks were initialized as identity mappings. By zero-initializing the output linear layers in these new blocks, the model's initial output remained identical to the original 7B model.
  3. Frozen Backbone: During the post-pretraining phase on specialized code and math data, the original 32 blocks were frozen. Only the 8 new blocks were trained, forcing them to learn the specialized "delta" of knowledge required for the new domains.
  4. Interleaved Placement: New blocks were interleaved throughout the model rather than stacked at the end, preserving the hierarchical processing of the Transformer architecture.
The Block Expansion pipeline compared to standard pre-training.

Experimental Setup and Datasets

The model underwent post-pretraining on 80 billion tokens consisting of high-quality code (Python split of Stack-dedup) and mathematics (Proof-pile-2). Following this, Instruction Tuning (SFT) was performed using a mix of approximately 1 million samples from diverse datasets including ShareGPT, WizardLM, SlimOrca, MetaMath, and Evol-CodeAlpaca.

Evaluation was conducted across a massive suite of benchmarks, including general reasoning (MMLU, ARC, HellaSwag), mathematics (GSM8K), coding (HumanEval, MBPP), and agent-centric tasks (MT-Bench, MINT-Bench).

Results and the Pareto Frontier

LLaMA Pro-8.3B and its instruction-tuned variant, LLaMA Pro-Instruct, delivered impressive results across the board:

  • General vs. Specialized Performance: LLaMA Pro-Instruct achieved an average score of 53.85 across all tasks, significantly higher than LLaMA2-7B-Chat (40.04) and CodeLLaMA-7B-Instruct (39.35).
  • Coding Excellence: On HumanEval, LLaMA Pro-Instruct scored 44.51%, nearly tripling the performance of the base LLaMA2-7B-Chat (14.63%).
  • Agent Capabilities: In the MINT-Bench, which tests tool use and multi-turn reasoning, LLaMA Pro-Instruct outperformed Mistral-7B and other models of similar size.
Comparison of general language vs. code performance across various models, illustrating the shifted Pareto frontier.

As shown in the performance analysis, LLaMA Pro effectively shifts the Pareto frontier. While specialized models like CodeLLaMA typically sacrifice general ability for code, LLaMA Pro improves in both directions simultaneously. This efficiency is achieved because only a fraction of the parameters are tuned during post-pretraining, resulting in lower computational overhead than full-parameter fine-tuning.

Conclusion and Future Directions

LLaMA Pro demonstrates that block expansion is a viable path for the progressive evolution of LLMs. While currently limited to text and code in English, the authors suggest this method could be applied to multimodal models—such as adding vision capabilities—in the future. The success of the 7B to 8.3B expansion opens new questions regarding the scaling limits of how many blocks can be added before performance plateaus.

The code and models have been open-sourced to facilitate further research into progressive model growth.

Summary updated

Abstract

Humans generally acquire new skills without compromising the old; however, the opposite holds for Large Language Models (LLMs), e.g., from LLaMA to CodeLLaMA. To this end, we propose a new post-pretraining method for LLMs with an expansion of Transformer blocks. We tune the expanded blocks using only new corpus, efficiently and effectively improving the model's knowledge without catastrophic forgetting. In this paper, we experiment on the corpus of code and math, yielding LLaMA Pro-8.3B, a versatile foundation model initialized from LLaMA2-7B, excelling in general tasks, programming, and mathematics. LLaMA Pro and its instruction-following counterpart (LLaMA Pro-Instruct) achieve advanced performance among various benchmarks, demonstrating superiority over existing open models in the LLaMA family and the immense potential of reasoning and addressing diverse tasks as an intelligent agent. Our findings provide valuable insights into integrating natural and programming languages, laying a solid foundation for developing advanced language agents that operate effectively in various environments.
BibTeX
@inproceedings{wu2024llama,
  author = {Chengyue Wu and Yukang Gan and Yixiao Ge and Zeyu Lu and Jiahao Wang and Ye Feng and Ping Luo and Ying Shan},
  title = {{LLaMA Pro: Progressive LLaMA with Block Expansion}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.352},
}
Figure