Paper Reading AI Learner

In-Context Algorithm Emulation in Fixed-Weight Transformers

2025-08-24 23:20:31
Jerry Yao-Chieh Hu, Hude Liu, Jennifer Yuntong Zhang, Han Liu

Abstract

We prove that a minimal Transformer architecture with frozen weights is capable of emulating a broad class of algorithms by in-context prompting. In particular, for any algorithm implementable by a fixed-weight attention head (e.g. one-step gradient descent or linear/ridge regression), there exists a prompt that drives a two-layer softmax attention module to reproduce the algorithm's output with arbitrary precision. This guarantee extends even to a single-head attention layer (using longer prompts if necessary), achieving architectural minimality. Our key idea is to construct prompts that encode an algorithm's parameters into token representations, creating sharp dot-product gaps that force the softmax attention to follow the intended computation. This construction requires no feed-forward layers and no parameter updates. All adaptation happens through the prompt alone. These findings forge a direct link between in-context learning and algorithmic emulation, and offer a simple mechanism for large Transformers to serve as prompt-programmable libraries of algorithms. They illuminate how GPT-style foundation models may swap algorithms via prompts alone, establishing a form of algorithmic universality in modern Transformer models.

Abstract (translated)

我们证明,一个权重固定化的最小Transformer架构能够通过上下文提示来模拟一大类算法。具体来说,对于任何可以通过固定权重的注意力头实现的算法(例如一步梯度下降或线性/岭回归),都存在一种提示,可以驱动两层softmax注意力模块以任意精度重现该算法的输出。这一保证甚至适用于单个头部注意层(如果需要的话使用更长的提示),实现了架构上的最小化。我们的核心思想是构造能够将算法参数编码为标记表示形式的提示,创造出明确的点积差距,迫使softmax注意机制按照预期进行计算。这种构建不需要前向传播层和参数更新。所有适应性都通过提示单独完成。 这些发现直接建立了上下文学习与算法模拟之间的联系,并提供了一种简单的机制,使大型Transformer可以充当可通过提示编程的算法库。它们揭示了GPT风格的基础模型如何仅通过提示即可交换算法,从而在现代Transformer模型中建立了一种形式的算法普适性。

URL

https://arxiv.org/abs/2508.17550

PDF

https://arxiv.org/pdf/2508.17550.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