We present Brainstacks, a modular architecture for continual multi-domain fine-tuning of large language models that packages domain expertise as frozen adapter stacks composing additively on a shared frozen base at inference. Five interlocking components: (1) MoE-LoRA with Shazeer-style noisy top-2 routing across all seven transformer projections under QLoRA 4-bit quantization with rsLoRA scaling; (2) an inner loop performing residual boosting by freezing trained stacks and adding new ones; (3) an outer loop training sequential domain-specific stacks with curriculum-ordered dependencies; (4) null-space projection via randomized SVD constraining new stacks to subspaces orthogonal to prior directions, achieving zero forgetting in isolation; (5) an outcome-based sigmoid meta-router trained on empirically discovered domain-combination targets that selectively weights stacks, enabling cross-domain composition. Two boundary experiments: (6) PSN pretraining on a randomly initialized model; (7) per-domain RL (DPO/GRPO) validating compatibility with post-SFT alignment. Validated on TinyLlama-1.1B (4 domains, 9 stacks) and Gemma 3 12B IT (5 domains, 10 stacks), MoE-LoRA achieves 2.5x faster convergence than parameter-matched single LoRA, residual boosting breaks through the single-stack ceiling, and the routed system recovers generation quality destroyed by ungated stack accumulation. The central finding: the outcome-based router discovers that domain stacks encode transferable cognitive primitives (instruction-following clarity, numerical reasoning, procedural logic, chain-of-thought structure) rather than domain-specific knowledge, with medical prompts routing to chat+math stacks in 97% of cases despite zero medical data in those stacks.
翻译:我们提出Brainstacks——一种用于大语言模型连续多领域微调的模块化架构,该架构将领域专业知识打包为冻结适配器堆栈,在推理阶段以加性方式组合于共享冻结基座之上。架构包含五个相互关联的组件:(1)采用Shazeer风格带噪top-2路由机制的MoE-LoRA,在QLoRA 4比特量化与rsLoRA缩放条件下覆盖全部七个变换器投影矩阵;(2)内循环通过冻结已训练堆栈并添加新堆栈实现残差增强;(3)外循环按课程顺序化依赖关系训练序列化领域专用堆栈;(4)基于随机化SVD的零空间投影,约束新堆栈位于与先前方向正交的子空间中,实现零遗忘隔离;(5)基于结果训练的sigmoid元路由器,依据经验发现的领域组合目标选择性加权堆栈,实现跨领域组合。两项边界实验:(6)在随机初始化模型上的PSN预训练;(7)验证与后SFT对齐兼容性的逐领域强化学习(DPO/GRPO)。在TinyLlama-1.1B(4领域,9堆栈)与Gemma 3 12B IT(5领域,10堆栈)上的验证表明:MoE-LoRA的收敛速度比参数匹配的单LoRA快2.5倍;残差增强突破单堆栈性能天花板;基于路由的系统可恢复被无门控堆栈累积破坏的生成质量。核心发现:基于结果的元路由器发现领域堆栈编码的是可迁移的认知基元(指令遵循清晰度、数值推理、过程逻辑、思维链结构)而非领域特定知识——尽管医学提示词在97%的案例中被路由至聊天+数学堆栈,但这两个堆栈中不包含任何医学数据。