TL;DR
Does depth itself give Transformer language models better compositional generalization, or does it simply reflect the fact that deeper models usually have more parameters? By systematically trading layer depth for feed-forward width at fixed parameter budgets (41M, 134M, and 374M), the authors show that depth independently boosts both language modeling and out-of-distribution compositional generalization. However, these returns diminish rapidly after just a few layers and fail to solve structural syntactic generalization.
What Problem Does This Paper Address?
Transformer language models notoriously struggle with compositional generalization—the ability to combine known words and syntactic rules in novel ways. While prior work suggested deeper models generalize more compositionally, depth is typically confounded with model size: adding layers introduces new parameters, and larger models generally perform better on downstream tasks.
This paper disentangles depth from overall parameter count to answer: Does network depth confer an architectural inductive bias toward compositional generalization independent of total parameters?
Methods
- Parameter-Matched Model Families: The authors constructed three parameter size classes (41M, 134M, and 374M parameters). Within each class, they varied the depth (number of layers, $n_{\text{layers}}$) while adjusting the feed-forward dimension ($d_{\text{ff}}$) to keep total parameters constant.
- Isolating Self-Attention: The residual embedding size ($d_{\text{model}}$) and attention dimension ($d_{\text{attn}}$) were held constant within each class, varying only $d_{\text{ff}}$. This ensured that changes in capability were not confounded by self-attention capacity.
- Causal Pretraining: All architectures were pretrained from scratch on a causal language modeling objective for 1 million steps (~131B tokens).
- Confounder Controls: To ensure depth benefits were not simply byproducts of better pretraining or in-distribution fitting, the authors evaluated:
- Perplexity-matched checkpoints: Fine-tuning deeper models stopped early at the exact validation perplexity reached by shallower reference models.
- Loss-matched evaluations: Evaluating out-of-distribution (OOD) accuracy at points during fine-tuning where models achieved identical in-distribution loss.
Datasets
- Pretraining:
- C4 (Colossal Clean Crawled Corpus): Web text used for standard causal language modeling.
- Compositional Generalization (Fine-Tuning):
- COGS: A semantic parsing benchmark measuring out-of-distribution lexical and structural generalization.
- COGS-vf (Variable-free COGS): A simplified version of COGS that removes variable indices to produce shorter target sequences.
- GeoQuery (Standard split): Natural language questions about US geography mapped to SQL-style database queries.
- English Passivization: Active-to-passive sentence transformations testing whether models learn hierarchical syntax rather than linear positional heuristics.
Key Insights and Ideas
- Diminishing Returns Set in Rapidly: Moving from 1 layer to 2 or 4 layers provides dramatic leaps in performance, but improvements plateau quickly. Compositional generalization saturates at low "threshold depths" (4–6 layers for COGS, 2–4 layers for COGS-vf and GeoQuery) regardless of model size.
- The Feed-Forward Dimension Cliff: Performance degrades when models become too narrow. When $d_{\text{ff}} < d_{\text{model}}$, feed-forward projections become non-injective and mathematically rank-deficient. Larger model families have more leeway to trade depth for width before hitting this bottleneck.
- Depth Solves Lexical, Not Structural, Generalization: When breaking down COGS performance, deeper models drastically improve on lexical generalization (e.g., using a known noun in a new grammatical role), but score nearly 0% on structural generalization (e.g., deeper recursion than seen in training). Depth alone does not provide the right inductive bias for recursive, tree-structured rules.
- Depth Has a True Independent Effect: Even when controlling for pretraining perplexity and in-distribution training loss, deeper models consistently outperform shallower models on OOD generalization.
Key Results
- Language Modeling:
- Single-layer models performed substantially worse than optimal deeper models of the same parameter count, with perplexity ratios of 1.59× (41M), 1.86× (134M), and 1.99× (374M).
- The optimal depths for perplexity were 5 layers (41M), 12 layers (134M), and 24 layers (374M).
- Compositional Generalization:
- On COGS, 1-layer models scored 12.4%–21.5% accuracy, whereas deeper variants reached 72.3%–78.0%.
- On English passivization, 1-layer models failed entirely (0.0%), while deeper configurations reached up to 89.9% (41M) and 93.2% (134M).
Limitations and Future Work
- Single Random Seeds: Due to computational cost, models were evaluated on a single pretraining and fine-tuning run, despite out-of-distribution generalization being known for high run-to-run variance.
- Alternative Depth Allocations: Compensating for depth via narrower feed-forward networks introduces a rank-deficiency bottleneck. The authors suggest investigating parameter-sharing approaches (such as Universal Transformers) to explore deep networks without shrinking layer width.
- Scale and In-Context Learning: Experiments were capped at 374M parameters using fine-tuning; examining whether depth exhibits similar thresholds during few-shot, in-context learning at multi-billion parameter scales remains open.
Summary updated