Lune

ICLR2022Top-tier venue

Compositional Attention: Disentangling Search and Retrieval

Sarthak Mittal, Sharath Chandra Raparthy, Irina Rish, Yoshua Bengio, Guillaume Lajoie

Abstract

Multi-head, key-value attention is the backbone of the widely successful Transformer model and its variants. This attention mechanism uses multiple parallel key-value attention blocks (called heads), each performing two fundamental computations: (1) search - selection of a relevant entity from a set via query-key interactions, and (2) retrieval - extraction of relevant features from the selected entity via a value matrix. Importantly, standard attention heads learn a rigid mapping between search and retrieval. In this work, we first highlight how this static nature of the pairing can potentially: (a) lead to learning of redundant parameters in certain tasks, and (b) hinder generalization. To alleviate this problem, we propose a novel attention mechanism, called Compositional Attention, that replaces the standard head structure. The proposed mechanism disentangles search and retrieval and composes them in a dynamic, flexible and context-dependent manner through an additional soft competition stage between the query-key combination and value pairing. Through a series of numerical experiments, we show that it outperforms standard multi-head attention on a variety of tasks, including some out-of-distribution settings. Through our qualitative analysis, we demonstrate that Compositional Attention leads to dynamic specialization based on the type of retrieval needed. Our proposed mechanism generalizes multi-head attention, allows independent scaling of search and retrieval, and can easily be implemented in lieu of standard attention heads in any network architecture.

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.

10 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

  • Is a Modular Architecture Enough? cites Object-Centric Learning with Slot Attention
  • Is a Modular Architecture Enough? cites A Meta-Transfer Objective for Learning to Disentangle Causal Mechanisms
  • Improving Transformers with Probabilistic Attention Keys cites Rethinking Attention with Performers
  • Improving Transformers with Probabilistic Attention Keys cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • Improving Transformers with Probabilistic Attention Keys cites Reformer: The Efficient Transformer
  • Rethinking Attention with Performers cites Reformer: The Efficient Transformer
  • Attention-based Iterative Decomposition for Tensor Product Representation cites Object-Centric Learning with Slot Attention
  • Discrete Dictionary-based Decomposition Layer for Structured Representation Learning cites Object-Centric Learning with Slot Attention
  • Discrete Dictionary-based Decomposition Layer for Structured Representation Learning cites Attention-based Iterative Decomposition for Tensor Product Representation
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers10

  1. Is a Modular Architecture Enough?Sarthak Mittal, Yoshua Bengio, Guillaume LajoieNeurIPS 2022 · 62 citations
  2. Improving Transformers with Probabilistic Attention KeysTam Minh Nguyen, Tan Minh Nguyen, Dung D. Le, Duy Khuong Nguyen et al.ICML 2022 · 38 citations
  3. Layer-Wise Representation Fusion for Compositional GeneralizationYafang Zheng, Lei Lin, Shuangtao Li, Yuxuan Yuan et al.AAAI 2024 · 4 citations
  4. Attention-based Iterative Decomposition for Tensor Product RepresentationTaewon Park, Inchul Choi, Minho LeeICLR 2024 · 1 citation
  5. Discrete Dictionary-based Decomposition Layer for Structured Representation LearningTaewon Park, Hyun-Chul Kim, Minho LeeNeurIPS 2024 · 1 citation

Builds on10

  1. An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn et al.ICLR 2021 · 21,477 citations
  2. Reformer: The Efficient TransformerNikita Kitaev, Lukasz Kaiser, Anselm LevskayaICLR 2020 · 2,878 citations
  3. Object-Centric Learning with Slot AttentionFrancesco Locatello, Dirk Weissenborn, Thomas Unterthiner, Aravindh Mahendran et al.NeurIPS 2020 · 1,275 citations
  4. A Meta-Transfer Objective for Learning to Disentangle Causal MechanismsYoshua Bengio, Tristan Deleu, Nasim Rahaman, Nan Rosemary Ke et al.ICLR 2020 · 371 citations
  5. Rethinking Attention with PerformersKrzysztof Marcin Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song et al.ICLR 2021 · 122 citations

Related papers

  1. Attention as a HypernetworkSimon Schug, Seijin Kobayashi, Yassir Akram, João Sacramento et al.ICLR 2025
  2. Learning Hard Retrieval Decoder Attention for TransformersHongfei Xu, Qiuhui Liu, Josef van Genabith, Deyi XiongEMNLP Findings 2021
  3. Improving Transformers with Dynamically Composable Multi-Head AttentionDa Xiao, Qingye Meng, Shengping Li, Xingyuan YuanICML 2024 · 8 citations
  4. In-Context Compositional Learning vis Sparse Coding TransformerWei Chen, Jingxi Yu, Zichen Miao, Qiang QiuNeurIPS 2025
  5. Efficient Length-Generalizable Attention via Causal Retrieval for Long-Context Language ModelingXiang Hu, Zhihao Teng, Jun Zhao, Wei Wu et al.ICML 2025
Dusk over the sea between two cliffs drawn in fine vertical lines