paper-with-me

홈 › Papers

Mechanics of Next Token Prediction with Self-Attention

2024-03-12 · Yingcong Li, Yixiao Huang, M. Emrullah Ildiz, Ankit Singh Rawat, Samet Oymak

Transformer-based language models are trained on large datasets to predict the next token given an input sequence. Despite this simple training objective, they have led to revolutionary advances in natural language processing. Underlying this success is the self-attention mechanism. In this work, we ask: $\textit{What}$ $\textit{does}$ $\textit{a}$ $\textit{single}$ $\textit{self-attention}$ $\textit{layer}$ $\textit{learn}$ $\textit{from}$ $\textit{next-token}$ $\textit{prediction?}$ We show that training self-attention with gradient descent learns an automaton which generates the next token in two distinct steps: $\textbf{(1)}$ $\textbf{Hard}$ $\textbf{retrieval:}$ Given input sequence, self-attention precisely selects the $\textit{high-priority}$ $\textit{input}$ $\textit{tokens}$ associated with the last input token. $\textbf{(2)}$ $\textbf{Soft}$ $\textbf{composition:}$ It then creates a convex combination of the high-priority tokens from which the next token can be sampled. Under suitable conditions, we rigorously characterize these mechanics through a directed graph over tokens extracted from the training data. We prove that gradient descent implicitly discovers the strongly-connected components (SCC) of this graph and self-attention learns to retrieve the tokens that belong to the highest-priority SCC available in the context window. Our theory relies on decomposing the model weights into a directional component and a finite component that correspond to hard retrieval and soft composition steps respectively. This also formalizes a related implicit bias formula conjectured in [Tarzanagh et al. 2023]. We hope that these findings shed light on how self-attention processes sequential data and pave the path toward demystifying more complex architectures.

📄 PDF Abstract BibTeX arXiv:2403.08081

Code (0)

등록된 구현이 없습니다.

Tasks

PredictionRetrieval

Similar Papers 제목 키워드 기반

Next-Latent Prediction Transformers Learn Compact World Models

2025-11-08 · Jayden Teoh, Manan Tomar, Kwangjun Ahn, Edward S. Hu 외 arxiv

Transformers replace recurrence with a memory that grows with sequence length and self-attention that enables ad-hoc lookups over past tokens. Consequently, they lack an inherent incentive to compress history into compac…

Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformer

2023-05-25 · NeurIPS 2023 11

Transformer architecture has shown impressive performance in multiple research domains and has become the backbone of many neural network models. However, there is limited understanding on how it works. In particular, wi…

DecoderInductive Bias

ToSA: Token Selective Attention for Efficient Vision Transformers

2024-06-13 · Manish Kumar Singh, Rajeev Yasarla, Hong Cai, Mingu Lee 외

In this paper, we propose a novel token selective attention approach, ToSA, which can identify tokens that need to be attended as well as those that can skip a transformer layer. More specifically, a token selector parse…

Depth EstimationDepth PredictionMonocular Depth EstimationPrediction

Next-token prediction capacity: general upper bounds and a lower bound for transformers

2024-05-22 · Liam Madden, Curtis Fox, Christos Thrampoulidis

Given a sequence of tokens, such as words, the task of next-token prediction is to predict the next-token conditional probability distribution. Decoder-only transformers have become effective models for this task, but th…

DecoderMemorization

Dynamics of Spontaneous Topic Changes in Next Token Prediction with Self-Attention

2025-01-10 · Mumin Jia, Jairo Diaz-Rodriguez

Human cognition is punctuated by abrupt, spontaneous shifts between topics-driven by emotional, contextual, or associative cues-a phenomenon known as spontaneous thought in neuroscience. In contrast, self-attention based…