acceptodds
Under review as a conference paper at ICLR 2027

Adversarially Trained Linear Transformers Are Optimal Robust In-Context Learners for Gaussian Mixtures

Abstract

Adversarial training is one of the most reliable defenses against adversarial attacks, but its high computational cost must generally be paid anew for each task. Robust foundation models offer a promising alternative: adversarially pretrain a model once and then transfer its robustness to downstream tasks through lightweight adaptation. However, a fundamental question remains open: can robustness acquired during pretraining transfer to unseen tasks without further adversarial training? In this study, we answer this question affirmatively. A single model adversarially pretrained at scale can achieve optimal robustness on new tasks without additional task-specific training. Specifically, we show that, for a family of Gaussian-mixture classification tasks, a sufficiently deep linear transformer adversarially trained across tasks can asymptotically attain the robust Bayes error on previously unseen tasks through in-context learning from clean demonstrations. By contrast, a standardly trained model cannot. We further analyze convergence under gradient flow, an accuracy–robustness trade-off, and demonstration complexity.

Primary area:
learning theory
Keywords:
Adversarial Training, Adversarial Defense, Adversarial Examples, Transformers, In-Context Learning, Robust Machine Learning, Robust Optimization, Bayes Classifier, Bayes Risk

Reviews

Among:
Shape:
1234this paper, Top 30%
Figure 1. Mean review rating of the reviewed papers at ICLR 2027. This paper averages 2.67 over 3 reviews, above 70% of the others.
Reviewer_HEe1OpenReview ↗
Rating
2
Confidence
2
Informativeness
2
Presentation
3
Soundness
2
Read review
Paper summary

This paper studies robust in-context learning through adversarial pretraining. The authors theoretically show that sufficiently deep adversarially trained linear transformers can approach the robust Bayes error on unseen tasks, while standard training cannot. Synthetic and real-world experiments are provided to support the theoretical results.

Critical strengths
  • The paper provides a solid theoretical analysis of robust in-context learning and clearly distinguishes adversarial from standard pretraining.
  • The theoretical results cover multiple aspects, including Bayes optimality, optimization, and robustness–accuracy trade-offs.
Critical weaknesses
  • The empirical evaluation is relatively limited. The real-world experiments mainly compare standard and adversarial training on three datasets, without stronger alternative robust pretraining or adaptation baselines.

  • The theoretical results rely on several structured assumptions, particularly the Gaussian-mixture setting with shared mean and covariance across tasks. This raises some concerns about how broadly the theoretical conclusions apply beyond the considered setting.

Questions for authors
  • The empirical evaluation mainly compares standard training with adversarial training. Could the authors clarify why other relevant robust pretraining or adaptation baselines are not included?

  • How restrictive are the assumptions underlying the theoretical results, particularly the shared mean/covariance structure across tasks and the condition L≥rL \ge r? To what extent would the main conclusions hold if these assumptions were relaxed?

Reviewer_QhR7OpenReview ↗
Rating
3
Confidence
3
Informativeness
2
Presentation
3
Soundness
2
Read review
Paper summary

This paper examines whether adversarially pretrained transformers can transfer robustness to unseen classification tasks via in-context learning, without additional adversarial training. The authors consider the Gaussian-mixture tasks and show that sufficiently deep linear transformers can achieve robust Bayes optimality using only clean in-context demonstrations. They further prove that adversarial pretraining can lead to a vanishing robust excess error as the number of pretraining tasks and demonstrations increases, whereas standard pretraining generally cannot achieve the same level of optimality. Experiments on synthetic data and several image classification datasets provide additional support for the theoretical findings.

Critical strengths
  1. The theoretical analysis is interesting and provides a meaningful extension of prior work. In particular, moving from expected robust margin guarantees to robust Bayes optimality is a useful step forward. I also find the connection between transformer depth, Krylov subspaces, and the ability to represent robust classifiers quite interesting. These results offer some useful insights into how adversarial robustness might be transferred through in-context learning.

  2. The experiments provide encouraging support for the theoretical findings. The synthetic experiments show how robustness improves with model depth, the number of pretraining tasks, and the number of demonstrations. I also appreciate that the authors go beyond linear transformers and include experiments with softmax attention on real-world datasets. Although these experiments do not fully establish the theory's generality, they demonstrate that the benefits of adversarial pretraining are not limited to the simplified theoretical model.

Critical weaknesses

The theoretical results are interesting, but I am not entirely convinced how broadly they apply. In particular, all tasks in the analysis share the same underlying Gaussian mean and covariance, and differ only through orthogonal transformations. This seems rather restrictive compared with real downstream tasks, where the underlying distributions can differ much more substantially. Also, the condition L≥rL \geq r could require quite deep transformers for more general covariance structures. While the real-world experiments are encouraging, they do not fully address these limitations. Since transferring robustness to unseen tasks is the main motivation of the paper, I think it is important to better understand how much of the result carries over beyond this particular theoretical setting.

