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

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Varre, Aditya, Yüce, Gizem, Flammarion, Nicolas
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866916907575148544
author Varre, Aditya
Yüce, Gizem
Flammarion, Nicolas
author_facet Varre, Aditya
Yüce, Gizem
Flammarion, Nicolas
contents Motivated by empirical observations of prolonged plateaus and stage-wise progression during training, we investigate the loss landscape of transformer models trained on in-context next-token prediction tasks. In particular, we focus on learning in-context $n$-gram language models under cross-entropy loss, and establish a sufficient condition for parameter configurations to be stationary points. We then construct a set of parameter configurations for a simplified transformer model that represent $k$-gram estimators (for $k \leq n$), and show that the gradient of the population loss at these solutions vanishes in the limit of infinite sequence length and parameter norm. This reveals a key property of the loss landscape: {sub-$n$-grams are near-stationary points of the population cross-entropy loss}, offering theoretical insight into widely observed phenomena such as stage-wise learning dynamics and emergent phase transitions. These insights are further supported by numerical experiments that illustrate the learning dynamics of $n$-grams, characterized by discrete transitions between near-stationary solutions.
format Preprint
id arxiv_https___arxiv_org_abs_2508_12837
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Learning In-context n-grams with Transformers: Sub-n-grams Are Near-stationary Points
Varre, Aditya
Yüce, Gizem
Flammarion, Nicolas
Machine Learning
Motivated by empirical observations of prolonged plateaus and stage-wise progression during training, we investigate the loss landscape of transformer models trained on in-context next-token prediction tasks. In particular, we focus on learning in-context $n$-gram language models under cross-entropy loss, and establish a sufficient condition for parameter configurations to be stationary points. We then construct a set of parameter configurations for a simplified transformer model that represent $k$-gram estimators (for $k \leq n$), and show that the gradient of the population loss at these solutions vanishes in the limit of infinite sequence length and parameter norm. This reveals a key property of the loss landscape: {sub-$n$-grams are near-stationary points of the population cross-entropy loss}, offering theoretical insight into widely observed phenomena such as stage-wise learning dynamics and emergent phase transitions. These insights are further supported by numerical experiments that illustrate the learning dynamics of $n$-grams, characterized by discrete transitions between near-stationary solutions.
title Learning In-context n-grams with Transformers: Sub-n-grams Are Near-stationary Points
topic Machine Learning
url https://arxiv.org/abs/2508.12837