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:
- Expansion: The researchers took the 32-block LLaMA2-7B and inserted 8 new Transformer blocks, resulting in a 40-block, 8.3B parameter model.
- 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.
- 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.
- Interleaved Placement: New blocks were interleaved throughout the model rather than stacked at the end, preserving the hierarchical processing of the Transformer architecture.
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.
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