Library of Layers (LoL): Adaptively Ordering Transformer Layers at Runtime
Abdellah Rahmani, Sean McLeish, Ang Li, Sanae Lotfi, Pascal Frossard, Micah Goldblum
Key points
From the paper's conclusion- We introduce Library of Layers (LoL), an architecture that dynamically orders its layers during inference to solve the problem at hand.
Abstract
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.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Programs-of-Layers in LLMs through the Lens of Cortical AreasarXiv · 2026
- Transformers Provably Learn Graph Search: Training Dynamics and the Exponential Power of DeptharXiv · 2026
- High-dimensional layer-state trajectories reveal the internal dynamics of transformer inferencearXiv · 2026
- Meta$^n$: Recursive Self-Improvement through Emergent DeptharXiv · 2026
- Layer-Level Control of Language Model Execution in Agent FrameworksarXiv · 2026
- Compositional Multilingual and Behavioral Attribute SteeringarXiv · 2026