Training-Free Universal Approximation by Prompting Random Transformers
2026-08-10 • Machine Learning
Machine Learning
AI summaryⓘ
The authors explore how much a transformer model can learn just by using prompts, without changing its internal weights. They show that even a very simple transformer with random weights can mimic complex functions when given the right soft prompt, similar to how certain kernel methods work. Their math proves this approach can approximate any smooth function with good accuracy, depending on the data's complexity. They also explain a tradeoff involving prompt size, strength, and model dimensions, and confirm their theory with experiments.
transformerpromptingsoftmax attentionkernel methodsNadaraya-Watson estimatoruniversal approximationHölder functionsGaussian initializationminimax rates
Authors
Alexander Hsu, Rongjie Lai
Abstract
How expressive is prompting a transformer? Answering this question is important for separating the roles of prompting, architecture, and pretraining in transformer models, and for determining whether task-specific behavior must be stored in model weights or can instead be induced at inference time through the prompt. We show, in an approximation-theoretic sense, that pretraining is optional: a single-layer softmax attention network with random, untrained weights can approximate any Hölder function on a compact manifold when steered by an appropriate soft prompt. Guided by the connection between softmax attention and kernel methods, we construct explicit soft prompts (a prompt per target function, independent of the query) as solutions to linear systems matching attention logits to Gaussian kernel exponents, under which the frozen transformer emulates the classical Nadaraya-Watson kernel estimator. The construction requires only a mild rank condition on the weights, which we show holds almost surely under Gaussian initialization. The prompted network inherits the theoretical guarantees of kernel regression, leading to universal approximation theorems with minimax-optimal rates that depend on the intrinsic dimension. We further quantify the cost of prompting, exposing a tradeoff between the norm of the constructed soft prompt tokens, prompt length, and hidden dimension. Numerical experiments corroborate the constructions and predicted rates.