TL;DR
BAR (Branch-Adapt-Route) is a modular framework for extending post-trained language models by training independent domain experts and merging them into a Mixture-of-Experts (MoE) architecture. This approach achieves performance comparable to full retraining while reducing the computational cost of updates from quadratic to linear and effectively eliminating the "catastrophic forgetting" that plagues sequential fine-tuning.
What Problem Does This Paper Address?
Modern language models (LMs) are rarely "finished." Developers constantly need to add new capabilities (e.g., better coding, tool use) or update existing ones with higher-quality data. Traditionally, this is done in one of two ways:
- Retraining from scratch: Mixing all old and new data. This is prohibitively expensive and scales poorly as the number of domains grows.
- Continued training (Fine-tuning): Updating an existing model on new data. This often leads to catastrophic forgetting, where the model loses earlier skills (like safety or general chat) while learning new ones (like math).
Furthermore, recent research suggests that "mid-training" (domain-specific pre-training) is essential for complex reasoning, but incorporating it into a fully post-trained model is non-trivial. The authors aim to find a way to add these "heavyweight" capabilities modularly without breaking the base model or breaking the bank.
Methods
The authors introduce BAR (Branch-Adapt-Route), which follows a three-stage process:
- Branch & Independent Expert Training: For every new domain (e.g., Math), a separate "expert" is created. This expert is initialized as a 2-expert MoE: one "anchor" expert (the original frozen model) and one "domain" expert. The domain expert undergoes its own full pipeline: mid-training (annealing), supervised fine-tuning (SFT), and reinforcement learning with verifiable rewards (RLVR).
- Merge: Once trained, these independent experts are combined into a single multi-expert MoE. Shared parameters (like attention layers) that were unfrozen during RL are averaged across the experts.
- Route: A lightweight router is trained on a small, stratified sample of SFT data (only 5% of the total dataset) to learn which expert to activate for a given input token.
A critical technical insight in BAR is the progressive unfreezing of shared layers. While prior modular pre-training work suggested freezing everything except the Feed-Forward Networks (FFNs), BAR finds that post-training requires adapting attention patterns and handling new tokens (like <thinking>). Consequently, they unfreeze embeddings during SFT and all parameters during RL.
Datasets
The researchers used OLMo 2 (7B) as their initial model and extended it with four domains:
- Math: Mid-training on Dolmino Math and FineMath; SFT from Tulu 3; RLVR using OLMo 3 reward data.
- Code: Mid-training on StarCoder/OLMo 3 code data; SFT from Tulu 3; RLVR from OLMo 3.
- Tool Use: SFT only, using Dolci tool use data.
- Safety: SFT only, using CoCoNot, WildGuardMix, and WildJailbreak.
Evaluation was conducted across 19 benchmarks spanning seven categories: Chat (AlpacaEval, IFEval), Knowledge (MMLU, PopQA), Reasoning (BBH, GPQA), Math (MATH, GSM8K), Code (HumanEval+, MBPP+), Tool Use (BFCL), and Safety (HarmBench, WildGuard).
Key Insights and Ideas
- Linear vs. Quadratic Scaling: In a monolithic setup, adding a 5th domain requires retraining all 5 domains. In BAR, you only train the 5th expert and the router. This shifts the cost curve from quadratic to linear.
- Structural Isolation: By isolating the training pipelines, BAR prevents "interference." For example, the aggressive RL needed to make a model great at Math often makes it less safe or worse at Chat. In BAR, the Math RL only affects the Math expert, leaving the Safety expert's weights untouched.
- Post-Training is Different: The paper highlights that modular strategies for pre-training don't translate directly to post-training. The need to handle behavioral shifts and new special tokens makes unfreezing shared layers a requirement, not an option.
- Modular Upgrades: The authors demonstrated that you can "swap out" a v1 Code expert for a v2 Code expert (trained on better data) without touching the Math or Safety experts, and the overall model improves accordingly.
Key Results
BAR achieves a state-of-the-art balance between performance and modularity:
- Overall Performance: BAR (5x7B) achieved an overall score of 49.1, significantly beating continual post-training (45.3) and retraining without mid-training (47.8). It nearly matched the "gold standard" of full retraining with mid-training (50.5), which is far more expensive.
- Expert Interference: As shown in Table 2, adding new experts (like Tool Use and Safety) improved the overall score without degrading the performance of previously added experts (Math and Code).
Limitations and Future Work
- Inference Cost: While activation is sparse (MoE), the total number of parameters grows linearly with each expert, which increases the memory footprint for deployment.
- Base Model Dependency: Currently, if the underlying "anchor" model (the base 7B transformer) is significantly upgraded, all domain experts must be retrained to match the new base weights.
- Routing Efficiency: The authors suggest that moving toward finer-grained experts (rather than one giant expert per domain) could allow for even sparser activation and lower inference costs.
Summary updated