mlsanityData to 14 Oct 2026

Optimal Attention Temperature Improves the Robustness of In-Context Learning under Distribution Shift in High Dimensions

arXiv 2511.01292 ↗First posted 3 Nov 2025stat.ML cs.LGcited by 1

Not on the map. Why?

Abstract (arXiv)

Pretrained Transformers can perform in-context learning (ICL) from a few demonstrations, but this ability can fail sharply when the test distribution differs from pretraining, a common deployment setting. We study attention temperature as a simple inference-time control for improving ICL robustness under such shifts. In a high-dimensional linear-regression framework, we analyze a Transformer with "approximate softmax" attention, which preserves softmax's normalization and temperature-dependent selectivity while remaining tractable. We derive a closed-form expression for the ICL generalization error under distribution shift, and show that it is minimized by an explicit optimal attention temperature. This characterization yields interpretable guidance by linking the best temperature to moments of the pre-softmax attention scores, and predicts when temperature adjustment can recover near Bayes-optimal performance. We validate the theory with extensive simulations, and further demonstrate gains on pretrained LLMs (GPT-2 and Llama2-7B) on question-answering benchmarks under distribution shift induced by noisy in-context demonstrations. Overall, attention temperature emerges as a principled, lightweight knob for improving the robustness of ICL in pretrained Transformers.

Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Builds on 33 of its 39 references that are in the map. First posted on arXiv 3 Nov 2025.

Builds on

33 of 39 references.

References · 33

  1. 2017Attention Is All You Needcited by 60,361
  2. 2020Language Models are Few-Shot Learnerscited by 32,419
  3. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 13,028
  4. 2022Emergent Abilities of Large Language Modelscited by 2,512
  5. 2020Rethinking Attention with Performerscited by 1,601
  6. 2021What Makes Good In-Context Examples for GPT-3?cited by 1,195
  7. 2022In-context Learning and Induction Headscited by 964
  8. 2017Crowdsourcing Multiple Choice Science Questionscited by 765
  9. 2022Transformers learn in-context by gradient descentcited by 732
  10. 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 715
  11. 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 684
  12. 2023YaRN: Efficient Context Window Extension of Large Language Modelscited by 601
21 more
  1. 2023Are Emergent Abilities of Large Language Models a Mirage?cited by 523
  2. 2023Trained Transformers Learn Linear Models In-Contextcited by 337
  3. 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 298
  4. 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 279
  5. 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 222
  6. 2022cosFormer: Rethinking Softmax in Attentioncited by 213
  7. 2023One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attentioncited by 170
  8. 2024The Effect of Sampling Temperature on Problem Solving in Large Language Modelscited by 170
  9. 2023Pretraining task diversity and the emergence of non-Bayesian in-context learning for regressioncited by 146
  10. 2021Vision Transformer for Small-Size Datasetscited by 122
  11. 2023How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?cited by 96
  12. 2024Competition Dynamics Shape Algorithmic Phases of In-Context Learningcited by 54
  13. 2023OpenICL: An Open-Source Framework for In-context Learningcited by 51
  14. 2023Transformers Learn to Achieve Second-Order Convergence Rates for In-Context Linear Regressioncited by 49
  15. 2024Bridging the Divide: Reconsidering Softmax and Linear Attentioncited by 48
  16. 2024Softmax is not Enough (for Sharp Size Generalisation)cited by 46
  17. 2024Fine-grained Analysis of In-context Linear Estimation: Data, Architecture, and Beyondcited by 24
  18. 2024On the Noise Robustness of In-Context Learning for Text Generationcited by 16
  19. 2022Accumulated Trivial Attention Matters in Vision Transformers on Small Datasetscited by 15
  20. 2021Attention Temperature Matters in Abstractive Summarization Distillationcited by 14
  21. 2018Learning When to Concentrate or Divert Attention: Self-Adaptive Attention Temperature for Neural Machine Translationcited by 10

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2026: 1.

1 paper.