Layer Swapping for Zero-Shot Cross-Lingual Transfer in Large Language Models

Lucas Bandarkar, Benjamin Muller, Pritish Yuvraj, Rui Hou, Nayan Singhal, Hongjiang Lv, Bing Liu

TL;DR

Layer Swapping is a simple, post-hoc model merging technique that transfers complex reasoning capabilities (like math) from an English-trained model to lower-resource languages. By replacing the top and bottom layers of a math-expert model with those of a target-language expert, the method improves multilingual math performance by 10% on average without requiring any task-specific data in the target language.

What Problem Does This Paper Address?

Building Large Language Models (LLMs) that excel at specialized reasoning tasks—such as mathematics—in non-English languages is incredibly difficult due to a severe shortage of high-quality, task-specific training data. While modern open-source base models see trillions of non-English tokens during pretraining, their post-training instruction data remains heavily English-centric.

Standard workarounds, like machine-translating English datasets into target languages, introduce high computational overhead and often result in noisy, unreliable data. Consequently, cross-lingual transfer—where a model applies reasoning learned in English to another language—is often weak. The authors address this gap by asking: Can we combine a model that knows math (in English) with a model that knows a target language (but not math) completely post-hoc, without any additional training?

Methods

The authors introduce Layer Swapping, a fully post-hoc model merging strategy that requires no additional training cycles.

  1. Expert Training: Starting from a shared base model (LLAMA 3.1 8B), they fine-tune two separate variants or "experts": a math expert trained on English math word problems, and a language expert trained on generic instruction data in a target language (with no math content).
  2. Parameter Analysis: By analyzing the weight changes (deltas) after supervised fine-tuning (SFT), they observed a striking pattern: language-specific updates are heavily concentrated in the very first and very last transformer layers (input/output mapping), whereas math reasoning updates reside primarily in the middle and upper-middle layers.
  3. Layer Swapping: Based on this insight, they compose a new model by taking the middle layers directly from the math expert and replacing the top and bottom layers with those from the language expert. They also introduce a "transition zone" where the boundary layers are a weighted average of both experts to smooth out latent representations.
Figure 1: Our merging method which swaps in top and bottom transformer layers from a language expert into a math expert, buffered by a transition zone.

Datasets

  • Math Training: Orca-Math (a synthetic dataset of 200k English math word problems).
  • Language Training: Generic instruction and translation datasets for Swahili, Bengali, Telugu, and Japanese (including the Aya Dataset, NLLB translation data, IndicShareLlama, BongChat, Inkuba, xP3 MT, LLM-Japanese, Ichikara, and Dolly).
  • Evaluation: MGSM (Multilingual Grade School Math benchmark, evaluated via 8-shot prompting), BELEBELE (reading comprehension), FLORES (translation), MBPP (coding), and MMLU (general knowledge).

Key Insights and Ideas

  • The "English Thinking" Hypothesis: English-centric LLMs process multilingual text by mapping inputs into an internal English representation space in the initial layers, performing core reasoning in English through the middle layers, and mapping back to the target language in the final layers. Layer Swapping directly exploits this structural modularity.
  • Localization of Skills: Reasoning capabilities and language capabilities are structurally separable within the transformer architecture.
  • Layer-Level vs. Weight-Level Merging: Keeping entire layers intact preserves the structural integrity of the learned transformations. Granular weight-averaging techniques (like model souping or TIES-merging) can cause destructive interference and disrupt linear dependencies within weight tensors.

Key Results

  • On the MGSM benchmark, Layer Swapping consistently outperformed the base model, individual experts, and standard model souping by an average of 10% across four major target languages (Swahili, Telugu, Bengali, Japanese).
  • For Swahili, the layer-swapped model achieved a maximum score of 37.2%, outperforming a model trained jointly from scratch on a combined dataset of Swahili and math data (32.8%).
  • Unlike other merging methods that cause massive performance drops on non-target languages, Layer Swapping maintained solid performance on English math tasks while boosting target language capabilities.

Limitations and Future Work

  • Pre-freezing vs. Post-hoc: A logical alternative would be freezing specific layers during training, though this sacrifices the post-hoc flexibility of layer swapping.
  • Pretraining Bias: The method relies heavily on the fact that LLAMA 3.1 is English-centric. It remains to be seen if layer swapping works on models with more balanced multilingual pretraining.
  • Scale and Architecture: The experiments were limited to 32-layer 8B models; larger models or different architectures will require re-tuning the optimal swap configurations (e.g., determining exactly how many layers to swap).
  • Generalization to Other Tasks: The paper focuses strictly on mathematical reasoning. Future work is needed to see if other complex skills (like coding or multi-hop reasoning) exhibit similar layer-level separability.

Summary updated

BibTeX
@inproceedings{bandarkar2025layer,
  author = {Lucas Bandarkar and Benjamin Muller and Pritish Yuvraj and Rui Hou and Nayan Singhal and Hongjiang Lv and Bing Liu},
  title = {{Layer Swapping for Zero-Shot Cross-Lingual Transfer in Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=vQhn4wrQ6j},
}
Figure