Our new X account is live! Follow @wizwand_team for updates
WorkDL logo mark

Generalization through Memorization: Nearest Neighbor Language Models

About

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.

Urvashi Khandelwal, Omer Levy, Dan Jurafsky, Luke Zettlemoyer, Mike Lewis• 2019

Related benchmarks

TaskDatasetResultRank
Language ModelingWikiText-103 (test)
Perplexity14.54
524
Language ModelingWikiText-103 (val)
PPL14.39
180
Language ModelingPG-19 (test)
Perplexity43.93
106
Word-level Language ModelingWikiText-103 word-level (test)
Perplexity15.79
65
Word-level Language ModelingWikiText-103 (dev)
Perplexity15.81
64
Language ModelingGovReport
Perplexity14.87
50
Language ModelingXsum
Perplexity17.01
26
Open-ended generationWikiText-103 (test)
MAUVE0.225
26
Language ModelingarXiv
Perplexity24.38
21
Open-ended Text GenerationLaw-MT Out of Domain (test)
MAUVE24.75
16
Showing 10 of 20 rows

Other info

Code

Follow for update