Table of Contents
Fetching ...

Memory Retrieval and Consolidation in Large Language Models through Function Tokens

Shaohua Zhang, Yuan Lin, Hang Li

TL;DR

Memory retrieval and consolidation in LLMs are analyzed through the Function Token Hypothesis, which posits a division between function tokens (high-frequency connectors) and content tokens (semantic content). The authors show that a small set of function tokens activate most features during inference (memory retrieval), while predicting content tokens after function tokens drives feature expansion during pre-training (memory consolidation). Evidence comes from a token-feature bipartite graph, Sparse Autoencoder–based feature decompositions, and controlled pre-training experiments that reveal a scale-free, function-token–driven access to the model's feature space. These findings offer interpretable insights into how LLMs store and reuse knowledge and have implications for designing training and alignment strategies.

Abstract

The remarkable success of large language models (LLMs) stems from their ability to consolidate vast amounts of knowledge into the memory during pre-training and to retrieve it from the memory during inference, enabling advanced capabilities such as knowledge memorization, instruction-following and reasoning. However, the mechanisms of memory retrieval and consolidation in LLMs remain poorly understood. In this paper, we propose the function token hypothesis to explain the workings of LLMs: During inference, function tokens activate the most predictive features from context and govern next token prediction (memory retrieval). During pre-training, predicting the next tokens (usually content tokens) that follow function tokens increases the number of learned features of LLMs and updates the model parameters (memory consolidation). Function tokens here roughly correspond to function words in linguistics, including punctuation marks, articles, prepositions, and conjunctions, in contrast to content tokens. We provide extensive experimental evidence supporting this hypothesis. Using bipartite graph analysis, we show that a small number of function tokens activate the majority of features. Case studies further reveal how function tokens activate the most predictive features from context to direct next token prediction. We also find that during pre-training, the training loss is dominated by predicting the next content tokens following function tokens, which forces the function tokens to select the most predictive features from context.

Memory Retrieval and Consolidation in Large Language Models through Function Tokens

TL;DR

Memory retrieval and consolidation in LLMs are analyzed through the Function Token Hypothesis, which posits a division between function tokens (high-frequency connectors) and content tokens (semantic content). The authors show that a small set of function tokens activate most features during inference (memory retrieval), while predicting content tokens after function tokens drives feature expansion during pre-training (memory consolidation). Evidence comes from a token-feature bipartite graph, Sparse Autoencoder–based feature decompositions, and controlled pre-training experiments that reveal a scale-free, function-token–driven access to the model's feature space. These findings offer interpretable insights into how LLMs store and reuse knowledge and have implications for designing training and alignment strategies.

Abstract

The remarkable success of large language models (LLMs) stems from their ability to consolidate vast amounts of knowledge into the memory during pre-training and to retrieve it from the memory during inference, enabling advanced capabilities such as knowledge memorization, instruction-following and reasoning. However, the mechanisms of memory retrieval and consolidation in LLMs remain poorly understood. In this paper, we propose the function token hypothesis to explain the workings of LLMs: During inference, function tokens activate the most predictive features from context and govern next token prediction (memory retrieval). During pre-training, predicting the next tokens (usually content tokens) that follow function tokens increases the number of learned features of LLMs and updates the model parameters (memory consolidation). Function tokens here roughly correspond to function words in linguistics, including punctuation marks, articles, prepositions, and conjunctions, in contrast to content tokens. We provide extensive experimental evidence supporting this hypothesis. Using bipartite graph analysis, we show that a small number of function tokens activate the majority of features. Case studies further reveal how function tokens activate the most predictive features from context to direct next token prediction. We also find that during pre-training, the training loss is dominated by predicting the next content tokens following function tokens, which forces the function tokens to select the most predictive features from context.

Paper Structure

This paper contains 18 sections, 7 equations, 12 figures, 1 table.

Figures (12)

  • Figure 1: Function tokens can dynamically activate the most predictive features from the context to guide the next-token prediction. For example, the function token 'in' reactivates features 'J.K. Rowling' and 'Location' from context (while suppressing feature 'French') and activates 'England' to predict 'Britain'. In contrast, the content token 'Harry' activates feature 'Harry Potter'.
  • Figure 2: Token frequency statistics in SlimPajama-627B.
  • Figure 3: Distribution of function and content tokens. Document bins represent equal partitions of corpus documents.
  • Figure 4: Construction of the bipartite graph using token-feature activation pairs as edges. Nodes consist of tokens from the vocabulary and features from the SAE decomposition.
  • Figure 5: Token degrees in the token-feature bipartite graph on a log-log scale. Tokens are ranked by frequency from the sampled data.
  • ...and 7 more figures