Mechanistic Study of Transformer In-Context Learning with Categorical Outputs
Soumya Banerjee, Aaron T Wang, William Convertino, Ozanan Meireles, Guy Rosman, Ricardo Henao, Xiang Cheng, Lawrence Carin
ICLR 2026 submission
Abstract. We study in-context learning (ICL) with Transformers for categorical outputs , a setting largely unexplored compared to research on real-valued . While attention-only Transformers can, in principle, perform functional gradient descent (GD) inference for real-valued outputs, we show that categorical introduce a non-linearity in GD that attention-only models cannot capture. This reveals a crucial role for the Transformer's multi-layered perceptron (MLP) layers, which we show are generally necessary for categorical ICL. However, we also analyze conditions under which attention-only models can, surprisingly, still perform well. Since training for categorical ICL requires substantial data, we propose a sparse Transformer parametrization linked to functional GD. This model trains far more efficiently with minimal performance degradation compared to an unconstrained Transformer. Our sparse design proves particularly valuable for data-limited applications, which we demonstrate through the ICL analysis of human surgical procedures.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperadd · history
Loading the discussion…