cs.LGFeb 19, 2026

Bigger Is Safer: Provable Robustness in In-Context Learning Scales with Capacity

Authors: Di Zhang, Ningxu Zhang, Zimeng Liu

Organizations: School of AI and Advanced Computing Xi’an Jiaotong-Liverpool University

Abstract

In-context learning (ICL) allows large language models to adapt to new tasks from a few examples without updating their parameters. Existing theories explain ICL by assuming the test task distribution matches pretraining -- an assumption that breaks down under adversarial distribution shifts. We introduce a distributionally robust meta-learning framework that provides worst-case guarantees for ICL under Wasserstein-based distribution shifts. Focusing on linear self-attention Transformers, we derive a non-asymptotic bound connecting adversarial perturbation strength (ρρ), model capacity (mm), and the number of in-context examples (NN). The analysis reveals that the maximum safe perturbation radius scales as ρmax⁡∝mρ_{\max} \propto \sqrt{m}, while maintaining performance under adversarial shift requires additional in-context examples with Nρ−N0∝ρ2N_ρ- N_0 \propto ρ^2. Experiments on synthetic tasks confirm these scaling laws, and experiments on 21 real pretrained models (0.1B--7B parameters, 5 families) provide qualitative evidence consistent with the theory's predictions, while revealing that ICL capability is a prerequisite for robustness. These findings advance the theoretical understanding of ICL under adversarial conditions and formalize the sense in which larger models are safer under distributional shift.

Figures & tables

Appendix figures & tables13 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. How Does the Pretraining Distribution Shape In-Context Learning? A Fundamental Trade-Off

    Oct 1, 2025Waïss Azizian, Ali HasanLanguage Model PretrainingOOD Generalization

  2. Understanding and Improving Continuous Adversarial Training for LLMs via In-context Learning Theory

    Apr 14, 2026Shaopeng Fu, Di WangAdversarial TrainingAdversarial Robustness of Language Models