Kernel-Prompted Random Transformer
Implementation & benchmark of arXiv:2608.09558 — Training-Free Universal Approximation by Prompting Random Transformers
Source paper: Training-Free Universal Approximation by Prompting Random Transformers arXiv:2608.09558 ⓘ · analyzed Sep 1, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Freeze a randomly initialized single-layer transformer and use a constructed soft prompt to make its attention weights equal Gaussian-kernel weights over support examples. The resulting model performs Nadaraya-Watson regression in one forward pass, so task adaptation stores prompt tokens rather than modifying network weights. Prompt length becomes the number of kernel centers, while hidden dimension and prompt norm determine whether the required logits can be represented accurately.
Formulas
Mathematical statement
The paper embeds a query x in R^{d_in} as x_emb = [x^T,1,0,...,0] in R^{1 x d_h}, where d_in is the input dimension and d_h >= d_in+2 is the hidden dimension. For support points x_i in R^{d_in}, labels y_i in R^m, and bandwidth sigma > 0, the target attention logits are b_i(x) = -||x-x_i||_2^2/(2 sigma^2). The desired predictor is the Nadaraya-Watson estimator f_hat(x) = sum_i exp(b_i(x)) y_i / sum_j exp(b_j(x)). Let q(x) be the frozen query vector and k_i be the key vector generated by prompt token p_i; the actual attention logit is ell_i(x) = q(x)^T k_i/sqrt(d_h), up to a fixed temperature. Expanding the squared distance gives b_i(x) = -||x||^2/(2 sigma^2) + x^T x_i/sigma^2 - ||x_i||^2/(2 sigma^2). The query-dependent common term -||x||^2/(2 sigma^2) cancels in softmax, so the prompt only needs to match the affine coefficients of x and the constant term. Prompt construction solves M z_i = c_i, where z_i contains free prompt coordinates, M maps those coordinates to coefficients of ell_i(x), and c_i contains the desired coefficients x_i/sigma^2 and -||x_i||^2/(2 sigma^2). The required rank condition is that M has full row rank; under Gaussian random weights this holds almost surely when d_h is sufficiently large. If exact matching is unstable, use ridge regression.
Implementation notes
1. Integration point: implement a frozen one-layer attention module with randomly sampled Gaussian query, key, value, and output matrices. Reserve N prompt slots followed by one query slot. Encode each support example (x_i,y_i) into a prompt token, exposing enough hidden coordinates to control its key and value. Encode the query as [x^T,1,0,...,0]. Read the output at the query position and decode it as the prediction.
2. Pseudocode:
sample frozen Q,K,V,O ~ Normal(0, 1/d_h)
choose support set {(x_i,y_i)} and bandwidth sigma
for each support i:
construct target coefficients c_i from
b_i(x)=-(||x||^2 - 2*x^T*x_i + ||x_i||^2)/(2*sigma^2)
probe the frozen logit ell_i(x; z) on d_in+2 basis query embeddings
construct M mapping free prompt coordinates z to logit coefficients
z_i = solve_ridge(M, c_i, lambda)
write z_i into prompt token p_i
choose remaining value coordinates so V(p_i) decodes to y_i
for query x:
run frozen attention on [p_1,...,p_N,E(x)]
return decoded query-position output
3. Compute M analytically from the frozen linear query/key maps when possible; otherwise estimate it with finite differences around a zero prompt. Use SVD to measure rank and condition number. If the smallest singular value is small, use the ridge solution above and record the residual ||Mz_i-c_i||_2. Estimate sigma using validation data or sigma equal to a multiple of the median pairwise support distance. The paper provides the full-rank/almost-sure-randomness rationale, but the implementation must empirically measure prompt norm, logit residual, attention-weight error relative to the Gaussian kernel, and final prediction error. If key and value coordinates are coupled, solve one joint least-squares system that matches both logit coefficients and the decoded labels.
4. First experiment: compare analytical prompting against gradient-optimized soft prompts, a frozen random transformer without prompting, k-nearest neighbors, and direct Nadaraya-Watson regression. Start with a two-dimensional synthetic Holder function and 32, 64, 128, and 256 support tokens; then test MNIST or CIFAR-10 embeddings. Sweep hidden dimension, bandwidth, ridge coefficient, and prompt length. Measure adaptation time, inference latency, prompt memory, test MSE or accuracy, logit residual, and prompt norm. Success means reaching kernel-regression accuracy with no backpropagation during adaptation, lower adaptation cost than prompt tuning, and decreasing error as prompt length and hidden dimension increase.
Verification
Stage 1 · Toy mechanism gate: Passed ✓
Stage 2 · Mechanism transferred to benchmark: Confirmed ✓
Stage 2 · Practical benchmark result: Significantly worse ✗
Methodology: 8 paired seeds, permutation test (p<0.05) against a learning-rate-tuned baseline. How verification works
Stage 1 — Mechanism check agent confidence 9/10
Built an analytical frozen random-attention prompt constructor that jointly matches Gaussian-kernel logit coefficients and support labels. The mechanism manifested: rank became full at dh=4=d_in+2 with residual below 1.4e-14; kernel attention weight error was below 4.4e-15; prompt norms scaled approximately as sigma^-2, with observed ratios 1.96, 2.04, and 2.01 versus predicted 1.96, 2.04, and 2.04. Ridge regularization reduced prompt norm from 45.56 to 1.26 while residual increased from approximately 0 to 7.28. The method exactly reproduced Nadaraya-Watson regression, but did not beat 3-NN on this toy task, so this validates the mechanism rather than a general predictive win.
- Agent confidence
- 9/10
- Baseline
- Nadaraya-Watson MSE: 0.1445, 0.1380, 0.1169, 0.1202 for N=32,64,128,256; 3-NN MSE: 0.1025, 0.0346, 0.0167, 0.0114.
- Idea
- Analytical prompt matched Nadaraya-Watson exactly: MSE identical at every support size; maximum attention-weight error 1.1e-15; logit RMS residual 2.6e-15 to 2.8e-15; adaptation time 0.59-0.74 ms; prompt storage 512-4096 floats.
Limitations: No MNIST/CIFAR embedding test, multi-head or full transformer block, GPU benchmark, gradient-optimized soft-prompt comparison, or random-unprompted transformer baseline was tested. The implementation models the frozen attention algebra with Gaussian linear Q/K/V maps rather than a full tokenized transformer forward pass.
How to run: python3 kernel_prompt_experiment.py
Stage 2 — Benchmark vs. tuned baseline (arXiv:2608.09558)
Significantly WORSE than the tuned baseline (+86.0%, p=0.0081, wins 0 / 8 paired seeds).
- Benchmark
- Sequence modeling
- Model
- frozen_random_attention_prompt
- Paired seeds
- 8
- Baseline mean
- 0.9357
- Idea mean
- 1.7407
- Effect (Δ)
- 0.805 (+86.0%; negative = idea better)
- Wins
- 0 / 8 paired seeds
- p-value
- 0.0081 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- n/a
- Mechanism
- Confirmed ✓
- Practical effect
- Hurts
- Baseline tuning
- swept over 3 configs
Only the sequence track was tested; CIFAR/MNIST transfer, other built-in tracks, full multi-layer/multi-head transformer comparison, inference latency/FLOP measurements, and gradient-optimized prompts beyond the matched frozen-attention prompt baseline were not tested.
How to run: python3 stage2_bench.py
Verdict computed by deterministic test code from paired-seed statistics — not by the language model.
Stage 2 — Benchmark latest Failed ✗
Agent confidence: 10/10
Built and evaluated the Kernel-Prompted Random Transformer on the structurally matched sequence forecast track using the same frozen random-attention architecture for both systems. The mechanism signature was confirmed quantitatively: prompt-norm ratio 4.0001 versus the predicted 4.0 and best affine-logit residual 8.8e-14. However, the idea had test MSE 1.7407 versus baseline 0.9357, paired delta +0.8050 with permutation p=0.0081, so it is significantly worse and does not count as a win.
- Baseline
- Best lr=0.01 from shared grid [0.001, 0.003, 0.01]; full 8-seed MSE mean 0.9356768578, std 0.1068674329.
- Idea
- Best tested setting sigma=0.8, lr=0.01; full 8-seed MSE mean 1.7406605533, std 0.1589719376. Paired delta idea-baseline=+0.8049836955, p=0.0081, idea wins 0/8.
- Mechanism signature
- Prompt norms sigma=[0.4,0.6,0.8] were [2036.9190,905.2893,509.2197], observed 0.4/0.8 ratio 4.000079 versus predicted 4.0; observed best logit residual 8.765e-14; confirmed=true.
Benchmark result
Significantly WORSE than the tuned baseline (+86.0%, p=0.0081, wins 0 / 8 paired seeds).
- Benchmark
- Sequence modeling
- Model
- frozen_random_attention_prompt
- Paired seeds
- 8
- Baseline mean
- 0.9357
- Idea mean
- 1.7407
- Effect (Δ)
- 0.805 (+86.0%; negative = idea better)
- Wins
- 0 / 8 paired seeds
- p-value
- 0.0081 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- n/a
- Mechanism
- Confirmed ✓
- Practical effect
- Hurts
- Baseline tuning
- swept over 3 configs
Only the sequence track was tested; CIFAR/MNIST transfer, other built-in tracks, full multi-layer/multi-head transformer comparison, inference latency/FLOP measurements, and gradient-optimized prompts beyond the matched frozen-attention prompt baseline were not tested.
How to run: python3 stage2_bench.py
Artifacts
- bench_report.json 4.9 KB View Raw
- kernel_prompt_experiment.py 5.0 KB View Raw
- report.md 1.7 KB View
- report_bench_2026-09-01T112618.md 3.7 KB View
- results.json 3.8 KB View Raw
- stage2_bench.py 6.3 KB View Raw