How Stable Is In-Context Learning? Lipschitz Bounds for Transformer Output under Context Perturbation

Jinheng Wu, Di Zhang


Abstract
In-context learning (ICL) enables large language models to adapt from a few demonstrations, yet its sensitivity to context perturbations remains poorly understood. We study the context-conditioned map C ↦ f𝜃(x; C) through Lipschitz analysis. Modeling the Transformer as a composition of attention and feed-forward layers, we derive a worst-case certificate |f(x; C + 𝛿) - f(x; C)| ≤ L|𝛿| and a data-dependent local estimator based on finite-difference Jacobian probes. Across six language models (117M–7B) on controlled arithmetic ICL tasks, we find that: (i) output changes saturate as perturbation magnitude increases; (ii) global spectral bounds are extremely conservative, while local estimates are far closer to empirical sensitivity; (iii) sensitivity concentrates in late attention layers; (iv) additional demonstrations often stabilize predictions through redundancy; and (v) perturbation direction matters: label flips have much larger normalized effect than reorderings. SST-2 validation supports the same local-sensitivity and perturbation-direction trends. Our results position Lipschitz analysis less as a tight global predictor and more as a diagnostic framework for locating and comparing ICL vulnerabilities.
Anthology ID:
2026.emnlp-main.1065
Volume:
Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing
Month:
October
Year:
2026
Address:
Budapest, Hungary
Editors:
Hung-Yi Lee, Sunipa Dev, Jessy Li, Desmond Elliott
Venue:
EMNLP
SIG:
SIGDAT
Publisher:
Association for Computational Linguistics
Note:
Pages:
24469–24480
Language:
URL:
https://aclanthology.org/2026.emnlp-main.1065/
DOI:
Bibkey:
Cite (ACL):
Jinheng Wu and Di Zhang. 2026. How Stable Is In-Context Learning? Lipschitz Bounds for Transformer Output under Context Perturbation. In Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing, pages 24469–24480, Budapest, Hungary. Association for Computational Linguistics.
Cite (Informal):
How Stable Is In-Context Learning? Lipschitz Bounds for Transformer Output under Context Perturbation (Wu & Zhang, EMNLP 2026)
Copy Citation:
PDF:
https://aclanthology.org/2026.emnlp-main.1065.pdf