Lune

ICLR2025Top-tier venue

Attention as a Hypernetwork

Simon Schug, Seijin Kobayashi, Yassir Akram, João Sacramento, Razvan Pascanu

Abstract

Transformers can under some circumstances generalize to novel problem instances whose constituent parts might have been encountered during training, but whose compositions have not. What mechanisms underlie this ability for compositional generalization? By reformulating multi-head attention as a hypernetwork, we reveal that a composable, low-dimensional latent code specifies key-query specific operations. We find empirically that this latent code is predictive of the subtasks the network performs on unseen task compositions, revealing that latent codes acquired during training are reused to solve unseen problem instances. To further examine the hypothesis that the intrinsic hypernetwork of multi-head attention supports compositional generalization, we ablate whether making the hypernetwork-generated linear value network nonlinear strengthens compositionality. We find that this modification improves compositional generalization on abstract reasoning tasks. In particular, we introduce a symbolic version of the Raven's Progressive Matrices human intelligence test, which gives us precise control over the problem compositions encountered during training and evaluation. We demonstrate on this task how scaling model size and data enables compositional generalization in transformers and gives rise to a functionally structured latent space. 1

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

8 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • LoRAGen: Structure-Aware Weight Space Learning for LoRA Generation cites Text-to-LoRA: Instant Transformer Adaption
  • Text-to-LoRA: Instant Transformer Adaption cites Language Models are Few-Shot Learners
  • Scaling can lead to compositional generalization cites Measuring and Narrowing the Compositionality Gap in Language Models
  • Scaling can lead to compositional generalization cites Language Models are Few-Shot Learners
  • Scaling can lead to compositional generalization cites Faith and Fate: Limits of Transformers on Compositionality
  • Emergent Analogical Reasoning in Transformers cites Scaling can lead to compositional generalization
  • Faith and Fate: Limits of Transformers on Compositionality cites Language Models are Few-Shot Learners
  • Towards Reasoning in Large Language Models: A Survey cites Measuring and Narrowing the Compositionality Gap in Language Models
  • Towards Reasoning in Large Language Models: A Survey cites Language Models are Few-Shot Learners
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers8

  1. Scaling can lead to compositional generalizationFlorian Redhardt, Yassir Akram, Simon SchugNeurIPS 2025 · 11 citations
  2. Hyper-GoalNet: Goal-Conditioned Manipulation Policy Learning with HyperNetworksPei Zhou, Wanting Yao, Qian Luo, Xunzhe Zhou et al.NeurIPS 2025 · 4 citations
  3. Emergent Analogical Reasoning in TransformersGouki Minegishi, Jingyuan Feng, Hiroki Furuta, Takeshi Kojima et al.ICML 2026 · 4 citations
  4. LoRAGen: Structure-Aware Weight Space Learning for LoRA GenerationHao Huang, Jingtao Ding, Mengqi Liao, Xin Wang et al.ICLR 2026
  5. Text-to-LoRA: Instant Transformer AdaptionRujikorn Charakorn, Edoardo Cetin, Yujin Tang, Robert Tjarko LangeICML 2025

Builds on16

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. Faith and Fate: Limits of Transformers on CompositionalityNouha Dziri, Ximing Lu, Melanie Sclar, Xiang Lorraine Li et al.NeurIPS 2023 · 728 citations
  3. Towards Reasoning in Large Language Models: A SurveyJie Huang, Kevin Chen-Chuan ChangACL Findings 2023 · 428 citations
  4. Linear Transformers Are Secretly Fast Weight ProgrammersImanol Schlag, Kazuki Irie, Jürgen SchmidhuberICML 2021 · 394 citations
  5. Measuring and Narrowing the Compositionality Gap in Language ModelsOfir Press, Muru Zhang, Sewon Min, Ludwig Schmidt et al.EMNLP Findings 2023 · 296 citations

Related papers

  1. In-Context Compositional Learning vis Sparse Coding TransformerWei Chen, Jingxi Yu, Zichen Miao, Qiang QiuNeurIPS 2025
  2. Compositional Attention: Disentangling Search and RetrievalSarthak Mittal, Sharath Chandra Raparthy, Irina Rish, Yoshua Bengio et al.ICLR 2022 · 20 citations
  3. Dynamic Inference with Neural InterpretersNasim Rahaman, Muhammad Waleed Gondal, Shruti Joshi, Peter V. Gehler et al.NeurIPS 2021 · 35 citations
  4. Compositional Generalization through Gradient Search in Nonparametric Latent SpaceHaruki Shirakami, James HendersonICLR 2026
  5. Are Transformers Able to Reason by Connecting Separated Knowledge in Training Data?Yutong Yin, Zhaoran WangICLR 2025
Dusk over the sea between two cliffs drawn in fine vertical lines