# Pointer Sentinel Mixture Models

Pointer sentinel mixtures let language models copy rare words from recent context

Stephen Merity, Caiming Xiong, James Bradbury, Richard Socher · arXiv · 2016-9-26

- **Problem** Softmax language models struggle to predict rare or unseen words, even when the context makes them clear. They must squeeze earlier words into a fixed-size hidden state, which is lossy for rare words.
- **Method** The pointer sentinel mixture model mixes a softmax over the vocabulary with a pointer over recent words. A sentinel score in the attention decides how much weight each part gets.
- **Results** On the Penn Treebank, the pointer sentinel LSTM achieves state of the art, 70.9 perplexity, with far fewer parameters than a standard softmax LSTM.

## Why rare words are hard for softmax models

Language models often need to predict a word that was introduced earlier, such as a person's name mentioned a few paragraphs back. A standard recurrent model has to squeeze that name into a fixed-size hidden state, keep it there over many steps, and decode it at the right moment. Because the hidden state has limited capacity and gradients vanish over long spans, this storage is lossy, and the loss is worst for rare words.

Attention and memory components help by letting a model retrieve earlier hidden states, but the final softmax over a fixed vocabulary still tends to miss rare or previously unknown words. Pointer networks avoid the fixed vocabulary by choosing an element of the input as the output, so they can emit tokens seen earlier in the text. A pointer network cannot emit a word that is absent from its input, which is a common situation in language modeling.

The question is whether one model can copy from recent context when that is possible and fall back to a softmax when it is not. The evaluation side has a related problem: the Penn Treebank has a 10k-word vocabulary and tokens that are lowercased and stripped of punctuation, so it may not test rare-word behaviour over long contexts.

## Pointer attention over a recent window

The base model is an LSTM whose final hidden state, after the last context word, is passed through a softmax over the vocabulary, giving a distribution with one row of weights per vocabulary word. The pointer needs its own query, so the last hidden state is projected by a linear map followed by tanh, giving q equals tanh of W h\_{N-1} plus b.

Taking the inner product of the last hidden state with itself would bias attention toward the most recent word, which is why the projection is used.

Each hidden state in the window receives a score z\_i equal to q transposed times h\_i, and a softmax turns those scores into attention weights a. A word's pointer probability is the sum of attention weights over every window position where that word occurs, which the paper calls pointer sum attention. Summing over occurrences lets a name that appears twice in a window receive mass from both mentions, while the supervision signal does not punish the model when the mass sits on any correct occurrence.

The window holds only the L most recent positions, because keeping every earlier position would be impractical for long documents. L is a hyperparameter that can be set on held-out data or by measuring how often a word at position t recurs within the last L words.

## A sentinel decides between pointer and vocabulary

The model appends one more score to the attention scores, computed as the inner product of the query with a learned sentinel vector s in R^H. The softmax is then taken over the window scores together with this sentinel score, so the attention distribution has V plus one entries, with the sentinel's weight read off as the gate value g. The sentinel also ends the pointer search, so any mass that is not spent on window words goes to the RNN vocabulary.

The gate is not produced by a separate switch that reads only the RNN state. It is part of the attention, so it depends on both the query and the contents of the window. The authors argue that this lets the two components compete: the pointer is used whenever it can match, and the softmax takes over otherwise. They report that this competition was crucial to their best model.

The pointer distribution is renormalized over the window words by a factor of one over one minus g, so it sums to one without the gate mass. The final mixture gives weight g to the vocabulary distribution and one minus g to the pointer distribution, so a value of 0 uses only the pointer and a value of 1 uses only the RNN. The RNN and the pointer share most of their parameters, which keeps the total parameter count low and lets the pointer's supervision help the RNN.

The new parameters are only W and b for the query and the sentinel vector s, which is H squared plus 2H in total. That count does not depend on the RNN depth, because the pointer only reads the output of the final RNN layer.

## Loss and training window

Training minimizes the cross-entropy between the one-hot target and the mixed probability, so only the probability of the correct word has to be computed for each step. The pointer part of the loss is the negative log of the gate plus the summed attention over the positions of the correct word, written as minus log of g plus the sum of a\_i over positions in I(y, x).

If all mass goes to the gate, the pointer part of the loss is zero and the loss comes entirely from the RNN component.

Stale RNN outputs in the pointer window would give incorrect gradients, but regenerating the whole window at each step is far slower. The authors make no theoretical guarantee about the effect of stale outputs, so they regenerate the window of RNN outputs after each gradient update. Truncated backpropagation is set to one step of advance with L steps of backpropagation, so the loss of the final predicted word is pushed through the whole window at each step.

The Penn Treebank experiments use a medium configuration with a hidden size of 650 and a two-layer LSTM, and they follow the setup of Zaremba et al. (2014) and Gal (2015). Training uses 100 timesteps, up from 35, with batch size 32, halves the learning rate when validation perplexity worsens, and stops after three epochs without improvement or at 64 epochs.

Gradients are rescaled when their global norm exceeds 1, and the dropout for the variational model is 0.5 on both connections.

## Building WikiText from Wikipedia

The authors selected articles that had been rated Good or Featured under Wikipedia's editorial criteria, which gave 23,805 Good articles and 4,790 Featured articles. Text was pulled from the Wikipedia API, and then the macro-heavy markup was cleaned up, list-heavy sections were removed by default, and formulae and LaTeX became formula tokens.

Tokenization used the Moses tokenizer with a modification that splits numbers, and words seen fewer than three times were replaced by an unk token. The file format follows the conventions of the Penn Treebank data, so existing language modeling tools can read it.

WikiText-2 has 2,088,628 training tokens and a vocabulary of 33,278 words, while WikiText-103 has 103,227,021 training tokens and a vocabulary of 267,735 words. The Penn Treebank has 929,590 training tokens and a 10,000-word vocabulary, and its OoV rate is 4.8%. WikiText-2 is about twice the size of the Penn Treebank, and the full WikiText corpus is over 103 million words, roughly a hundred times larger, with articles that keep longer dependencies intact.

## WikiText-2 results

No prior baselines exist on WikiText-2, so the comparison uses the zoneout variational LSTM and the medium variational LSTM of Gal (2015). All three models use a two-layer LSTM with hidden size 650, and hyperparameters carry over from the best Penn Treebank setup.

The pointer model's margin over these two baselines is the same direction as on the Penn Treebank.

The large Gal (2015) variant, a two-layer LSTM with hidden size 1500, ran out of memory on a 12GB K80 GPU, which the authors attribute to the larger vocabulary. As a result, no large-model WikiText-2 baseline is available, and the comparison covers only the medium setting.

## Where the pointer helps: rare words and pointer use

The bucket analysis on the Penn Treebank sorts words by frequency, splits them into equal-sized buckets, and reports the mean difference in log perplexity between the pointer sentinel-LSTM and the LSTM. The gain grows as words become rarer, which fits the idea that the pointer lets the model copy rare words without storing them in the hidden state.

The authors also see a smaller but real gain on relatively frequent words, which they attribute either to the pointer picking the word directly or to the pointer supervision that sends gradients to other occurrences in the window.

Company names such as Honeywell (8 times in training) and Integrated (41 times in training) were also often copied, though the Integrated count includes generic uses after lowercasing.

The pointer was also used for frequent items such as units of measurement and short-scale number words, and for some frequent verbs such as said. In some cases the pointer reached the last positions of the 100-word window, position 97, which is far beyond the 35 steps that most models truncate backpropagation to, so the gate needs access to the window contents rather than the RNN state alone.

## Limitations

The Penn Treebank vocabulary is capped at 10k words with lowercased, unpunctuated tokens, which the authors argue is unrealistic for real language use with many rare words. WikiText results are reported only for the medium two-layer setting, since the large baseline ran out of memory.

The training scheme depends on regenerating the pointer window after each update, and the authors have no theoretical guarantee about how stale outputs affect the gradients. Truncated backpropagation is run with one step of advance over L steps, which is a different schedule from most language modeling code.

The reported comparisons pair the full model with the zoneout RNN baseline, so the separate effect of the sentinel gate is not isolated in these tables. The qualitative pointer analysis uses selected validation examples, so it shows how the gate behaves in those cases and does not measure gate use across the whole validation set.

## Paper info

- **Authors**: Stephen Merity, Caiming Xiong, James Bradbury, Richard Socher
- **Venue**: arXiv · Preprint
- **First published**: 2016-9-26
- **Added**: 2026-11-12
- **Updated**: 2016-9-26
- **Version**: v1
- **arXiv**: 1609.07843
- **Category**: cs.CL · cs.AI
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1609.07843v1) · [PDF ↗](https://arxiv.org/pdf/1609.07843v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Stephen Merity, Caiming Xiong, James Bradbury, Richard Socher (2016). Pointer Sentinel Mixture Models. arXiv:1609.07843v1. https://arxiv.org/abs/1609.07843v1

**BibTeX**

```
@misc{merity2016pointer,
  title = {{Pointer Sentinel Mixture Models}},
  author = {Stephen Merity and Caiming Xiong and James Bradbury and Richard Socher},
  year = {2016},
  eprint = {1609.07843},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1609.07843v1}
}
```

## Other paper commentary

- [TriviaQA: A Large Scale Distantly Supervised Challenge Dataset for Reading Comprehension](https://refivu.com/en/papers/34db6f08-4b90-47eb-a2d8-fd0c5a90bf6e-triviaqa-a-large-scale-distantly-supervised-challenge.md)
- [Convolutional Sequence to Sequence Learning](https://refivu.com/en/papers/48e91a54-308d-4269-9616-28e683053df1-convolutional-sequence-to-sequence-learning.md)
- [LexRank: Graph-based Lexical Centrality as Salience in Text Summarization](https://refivu.com/en/papers/11b54298-bb68-4667-a225-10b7dade3a5a-lexrank-graph-based-lexical-centrality-as-salience-in.md)
- [Embedding Entities and Relations for Learning and Inference in Knowledge Bases](https://refivu.com/en/papers/d1a4fc27-43e3-48ba-b0b6-d1a50a552670-embedding-entities-and-relations-for-learning-and-inference.md)
- [Semantics derived automatically from language corpora contain human-like biases](https://refivu.com/en/papers/abf5bfd6-5402-457c-958c-81fe475605f3-semantics-derived-automatically-from-language-corpora.md)
- [Using Information Content to Evaluate Semantic Similarity in a Taxonomy](https://refivu.com/en/papers/23ad22de-7daf-406d-8e06-0f53f8035655-using-information-content-to-evaluate-semantic-similarity-in.md)
- [Conditional Image Synthesis With Auxiliary Classifier GANs](https://refivu.com/en/papers/cbb27823-75f1-4fb6-b4c8-dcc645b1f162-conditional-image-synthesis-with-auxiliary-classifier-gans.md)
- [RepVGG: Making VGG-style ConvNets Great Again](https://refivu.com/en/papers/b7578ec8-e378-4286-b3a9-984d13d073c3-repvgg-making-vgg-style-convnets-great-again.md)
- [Estimating Continuous Distributions in Bayesian Classifiers](https://refivu.com/en/papers/318decb8-43d0-4596-b25f-944ca636af13-estimating-continuous-distributions-in-bayesian-classifiers.md)
- [Loss Functions for Neural Networks for Image Processing](https://refivu.com/en/papers/e37574f3-bd03-49a6-929a-ac77f4fc8959-loss-functions-for-neural-networks-for-image-processing.md)
- [Supervised learning with quantum enhanced feature spaces](https://refivu.com/en/papers/3f9e8d98-c1b3-4fa7-89e8-2599add8f4d9-supervised-learning-with-quantum-enhanced-feature-spaces.md)
- [The No-U-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo](https://refivu.com/en/papers/e0f0ea3e-b264-41df-ace0-6689f5d123b5-the-no-u-turn-sampler-adaptively-setting-path.md)

## Terms in this paper

- [LSTM](https://refivu.com/en/terms/ba10547646d9-lstm)
- [perplexity](https://refivu.com/en/terms/2b204e513801-perplexity)
- [language modeling](https://refivu.com/en/terms/8f3aaf7f8ef0-language-modeling)
- [recurrent neural networks](https://refivu.com/en/terms/326dd1d8cc5b-recurrent-neural-networks)
- [Penn Treebank](https://refivu.com/en/terms/fffc021679a8-penn-treebank)
- [Pointer network](https://refivu.com/en/terms/61d9123f2056-pointer-network)
- [WikiText](https://refivu.com/en/terms/b2db4641e2db-wikitext)
- [WikiText-2](https://refivu.com/en/terms/9f23241a7a2c-wikitext-2)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/8f7d0844-f517-4c18-ba24-8cd7dc616a74-pointer-sentinel-mixture-models)
