Skip to main content
QUICK REVIEW

[Paper Review] Sharp Nearby, Fuzzy Far Away: How Neural Language Models Use Context

Urvashi Khandelwal, He He|arXiv (Cornell University)|May 12, 2018
Topic ModelingComputer Science15 references62 citations
TL;DR

The paper analyzes how LSTM language models use contextual information, finding about 200 tokens of effective context, with nearby context being order-sensitive only within the last sentence, and distant context forming a rough semantic field aided by neural caching for copying words.

ABSTRACT

We know very little about how neural language models (LM) use prior linguistic context. In this paper, we investigate the role of context in an LSTM LM, through ablation studies. Specifically, we analyze the increase in perplexity when prior context words are shuffled, replaced, or dropped. On two standard datasets, Penn Treebank and WikiText-2, we find that the model is capable of using about 200 tokens of context on average, but sharply distinguishes nearby context (recent 50 tokens) from the distant history. The model is highly sensitive to the order of words within the most recent sentence, but ignores word order in the long-range context (beyond 50 tokens), suggesting the distant past is modeled only as a rough semantic field or topic. We further find that the neural caching model (Grave et al., 2017b) especially helps the LSTM to copy words from within this distant context. Overall, our analysis not only provides a better understanding of how neural LMs use their context, but also sheds light on recent success from cache-based models.

Motivation & Objective

  • Determine how many tokens of prior context LSTM LMs effectively use.
  • Differentiate how nearby versus long-range context are represented in LSTM LMs.
  • Assess the impact of word order and word identity in different regions of context.
  • Evaluate how a neural cache copy mechanism helps leverage distant context.

Proposed method

  • Perform ablation tests by perturbing prior context at test time (truncate, shuffle, replace, drop).
  • Use a standard LSTM LM trained on PTB and WikiText-2 with and without a neural cache.
  • Compare performance using perplexity/NLL across perturbations.
  • Analyze word-type (content vs. function) and POS categories to see context dependence.
  • Incorporate neural cache to measure its effect on copying from nearby vs. far context.

Experimental results

Research questions

  • RQ1How much prior context do neural LMs effectively use (in tokens)?
  • RQ2Do nearby and long-range contexts contribute differently to predictions in LSTMs?
  • RQ3How does word order influence predictions in near versus distant context?
  • RQ4Do copy mechanisms (neural cache) help leverage distant context more effectively?

Key findings

  • LSTMs effectively use about 200 tokens of context on average (PTB and WikiText-2).
  • Word order matters only within the most recent ~20 tokens; global word order effects vanish after about 50 tokens, indicating a rough semantic representation for distant words.
  • Content words require more context than function words; infrequent words require more context than frequent ones.
  • A neural cache significantly improves copying from long-range context, especially for words that can only be copied from distant context, while also sometimes harming words not present in history.
  • Replacing target words with other tokens hurts nearby-context-copying words more than dropping them, suggesting nearby-context copying relies on exact occurrences.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.