LLM-Microscope: Uncovering the Hidden Role of Punctuation in Context Memory of Transformers

Anton Razzhigaev, Matvey Mikhalchuk, Temurbek Rahmatullaev, Elizaveta Goncharova, Polina Druzhinina, Ivan V. Oseledets, Andrey Kuznetsov

Introduction

Large Language Models (LLMs) have revolutionized natural language processing, yet their internal mechanics for context retention remain largely opaque. Traditional linguistic intuition suggests that "content words"—nouns, verbs, and adjectives—carry the primary semantic weight, while "function words" and punctuation are secondary. This research challenges that paradigm, investigating how context is aggregated and stored within high-dimensional embeddings. By introducing the LLM-Microscope toolkit, this study reveals that seemingly trivial "filler" tokens, such as commas and articles, serve as the primary anchors for contextual memory.

Methods: The LLM-Microscope Framework

The researchers developed LLM-Microscope, an open-source framework designed to quantify how different tokens preserve information across model layers. A core component of this framework is the Contextualization Assessment, also known as Prefix Reconstruction.

Prefix Reconstruction

In this method, a small Multi-Layer Perceptron (MLP) adapter is trained to determine if the embedding of a single token can reconstruct the entire preceding text prefix. If a token's hidden state allows for the accurate reconstruction of the previous 50 words, it is identified as being highly contextualized.

Prefix Reconstruction Method: An adapter is trained to reconstruct the preceding text from a single token's embedding.

Additional techniques within the toolkit include:

  • Token-level Nonlinearity: Measuring layer-to-layer transformations using Procrustes analysis to correlate linearity with context retention.
  • Adapted Logit Lens: Projecting intermediate hidden states into the vocabulary space to observe mid-computation "thoughts."
  • Intrinsic Dimensionality: Estimating representation complexity through the scaling of embedding volumes.

Datasets and Evaluation

To train the reconstruction adapters, the researchers utilized a suite of "Tiny" datasets, including TinyStories, Tiny-Textbooks, and Tiny-Codes. Evaluation was conducted across several benchmarks: MMLU for general knowledge, BABILong-4k for long-context reasoning, and random Wikipedia fragments to analyze the relationship between linearity and memory.

Key Insights: The Memory of "Filler" Tokens

The most striking finding is that determiners (e.g., "the", "a") and punctuation (e.g., commas, periods) are the most "memory-retentive" tokens. While nouns and adjectives tend to focus on their specific semantic meanings—a behavior described as "selfish"—filler tokens act as vessels that the model populates with global context.

Distribution of reconstruction loss scores by Part of Speech across various LLMs, showing lower loss for determiners and punctuation.

The analysis across multiple model families, including Llama, OPT, and Phi, consistently showed that Determiners (DT) and Punctuation exhibit the lowest reconstruction loss. This indicates they are significantly better at "remembering" the preceding text than content-heavy nouns (NN). Furthermore, a strong correlation exists between the linearity of a token's processing and its contextualization score, suggesting that more linear transitions facilitate better memory retention. Interestingly, the Logit Lens reveals that when processing non-English text, intermediate layers often "think" in English before translating back to the target language.

Performance Impact and Results

The structural necessity of these filler tokens was confirmed through ablation studies. On the BABILong-4k benchmark, a long-context reasoning task, removing stopwords and punctuation led to a significant drop in accuracy. For instance, Llama-3-8B saw its score plummet from 0.388 to 0.307. Similar performance degradation was observed in general knowledge tasks like MMLU across all tested models (Mistral, Qwen, Phi).

Even when using advanced models like GPT-4o to selectively remove "irrelevant" tokens, the underlying LLM's performance suffered. This suggests that the presence of these tokens is not merely a linguistic artifact but a structural requirement for the model's internal reasoning and context aggregation processes.

Limitations and Future Work

While the patterns held across several model families, the authors acknowledge that the method for measuring context relies on a trained MLP adapter, whose own architecture could influence results. Additionally, applying the final LM-head to intermediate layers (Logit Lens) assumes those layers share a vocabulary space with the output layer. Future work will focus on refining these techniques and exploring how these insights lead to more efficient "context-aware" pruning that preserves vital filler tokens while discarding truly redundant data.

Summary updated

BibTeX
@inproceedings{razzhigaev2025llm,
  author = {Anton Razzhigaev and Matvey Mikhalchuk and Temurbek Rahmatullaev and Elizaveta Goncharova and Polina Druzhinina and Ivan V. Oseledets and Andrey Kuznetsov},
  title = {{LLM-Microscope: Uncovering the Hidden Role of Punctuation in Context Memory of Transformers}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.findings-naacl.432},
}
Figure