atlas

Research map / Architectures and efficiency / Attention and transformers

One-Layer Transformer Provably Learns One-Nearest Neighbor In Context

NeurIPS 2024 · Architectures and efficiency › Attention and transformers · approach: Transformer expressivity and learnability · 0 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Shows that a single frozen-value softmax attention layer trained with gradient descent on a 1-nearest-neighbor ICL task converges to zero loss despite nonconvexity, and that the learned model behaves like 1-NN under distribution shift.

Problem

Whether transformers can provably learn a nonparametric algorithm (one-nearest neighbor) in context under gradient-based training, given the nonconvex loss landscape of softmax attention.

Approach

Reduces the gradient dynamics of a one-layer softmax attention model (frozen value matrix, merged query-key matrix, specific initialization) to a two-parameter dynamical system, proves loss convergence to zero, and shows robustness of the learned predictor under prompt/query distribution shift.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Train the one-layer softmax-attention transformer by gradient descent with the specified initialization and sufficiently large σOne-layer softmax-attention transformer · 1-NN in-context learningtraining loss: converges to 0Helped
Train the transformer for K gradient-descent iterations under the stated margin and bounded-label conditionsOne-layer softmax-attention transformer · Distribution-shifted 1-NN predictionsquared prediction error: O\big(\inf_{\delta}\big\{R^2N^2K^{-\poly(N,d)\delta} + R^2\PP^{\text{test}}(A_\delta^c)\big\}\big)Helped
Train for enough gradient steps when test queries are separated from the decision boundaryOne-layer softmax-attention transformer · Distribution-shifted classification with boundary separationclassification error after rounding: 0Helped
Use SGD and random Gaussian initialization instead of the theorem's specified initialization and full-batch gradient descentSingle-layer transformer · 1-NN in-context learningtraining lossHelped
Increase context length N or input dimension dSingle-layer transformer trained on 1-NN · 1-NN in-context learningconvergence speedHurt
Evaluate on a test distribution whose queries are separated from the decision boundaryTrained single-layer transformer · Well-separated distribution-shifted test setMSE to 1-NN predictorHelped

Surprising findings

Limitations

Experimental setup

Datasets: synthetic 1-NN prompts sampled uniformly on the sphere

Benchmarks: synthetic 1-NN prompts (training distribution) synthetic well-separated test distribution

Metrics: MSE loss MSE to 1-NN predictor

Builds on: linear self-attention in-context learning theory gradient flow analysis of transformers

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy