层库(LoL):在运行时自适应排序Transformer层

·

研究论文 · 2026/11/03

我们提出Library of Layers (LoL),一种在推理时动态排序Transformer层的架构。LoL仅有一个超参数——全局Transformer块库的大小,使其能在参数重用与稀疏性之间无缝过渡,统一了稠密、深度循环和专家混合架构的参数效率与FLOPs效率权衡。在文本数据预训练中,LoL与上述三种基线性能相当;在数独和迷宫数据上,模型采用不同的层排序实现不同解题策略,且可通过干预路由强制模型应用特定策略;在多语言自然语言设置中,LoL根据语言和文字选择不同的层排序模式;在安全数据上训练并对其路由器输出拟合探针,探针能以高AUROC区分安全与不安全文本。LoL为模型动态构建自身计算图、实现更高效可控推理提供了路径。

LoL通过动态层排序统一了多种架构的效率权衡,并在多个任务中展示了策略可解释性与可控性,为构建更高效、可控的推理模型提供了新思路。

Computer programmers chain together the same reusable computational primitives, for example, conditional statements or loops, but in different orders to implement different algorithms. In contrast, existing language model architectures always execute their layers in the same order. We introduce Library of Layers (LoL), an architecture that dynamically orders its layers during inference to solve the problem at hand. LoL has a single hyperparameter, the size of its global library of transformer blocks, that allows it to transition seamlessly between parameter reuse and sparsity, generalizing the parameter-efficiency and FLOPs-efficiency tradeoffs of dense, depth-recurrent, and mixture of experts architectures in one unified family. We show that LoL achieves competitive performance with all three above baselines when pretrained on text data. On synthetic sudoku and maze data, we observe that the model employs distinct layer orderings to implement different solution strategies, and we can intervene on routing to force a model to apply a specific solution strategy to a problem instance. In a multilingual natural language setting, we find that LoL chooses different layer order patterns based on language and script. Similarly, we train LoL on safety data and fit probes to its router outputs, finding that these probes distinguish safe from unsafe text with high AUROC. LoL provides a path toward a future in which models dynamically compose their own computational graph, enabling more efficient and controllable reasoning.

阅读原文

参与讨论