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

Mumin Jia, Jairo Diaz Rodriguez · OpenReview

Abstract

Human cognition is characterized by spontaneous thought—abrupt, associative shifts between topics driven by internal or external cues. In contrast, Large Language Models (LLMs) rely on self-attention mechanisms to predict the next token based on structured input patterns. This paper investigates whether LLMs exhibit similar spontaneous drift. By formalizing topics through Token Priority Graphs (TPGs), we demonstrate that self-attention architectures are mathematically predisposed toward topic stability. Our findings reveal that, unlike humans, LLMs become more focused as context length increases or as topics become more ambiguous, highlighting a fundamental divergence between artificial and human cognition.

Introduction

In neuroscience, "spontaneous thought" refers to the mind's tendency to wander, making sudden leaps between concepts. This behavior is often triggered by emotional states or subtle sensory associations. Conversely, the transformer architecture, which powers modern LLMs, is designed for consistency through next-token prediction. While LLMs are known for their ability to maintain context, a formal mathematical understanding of their resistance to spontaneous drift has been lacking. This study aims to bridge this gap by investigating the conditions under which a self-attention model might "spontaneously" switch from one topic to another.

Theoretical Framework

To analyze these dynamics, we define a Topic as a set of Token Priority Graphs (TPGs). In this model, tokens are nodes in a graph where edges represent the statistical probability of one token following another. A "spontaneous change" occurs when a model, given an input sequence from Topic A, predicts a token belonging to Topic B.

Conceptual framework for analyzing topic transitions in self-attention models.

Our analysis of a simplified, single-layer self-attention model led to the discovery of the "Outvoting" Rule. Theoretically, a topic change can only occur if the number of lower-priority tokens (those less central to the current topic) in the input sequence significantly outweighs the higher-priority tokens. This suggests that for an LLM, switching topics is a statistical numbers game rather than an associative leap.

Key Results

The study validated its theoretical predictions through experiments on frontier models, including GPT-4o, Llama-3.3, Claude-3.7, and DeepSeek-V3. The researchers used Retrieval-Augmented Generation (RAG) to provide models with specific "knowledge" from recent arXiv papers, ensuring no data leakage from training.

Stability via Context Length

A primary finding is that the probability of a topic change vanishes as the sequence length ($T$) increases. In human conversation, longer durations often lead to tangents; however, for LLMs, more context serves as a stabilizing anchor. As $T \to \infty$, the model's attention mechanism becomes increasingly locked onto the established topic.

Resistance to Ambiguity

The researchers also explored Topic Ambiguity ($L$), defined by the overlap of keywords between different topics. In humans, ambiguity often triggers a shift in focus. In LLMs, however, ambiguity acts as a stabilizing factor. While it may result in "fuzzier" outputs, it does not increase the likelihood of the model jumping to an unrelated topic.

Proportion of topic outcomes relative to sequence length (T) and topic ambiguity (L).

Discussion and Cognitive Disparity

The results underscore a "fundamental disparity" between AI and human thought. LLMs follow a structured, statistical path that rewards consistency and context-heavy stability. Human cognition, by contrast, is punctuated by unstructured, sensory-driven redirection.

While the current theoretical proofs are limited to single-layer models, the empirical consistency across deep, multi-layer frontier models suggests that these principles are inherent to the self-attention mechanism itself. Future research will focus on extending these mathematical proofs to multi-layer architectures and investigating how these dynamics behave over extremely long generated outputs where hallucinations might mimic topic shifts.

Conclusion

This work provides the first formal characterization of spontaneous topic changes in self-attention architectures. By proving that longer contexts and ambiguity increase topic stability, we highlight the mechanical nature of LLM "focus," which stands in stark contrast to the fluid, wandering nature of the human mind.

Summary updated

BibTeX
@inproceedings{jia2025dynamics,
  author = {Mumin Jia and Jairo Diaz Rodriguez},
  title = {{Dynamics of "Spontaneous" Topic Changes in Next Token Prediction with Self-Attention}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=nMLvTru6Zo},
}
Figure