Scaling In-Context Demonstrations with Structured Attention
Not on the map. Why?
Abstract (arXiv)
The recent surge of large language models (LLMs) highlights their ability to perform in-context learning, i.e., "learning" to perform a task from a few demonstrations in the context without any parameter updates. However, their capabilities of in-context learning are limited by the model architecture: 1) the use of demonstrations is constrained by a maximum sentence length due to positional embeddings; 2) the quadratic complexity of attention hinders users from using more demonstrations efficiently; 3) LLMs are shown to be sensitive to the order of the demonstrations. In this work, we tackle these challenges by proposing a better architectural design for in-context learning. We propose SAICL (Structured Attention for In-Context Learning), which replaces the full-attention by a structured attention mechanism designed for in-context learning, and removes unnecessary dependencies between individual demonstrations, while making the model invariant to the permutation of demonstrations. We evaluate SAICL in a meta-training framework and show that SAICL achieves comparable or better performance than full attention while obtaining up to 3.4x inference speed-up. SAICL also consistently outperforms a strong Fusion-in-Decoder (FiD) baseline which processes each demonstration independently. Finally, thanks to its linear nature, we demonstrate that SAICL can easily scale to hundreds of demonstrations with continuous performance gains with scaling.
Key facts. Cited by 8 papers in the map (data through 14 Oct 2026). Builds on 62 of its 74 references that are in the map. First posted on arXiv 5 Jul 2023.
Builds on
62 of 74 references.
References · 62
- 2017Attention Is All You Needcited by 60,361
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
- 2021LoRA: Low-Rank Adaptation of Large Language Modelscited by 14,380
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
- 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,708
- 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,326
- 2022Large Language Models are Zero-Shot Reasonerscited by 4,374
- 2019Parameter-Efficient Transfer Learning for NLPcited by 4,236
- 2021Prefix-Tuning: Optimizing Continuous Prompts for Generationcited by 3,915
- 2021The Power of Scale for Parameter-Efficient Prompt Tuningcited by 3,795
- 2021Finetuned Language Models Are Zero-Shot Learnerscited by 3,780
38 more
- 2022OPT: Open Pre-trained Transformer Language Modelscited by 3,512
- 2020Longformer: The Long-Document Transformercited by 3,413
- 2022Scaling Instruction-Finetuned Language Modelscited by 3,024
- 2022Training Compute-Optimal Large Language Modelscited by 3,019
- 2020Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecastingcited by 2,169
- 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 2,022
- 2020Big Bird: Transformers for Longer Sequencescited by 1,684
- 2020Reformer: The Efficient Transformercited by 1,668
- 2019Generating Long Sequences with Sparse Transformerscited by 1,546
- 2020Linformer: Self-Attention with Linear Complexitycited by 1,474
- 2021Multitask Prompted Training Enables Zero-Shot Task Generalizationcited by 1,470
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,434
- 2021Calibrate Before Use: Improving Few-Shot Performance of Language Modelscited by 1,392
- 2020Making Pre-trained Language Models Better Few-shot Learnerscited by 1,256
- 2021BitFit: Simple Parameter-efficient Fine-tuning for Transformer-based Masked Language-modelscited by 1,245
- 2020Leveraging Passage Retrieval with Generative Models for Open Domain Question Answeringcited by 1,210
- 2021What Makes Good In-Context Examples for GPT-3?cited by 1,195
- 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,135
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 938
- 2018Adafactor: Adaptive Learning Rates with Sublinear Memory Costcited by 905
- 2022Few-Shot Parameter-Efficient Fine-Tuning is Better and Cheaper than In-Context Learningcited by 896
- 2020Efficient Transformers: A Surveycited by 790
- 2022Transformers learn in-context by gradient descentcited by 732
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 715
- 2021P-Tuning v2: Prompt Tuning Can Be Comparable to Fine-tuning Universally Across Scales and Taskscited by 689
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 684
- 2021Learning To Retrieve Prompts for In-Context Learningcited by 648
- 2017Learning multiple visual domains with residual adapterscited by 557
- 2020UnifiedQA: Crossing Format Boundaries With a Single QA Systemcited by 476
- 2021Compacter: Efficient Low-Rank Hypercomplex Adapter Layerscited by 460
- 2021MetaICL: Learning to Learn In Contextcited by 454
- 2021Random Feature Attentioncited by 354
- 2020Parameter-Efficient Transfer Learning with Diff Pruningcited by 352
- 2021Surface Form Competition: Why the Highest Probability Answer Isn't Always Rightcited by 263
- 2022Reasoning with Language Model Prompting: A Surveycited by 252
- 2019Simple, Scalable Adaptation for Neural Machine Translationcited by 242
- 2022Towards Understanding Chain-of-Thought Prompting: An Empirical Study of What Matterscited by 222
- 2021Training Neural Networks with Fixed Sparse Maskscited by 214
50 most cited of 62 All 62 (JSON)
Built on by
Citing papers per year: 2024: 5; 2025: 3.
8 papers.
- 2024Eliminating Position Bias of Language Models: A Mechanistic Approachcited by 65
- 2024KBLaM: Knowledge Base augmented Language Modelcited by 16
- 2024Superposition Prompting: Improving and Accelerating Retrieval-Augmented Generationcited by 15
- 2025A Survey of Scaling in Large Language Model Reasoningcited by 10
- 2024Disentangling Latent Shifts of In-Context Learning with Weak Supervisioncited by 3
- 2025In-Context Learning (and Unlearning) of Length Biasescited by 3
- 2025RoToR: Towards More Reliable Responses for Order-Invariant Inputscited by 3
- 2024In-Context Learning with Noisy Labelscited by 0
- 2025A Survey of Scaling in Large Language Model Reasoning2 Apr 2025
- 2025RoToR: Towards More Reliable Responses for Order-Invariant Inputs10 Feb 2025
- 2025In-Context Learning (and Unlearning) of Length Biases10 Feb 2025
- 2024In-Context Learning with Noisy Labels29 Nov 2024
- 2024KBLaM: Knowledge Base augmented Language Model14 Oct 2024
- 2024Disentangling Latent Shifts of In-Context Learning with Weak Supervision2 Oct 2024
- 2024Eliminating Position Bias of Language Models: A Mechanistic Approach1 Jul 2024
- 2024Superposition Prompting: Improving and Accelerating Retrieval-Augmented Generation10 Apr 2024