Generalization through Memorization: Nearest Neighbor Language Models

By Urvashi Khandelwal, Omer Levy, Dan Jurafsky, Luke S. Zettlemoyer, Michael Lewis. 2019

1,095 citations recorded by the source corpus.

We introduce $k$NN-LMs, which extend a pre-trained neural language model (LM) by linearly interpolating it with a $k$-nearest neighbors ($k$NN) model. The nearest neighbors are computed according to distance in the pre-trained LM embedding space, and can be drawn from any text collection, including the original LM training data. Applying this augmentation to a strong Wikitext-103 LM, with neighbors drawn from the original training set, our $k$NN-LM achieves a new state-of-the-art perplexity of 15.79 - a 2.9 point improvement with no additional training. We also show that this approach has implications for efficiently scaling up to larger training sets and allows for effective domain adaptation, by simply varying the nearest neighbor datastore, again without further training. Qualitatively, the model is particularly helpful in predicting rare patterns, such as factual knowledge. Together, these results strongly suggest that learning similarity between sequences of text is easier than predicting the next word, and that nearest neighbor search is an effective approach for language modeling in the long tail.

Subfields: Artificial Intelligence, Computer Vision and Pattern Recognition, Information Retrieval & Search, Large Language Models

How researchers see this paper

The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.

In Artificial Intelligence

  1. Mohit Bansal
  2. Luke S. Zettlemoyer
  3. Jianfeng Gao
  4. Percy Liang
  5. Graham Neubig
  6. Hannaneh Hajishirzi
  7. Yejin Choi
  8. Noah A. Smith

In Computer Vision and Pattern Recognition

  1. Luc Van Gool
  2. Dacheng Tao
  3. Mohit Bansal
  4. Trevor Darrell
  5. Jianfeng Gao
  6. Xiaogang Wang
  7. Ming-Hsuan Yang
  8. Andrew Zisserman

In Information Retrieval & Search

  1. Hannaneh Hajishirzi
  2. Wen-tau Yih
  3. Sebastian Riedel
  4. Jamie Callan
  5. Danqi Chen
  6. Luyu Gao
  7. Gautier Izacard
  8. Jimmy J. Lin

In Large Language Models

  1. Luke S. Zettlemoyer
  2. Hinrich Schütze
  3. Timo Schick
  4. Yejin Choi
  5. Jianfeng Gao
  6. Noah A. Smith
  7. Hannaneh Hajishirzi
  8. Graham Neubig

Citations in the corpus