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

Authors: 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 \mapsto f_\theta(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 + \delta) - f(x; C)| \leq L|\delta| 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.

PDFOpen original
Find similar papers with AI

Copy this prompt into your assistant

Using Paperlist, find papers similar to "How Stable Is In-Context Learning? Lipschitz Bounds for Transformer Output under Context Perturbation" (id: 238866, EMNLP 2026).
set up https://paperlist.ai/SKILL.md

MCP setupCLI