What Kinds of Tokens Benefit from Distant Text? An Analysis on Long Context Language Modeling

Yutong Hu, Quzhe Huang, Kangcheng Luo, Yansong FengarXiv 2024 · DOI

Abstract

While large language models (LLMs) boast massive context windows, the specific types of tokens that benefit from distant information remain poorly understood. This study analyzes three long-context LLMs—Yi-6B-200K, YaRN-7B-128K, and LongLoRA-7B-100K—to identify which words gain the most from expanded context. We find that content words (nouns and adjectives) and the initial tokens of words are the primary beneficiaries. This improvement is largely driven by the model's ability to recognize repeating N-gram patterns and an increasing "overconfidence" as the context window expands.

Introduction

In the current landscape of natural language processing, the race for "infinite" context has led to LLMs routinely handling 32k, 128k, or even 200k tokens. Standard evaluations consistently show that as the context length ($K$) increases, the model's perplexity—a measure of its predictive accuracy—decreases. However, this behavior is fundamentally "un-human." Human readers and writers possess limited working memory and rarely rely on a specific word from 30,000 tokens ago to decide what to write next, unless intentionally employing complex literary devices like foreshadowing.

This research aims to bridge the gap between model performance and human cognitive limits. Is the performance boost in LLMs coming from a few "foreshadowed" tokens, or is the model utilizing distant text in a way that differs fundamentally from human processing? By analyzing how different token types respond to expanded context, we can better understand the mechanics of long-context modeling.

Methodology

The researchers analyzed three representative long-context LLMs: Yi-6B-200K, YaRN-7B-128K, and LongLoRA-7B-100K. To pinpoint the source of improvement, they introduced the concept of token-perplexity decrement. This metric compares the model's prediction of a specific token using a context of length $K$ versus a doubled context of length $2K$. If the probability of the correct token increases with the longer context, that token is considered to "benefit" from distant text.

Methodology for measuring token-perplexity decrement by comparing context lengths K and 2K.

The analysis was conducted across three primary dimensions:

  1. Lexical Properties: Utilizing Part-of-Speech (POS) tagging to determine if nouns, verbs, or adjectives benefit differently.
  2. Contextual Influence: Measuring the "New Occurrence Ratio" of N-grams (repeating phrases) to see if the model is essentially "copy-pasting" from the distant past.
  3. Model Priors: Checking if the frequency of a token in the model's original pre-training data (using RedPajama as a proxy) affects its reliance on long context.

Results and Analysis

Content is King: Lexical Benefits

A primary finding of the study is that "open words" (nouns and adjectives) benefit significantly more from long context than "closed words" (prepositions, conjunctions). This suggests that LLMs use distant text primarily to resolve semantic ambiguity rather than to follow local grammatical rules. Across all tested models, nouns consistently showed the highest perplexity decrement.

Perplexity decrement across different POS categories and context lengths for Yi, YaRN, and LongLoRA models.

The "First Token" Hurdle and N-Gram Mechanisms

For words split into multiple subword tokens, the study found that the first token receives the most substantial boost from long context. Once the model identifies the start of a word using distant cues, subsequent subwords are easily predicted using local context. Furthermore, there is a strong correlation (Spearman correlation up to 0.53) between N-gram repetition and performance. If a phrase appears in the "new" (distant) context but not the "original" (local) context, the model's predictive accuracy for that phrase improves dramatically, acting as a sophisticated pattern-matcher.

The Overconfidence Trap

Perhaps the most surprising finding is that LLMs become more "confident" (exhibiting lower entropy and higher max probability) as context grows, even when their predictions are incorrect. This suggests that the drop in perplexity observed in long-context models might be partially due to the model becoming more opinionated or "stubborn," rather than strictly more accurate in a semantic sense.

Discussion and Conclusion

The study reveals that a large portion of tokens (over 40% in most settings) show a decrease in perplexity when context is doubled, a behavior vastly different from human reading. While N-grams explain much of the performance boost, some tokens continue to benefit from extremely distant text for reasons not yet fully understood.

Furthermore, for rare tokens that appeared infrequently during pre-training, the model relies much more heavily on the provided context. The discovery of "overconfidence" suggests that researchers need to look beyond simple perplexity scores to ensure long-context models are truly becoming more capable. Future model design should focus on ensuring that expanded context leads to genuine intelligence rather than just increased pattern-matching confidence.

Summary updated

BibTeX
@misc{hu2024what,
  author = {Yutong Hu and Quzhe Huang and Kangcheng Luo and Yansong Feng},
  title = {{What Kinds of Tokens Benefit from Distant Text? An Analysis on Long Context Language Modeling}},
  year = {2024},
  eprint = {2406.11238},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.11238},
}
Figure