Questions for authors
  1. How important is the shared Gaussian structure to the main results? In the current setting, unseen tasks differ only through orthogonal transformations. What would happen if the mean or covariance also changed across tasks? I understand that extending the theory may be difficult, but even some synthetic experiments with slightly different task distributions could help clarify how sensitive the results are to this assumption.

  2. How restrictive is the depth requirement in practice? The condition L≥rL \geq r seems potentially quite strong, since rr can be as large as dd for a general covariance matrix. Interestingly, in Figure 1, the two-layer model already gets quite close to the Bayes error even though r=10r=10. Does this suggest that the theoretical condition is rather conservative? Is there any intuition about when a much shallower transformer might be sufficient?

  3. How far do the theoretical guarantees carry over to the models used in practice? The main results assume linear attention and, in Theorem 3.4, a global empirical-risk minimizer. The real-world experiments instead use softmax transformers trained with gradient-based optimization. These results are promising, but I wonder whether they mainly demonstrate the benefit of adversarial pretraining, rather than the stronger Bayes-optimality claim. It would be helpful to hear the authors' perspective on this gap.

  4. Could the authors clarify the theoretical advances over [1]? I agree that the new robust Bayes error guarantee is stronger than the expected robust margin analysis in the earlier work. However, the two papers also make rather different assumptions about the data distribution and perturbation model. In particular, the current paper assumes Gaussian mixtures with shared latent parameters. I am therefore not sure that the new setting is strictly more general. A more precise discussion of what is genuinely extended, and what is instead analyzed under different assumptions, would help me better assess the contribution.

[1]Kumano, S., Kera, H., & Yamasaki, T. (2026, April). Adversarially pretrained transformers may be universally robust in-context learners. In International Conference on Learning Representations (Vol. 2026, pp. 124615-124659).

Reviewer_Fbf2OpenReview ↗
Rating
3
Confidence
2
Informativeness
3
Presentation
2
Soundness
2
Read review
Paper summary

This manuscript studies whether adversarial robustness acquired during pretraining can transfer to previously unseen classification tasks through in-context learning (ICL), without task-specific adversarial training at inference time. The theoretical analysis considers a family of binary Gaussian-mixture tasks in which all tasks share a common latent mean vector and covariance matrix, while task-specific distributions differ through orthogonal transformations.

Critical strengths

The problem is well motivated and relevant. The paper investigates whether robustness acquired during pretraining can be transferred to unseen tasks without further task-specific adversarial training. This is an important question for robust foundation models, where repeatedly performing adversarial training for every downstream task can be computationally expensive. The distinction between clean demonstrations and an adversarially perturbed query is clearly formulated, making the learning scenario relatively easy to understand. The theoretical analysis goes beyond robust-margin guarantees. A notable strength is that the authors analyze the robust zero-one error relative to the taskwise robust Bayes error, rather than relying exclusively on expected robust margins. The characterization of the robust Bayes direction and the connection between the required transformer depth and the Krylov subspace dimension provide a coherent explanation of how a shared transformer can represent task-specific robust classifiers. The finite-task and finite-context analysis further strengthens the theoretical contribution. The paper studies several complementary aspects of robust ICL. Beyond the main optimality results, the authors investigate gradient-flow convergence, the accuracy–robustness trade-off, and demonstration complexity. These results help connect the main theoretical framework to broader questions about optimization and the statistical cost of robust prediction. The limitations concerning the Gaussian task family.

Critical weaknesses

The novelty relative to closely related work remains insufficiently clarified. Although the authors discuss the differences between their work and Kumano et al. (2026), the comparison remains insufficiently precise to clearly distinguish the genuinely original contributions from extensions of existing results. Specifically, it is still unclear which theoretical results are fundamentally new, which are obtained by relaxing the assumptions or generalizing the architecture of prior work, and which follow from existing analytical techniques with relatively straightforward modifications. For example, the authors extend the analysis from single-layer to multilayer linear transformers, consider a broader Gaussian data model, and establish guarantees in terms of taskwise robust zero-one error. However, the manuscript does not sufficiently disentangle the technical novelty associated with each extension or explain which new theoretical difficulties must be overcome to obtain these results. A more systematic, contribution-by-contribution comparison with Kumano et al. (2026) is therefore needed, explicitly identifying the inherited results, the generalized results, and the genuinely new theoretical insights. The theoretical results rely on restrictive assumptions about the task distribution. All tasks share the same underlying Gaussian mean and covariance and differ only through orthogonal transformations. Thus, the unseen tasks considered in the theory belong to a highly structured family, and it remains unclear whether the proposed robustness guarantees extend to more general downstream tasks. This raises concerns about the broad claim in the abstract that “a single model adversarially pretrained at scale can achieve optimal robustness on new tasks without additional task-specific training.” The authors should clarify the scope of this claim and either provide further theoretical or empirical evidence to support its generality or revise the abstract, introduction, and conclusion to ensure that the claims accurately reflect the assumptions and limitations of the established results.

Questions for authors

Q1: Insufficiently clarified contribution boundary relative to Kumano et al. (2026). A systematic, contribution-by-contribution comparison is needed to explicitly distinguish inherited results, generalized results obtained by relaxing assumptions or extending the architecture, and genuinely new theoretical insights, so that extensions of prior work are not presented as original breakthroughs.

Q2: Technical novelty and theoretical difficulties of each extension are not disentangled. Specifically, the extensions from single-layer to multilayer linear transformers, to a broader Gaussian data model, and to taskwise robust zero-one error guarantees should each be accompanied by an explanation of the new theoretical difficulties they overcome, rather than being collectively described as generalizations.

Q3: The task-distribution assumptions are overly restrictive, raising concerns about generality. All tasks share the same underlying Gaussian mean and covariance and differ only through orthogonal transformations, so the unseen tasks belong to a highly structured family. It remains unclear whether the robustness guarantees extend to more general downstream tasks.

Q4: The broad robustness claim exceeds the scope of the theoretical assumptions. The abstract’s claim that “a single model adversarially pretrained at scale can achieve optimal robustness on new tasks without additional task-specific training” is too strong. The authors should clarify its scope and either provide further theoretical or empirical evidence or revise the abstract, introduction, and conclusion so that the claims accurately reflect the assumptions and limitations of the established results.

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Related papers

Loading the map…

Discussion (0)

Sign in to comment.