Abstract
Adapting Large Language Models (LLMs) to new languages often leads to "catastrophic forgetting," where the model loses proficiency in its original training domains. This paper, presented at EMNLP 2024, introduces Branch-and-Merge (BAM), an iterative training strategy that mitigates this issue. BAM decomposes the training process into parallel branches trained on distinct data slices, which are subsequently merged. This approach produces higher-quality weight updates that effectively learn new target languages (e.g., Bulgarian, German) while preserving original capabilities like English reasoning and coding. Our results show that BAM-trained models outperform standard continued pretraining in both language transfer and instruction-following tasks.
Introduction
The process of "Language Transfer"—fine-tuning a state-of-the-art English LLM on a new language—is a common practice for localizing AI. However, it frequently triggers catastrophic forgetting. A model might gain fluency in Bulgarian but simultaneously lose its ability to solve complex mathematical problems or write Python code in English.
Current mitigation strategies often rely on "experience replay," where a portion of the original English training data is mixed into the new dataset. While helpful, this does not address the fundamental issue: aggressive training updates can shift a model's internal representations too far from their optimized state. The challenge lies in updating weights sufficiently to master a new language without "overwriting" the model's foundational intelligence.
Methodology: Branch-and-Merge (BAM)
The core contribution of this work is the Branch-and-Merge (BAM) algorithm. Rather than training a model on a single, continuous stream of data, BAM adopts an iterative, parallelized approach.
The process consists of four primary stages:
- Slicing: The target training data is partitioned into $N$ discrete slices.
- Branching: In each iteration, the current base model is replicated into $K$ independent branches. Each branch undergoes training on a different data slice.
- Merging: The weights from these $K$ branches are merged back into a single unified model. The authors utilize techniques such as Spherical Linear Interpolation (SLERP) or Linear Averaging for this step.
- Iterating: The resulting merged model serves as the initialization for the subsequent iteration of branching and training.
The Intuition: Navigating the Loss Landscape
The effectiveness of BAM stems from its ability to filter out "noise" inherent in individual training runs. Training on a single data slice might drive a model toward a local minimum that optimizes for that specific data but degrades general knowledge. By merging parallel branches, these divergent "errors" tend to cancel out.
As illustrated in the loss landscape visualization, individual branches ($\theta_1, \theta_2$) may move toward different regions. Merging them ($\theta'_{1,2}$) pulls the model into the "valley"—a more stable region that maintains low loss for both the new target data and the original source data. This results in weight changes that are smaller in total magnitude but significantly higher in quality.
Experimental Setup and Datasets
The authors evaluated BAM across two language transfer scenarios:
- English to German: A scenario involving alphabet-sharing.
- English to Bulgarian: A more challenging non-alphabet-sharing scenario.
The training utilized a mix of target language data (e.g., 82B tokens for Bulgarian) and "Approximate Experience Replay" data, which included English Wikipedia, GitHub repositories, and instruction sets like SlimOrca. Performance was measured using standard benchmarks (MMLU, GSM8K) and MON-Tests, a novel benchmark derived from native Bulgarian high school examinations.
Key Results and Insights
Testing on Mistral-7B and Llama-3-8B yielded several critical findings:
- Superior Performance: BAM-trained Llama-3-8B outperformed standard continued pretraining by 1.7% on English benchmarks while maintaining or exceeding Bulgarian proficiency.
- Instruction Tuning Excellence: In instruction fine-tuning, BAM-trained Llama-3-8B surpassed the official Llama-3-8B-Instruct by 10.9% in Bulgarian and 1.3% in English.
- Weight Efficiency: BAM produces smaller total weight changes than standard methods. This suggests that standard fine-tuning is often unnecessarily "loud," and that high-quality, smaller updates are more effective for preserving knowledge.
- Curriculum Slicing: The strategy is most effective when data is sliced by language (e.g., one branch for Bulgarian, one for English), fostering a "specialization and consensus" dynamic.
Limitations and Future Work
While promising, BAM has limitations. The study focused on models up to 8B parameters; further research is needed to confirm if these benefits scale to 70B+ parameter models. Additionally, while branches can be trained in parallel, the total computational hours are higher than sequential training. Future work may explore more sophisticated merging strategies or apply BAM to specialized domain adaptation, such as medical or legal fine-tuning.
Summary updated