APIUp to 28% cheaper than official pricesTry the API →
Hermes
Back to News

Library of Layers Lets Transformers Pick Their own Execution Path

Library of Layers (LoL) is a transformer that picks which block runs at each depth via a learned router. A single knob (library size) interpolates between dense, looped, and mixture-of-experts architectures.

Library of Layers Lets Transformers Pick Their own Execution Path
Source
AlphaSignal
Published
Author
AlphaSignal
Read
2 min read

Takeaways

  • Library of Layers (LoL) is a transformer that picks which block runs at each depth via a learned router.
  • A single knob (library size) interpolates between dense, looped, and mixture-of-experts architectures.
  • Strided window attention keeps per-token routing stable by shifting window boundaries at every depth.
  • Forcing a routing path makes the model run a specific sudoku or maze algorithm with over 99.5% accuracy.
  • Router outputs separate safe from unsafe text with up to 0.95 AUROC using a linear probe.
  • Code is open source under MIT; no pretrained weights released.

Transformer language models usually send every token through the same fixed sequence of layers. Researchers behind Library of Layers (LoL) propose a different execution model: a router selects blocks from a shared library at each depth, allowing the order to change with the input.

By making execution order learnable, LoL gives one set of weights multiple processing paths. The architecture can reuse a small collection of blocks, select sparsely from a larger pool, or operate between those extremes. Its experiments also suggest that routing paths encode information about languages, algorithms, and text safety.

One parameter spans three familiar designs

A transformer block combines attention with feed-forward computation. Standard models assign a separate block to each position in a fixed stack; LoL stores blocks in a global library and asks the router which one should run at every step.

Library sizeExecution patternClosest architecturePrimary tradeoff
SmallBlocks are reused across many depthsDepth-recurrent transformerFewer parameters, more repeated computation
Near model depthBlocks can specialize by depthDense transformerDedicated capacity for each processing stage
LargeThe router selects sparsely from a broad poolMixture of expertsMore parameters without activating all of them

Changing the library size moves the model along this spectrum without requiring a separate architecture. A small library encourages repeated use, while a larger library gives the router more specialized blocks to choose from.

Conventional mixture-of-experts models usually preserve a fixed layer stack and route tokens among feed-forward experts inside each layer. LoL instead routes windows of tokens among complete transformer blocks drawn from one global pool.

Reporting is indexed from AlphaSignal. Rights remain with the original publisher and cited sources.

Read original report

Sources

  1. 01arxiv.org
  2. 02github.com
  3. 03twitter.com