Paper Reading AI Learner

Transformers Don't In-Context Learn Least Squares Regression

2025-07-13 01:09:26
Joshua Hill, Benjamin Eyre, Elliot Creager

Abstract

In-context learning (ICL) has emerged as a powerful capability of large pretrained transformers, enabling them to solve new tasks implicit in example input-output pairs without any gradient updates. Despite its practical success, the mechanisms underlying ICL remain largely mysterious. In this work we study synthetic linear regression to probe how transformers implement learning at inference time. Previous works have demonstrated that transformers match the performance of learning rules such as Ordinary Least Squares (OLS) regression or gradient descent and have suggested ICL is facilitated in transformers through the learned implementation of one of these techniques. In this work, we demonstrate through a suite of out-of-distribution generalization experiments that transformers trained for ICL fail to generalize after shifts in the prompt distribution, a behaviour that is inconsistent with the notion of transformers implementing algorithms such as OLS. Finally, we highlight the role of the pretraining corpus in shaping ICL behaviour through a spectral analysis of the learned representations in the residual stream. Inputs from the same distribution as the training data produce representations with a unique spectral signature: inputs from this distribution tend to have the same top two singular vectors. This spectral signature is not shared by out-of-distribution inputs, and a metric characterizing the presence of this signature is highly correlated with low loss.

Abstract (translated)

上下文学习(ICL)已经成为大规模预训练变压器的强大能力,使它们能够在不进行任何梯度更新的情况下解决隐含在示例输入-输出对中的新任务。尽管其实用性得到了成功验证,但其背后的机制仍然很大程度上是个谜。在这项工作中,我们研究了合成线性回归问题,以探讨变压器如何实现在推理过程中学习的能力。先前的工作已经证明,变压器可以达到诸如普通最小二乘(OLS)回归或梯度下降等学习规则的性能,并且提出了变压器通过实现这些技术之一来促进上下文学习的观点。在本项工作中,我们通过一系列分布外泛化实验展示了针对ICL进行训练的变压器在提示分布发生变化后无法推广的行为,这种行为与认为变压器实施诸如OLS算法的观点不符。 最后,我们通过对残差流中所学表示的谱分析强调了预训练语料库在塑造ICL行为中的作用。来自与训练数据相同分布的输入会产生具有独特谱特征的表示:这些分布中的输入通常具有相同的前两个奇异向量。这种谱签名不会被分布外的输入共享,且一个表征该签名存在性的度量高度相关于较低损失值。 简而言之,这项研究表明预训练的数据对于上下文学习行为至关重要,并且变压器在处理新任务时的行为并不总是遵循传统算法如OLS的学习规则。

URL

https://arxiv.org/abs/2507.09440

PDF

https://arxiv.org/pdf/2507.09440.pdf


Tags
3D Action Action_Localization Action_Recognition Activity Adversarial Agent Attention Autonomous Bert Boundary_Detection Caption Chat Classification CNN Compressive_Sensing Contour Contrastive_Learning Deep_Learning Denoising Detection Dialog Diffusion Drone Dynamic_Memory_Network Edge_Detection Embedding Embodied Emotion Enhancement Face Face_Detection Face_Recognition Facial_Landmark Few-Shot Gait_Recognition GAN Gaze_Estimation Gesture Gradient_Descent Handwriting Human_Parsing Image_Caption Image_Classification Image_Compression Image_Enhancement Image_Generation Image_Matting Image_Retrieval Inference Inpainting Intelligent_Chip Knowledge Knowledge_Graph Language_Model LLM Matching Medical Memory_Networks Multi_Modal Multi_Task NAS NMT Object_Detection Object_Tracking OCR Ontology Optical_Character Optical_Flow Optimization Person_Re-identification Point_Cloud Portrait_Generation Pose Pose_Estimation Prediction QA Quantitative Quantitative_Finance Quantization Re-identification Recognition Recommendation Reconstruction Regularization Reinforcement_Learning Relation Relation_Extraction Represenation Represenation_Learning Restoration Review RNN Robot Salient Scene_Classification Scene_Generation Scene_Parsing Scene_Text Segmentation Self-Supervised Semantic_Instance_Segmentation Semantic_Segmentation Semi_Global Semi_Supervised Sence_graph Sentiment Sentiment_Classification Sketch SLAM Sparse Speech Speech_Recognition Style_Transfer Summarization Super_Resolution Surveillance Survey Text_Classification Text_Generation Time_Series Tracking Transfer_Learning Transformer Unsupervised Video_Caption Video_Classification Video_Indexing Video_Prediction Video_Retrieval Visual_Relation VQA Weakly_Supervised Zero-Shot