atlas

Research map / Architectures and efficiency / Attention and transformers

Learning In-context $n$-grams with Transformers: Sub-$n$-grams Are Near-Stationary Points

ICML 2025 · Architectures and efficiency › Attention and transformers · approach: Transformer expressivity and learnability

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 sub-n-gram solutions implemented by a simplified two-layer disentangled transformer are near-stationary points of the in-context n-gram population cross-entropy loss, with a numerical stage-wise learning experiment for trigrams.

Problem

Explaining the long plateaus and stage-wise learning dynamics when transformers learn in-context n-gram language models with cross-entropy loss.

Approach

Gives a sufficient stationarity condition for CE loss when the model's score depends only on a suffix of the context, then constructs two-layer transformer parameters implementing k-gram MLE estimators (k ≤ n) whose population gradient vanishes as sequence length T and weight scale c go to infinity.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
learn attention to the previous token after initially uniform attentionSimplified two-layer Transformer · Trigram language model, vocabulary size 5, sequence length 32test lossHelped
shift the second attention head from the previous token to the token two positions backSimplified two-layer Transformer · Trigram language model, vocabulary size 5, sequence length 32test lossHelped

Surprising findings

Limitations

Experimental setup

Datasets: synthetic in-context trigram sequences (Dirichlet(0.5) transition priors, vocabulary 5)

Metrics: population cross-entropy loss gradient norm bound attention maps

Builds on: induction heads disentangled transformer

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