mlsanityData to 7 Oct 2026

You can't pick your neighbors, or can you? When and how to rely on retrieval in the kNN-LM

arXiv 2210.15859 ↗First posted 28 Oct 2022cs.CL cs.LGcited by 18

Not on the map. Why?

Abstract (arXiv)

Retrieval-enhanced language models (LMs), which condition their predictions on text retrieved from large external datastores, have recently shown significant perplexity improvements compared to standard LMs. One such approach, the kNN-LM, interpolates any existing LM's predictions with the output of a k-nearest neighbors model and requires no additional training. In this paper, we explore the importance of lexical and semantic matching in the context of items retrieved by kNN-LM. We find two trends: (1) the presence of large overlapping n-grams between the datastore and evaluation set plays an important factor in strong performance, even when the datastore is derived from the training data; and (2) the kNN-LM is most beneficial when retrieved items have high semantic similarity with the query. Based on our analysis, we define a new formulation of the kNN-LM that uses retrieval quality to assign the interpolation coefficient. We empirically measure the effectiveness of our approach on two English language modeling datasets, Wikitext-103 and PG-19. Our re-formulation of the kNN-LM is beneficial in both cases, and leads to nearly 4% improvement in perplexity on the Wikitext-103 test set.

Key facts. Cited by 18 papers in the map (data through 7 Oct 2026). Builds on 38 of its 45 references that are in the map. First posted on arXiv 28 Oct 2022.

Builds on

38 of 45 references.

References · 38

  1. 2020Language Models are Few-Shot Learnerscited by 32,199
  2. 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,160
  3. 2016Pointer Sentinel Mixture Modelscited by 2,992
  4. 2020REALM: Retrieval-Augmented Language Model Pre-Trainingcited by 2,126
  5. 2019Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelismcited by 1,829
  6. 2016Understanding deep learning requires rethinking generalizationcited by 1,657
  7. 2021Improving language models by retrieving from trillions of tokenscited by 1,278
  8. 2022LaMDA: Language Models for Dialog Applicationscited by 1,218
  9. 2019Generalization through Memorization: Nearest Neighbor Language Modelscited by 788
  10. 2017Reading Wikipedia to Answer Open-Domain Questionscited by 777
  11. 2021Deduplicating Training Data Makes Language Models Bettercited by 705
  12. 2019Compressive Transformers for Long-Range Sequence Modellingcited by 699
26 more
  1. 2019Latent Retrieval for Weakly Supervised Open Domain Question Answeringcited by 691
  2. 2022Deduplicating Training Data Mitigates Privacy Risks in Language Modelscited by 309
  3. 2018Adaptive Input Representations for Neural Language Modelingcited by 226
  4. 2022Memorizing Transformerscited by 219
  5. 2020Nearest Neighbor Machine Translationcited by 209
  6. 2021How much do language models copy from their training data? Evaluating linguistic novelty in text generation using RAVENcited by 124
  7. 2021COIL: Revisit Exact Lexical Match in Information Retrieval with Contextualized Inverted Listcited by 113
  8. 2022Training Language Models with Memory Augmentationcited by 112
  9. 2020Self-training Improves Pre-training for Natural Language Understandingcited by 96
  10. 2021Efficient Nearest Neighbor Language Modelscited by 93
  11. 2021Adaptive Semiparametric Language Modelscited by 83
  12. 2016Improving Neural Language Models with a Continuous Cachecited by 81
  13. 2022RankGen: Improving Text Generation with Large Ranking Modelscited by 72
  14. 2022Neuro-Symbolic Language Modeling with Automaton-augmented Retrievalcited by 60
  15. 2021Adaptive Nearest Neighbor Machine Translationcited by 58
  16. 2020Augmenting Transformers with KNN-Based Composite Memory for Dialoguecited by 53
  17. 2022Retrieval-Enhanced Machine Learningcited by 46
  18. 2021Joint Passage Ranking for Diverse Multi-Answer Retrievalcited by 43
  19. 2020BERT-kNN: Adding a kNN Search Component to Pretrained Language Models for Better QAcited by 36
  20. 2021GNN-LM: Language Modeling based on Global Contexts via GNNcited by 27
  21. 2020Guided Transformer: Leveraging Multiple External Sources for Representation Learning in Conversational Searchcited by 23
  22. 2022Chunk-based Nearest Neighbor Machine Translationcited by 21
  23. 2019Multi-step Entity-centric Information Retrieval for Multi-Hop Question Answeringcited by 20
  24. 2020Learning Sparse Prototypes for Text Generationcited by 15
  25. 2021RETRONLU: Retrieval Augmented Task-Oriented Semantic Parsingcited by 15
  26. 2021Capturing Structural Locality in Non-parametric Language Modelscited by 8

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2022: 1; 2023: 7; 2024: 5; 2025: 3; 2026: 2.

18 papers.

Sort:

By area:

  1. 2022When Not to Trust Language Models: Investigating Effectiveness of Parametric and Non-Parametric Memoriescited by 1,103
  2. 2023Unlimiformer: Long-Range Transformers with Unlimited Length Inputcited by 127
  3. 2024Reliable, Adaptable, and Attributable Language Models with Retrievalcited by 73
  4. 2023SILO Language Models: Isolating Legal Risk In a Nonparametric Datastorecited by 71
  5. 2024Repoformer: Selective Retrieval for Repository-Level Code Completioncited by 55
  6. 2023How Do Large Language Models Capture the Ever-changing World Knowledge? A Review of Recent Advancescited by 33
  7. 2023Why do Nearest Neighbor Language Models Work?cited by 29
  8. 2025Adaptive Tool Use in Large Language Models with Meta-Cognition Triggercited by 29
  9. 2024Nearest Neighbor Speculative Decoding for LLM Generation and Attributioncited by 26
  10. 2023Learn to Memorize: Scalable Continual Learning in Semiparametric Models with Mixture-of-Neighbors Induction Memorycited by 12
  11. 2024Plan*RAG: Efficient Test-Time Planning for Retrieval Augmented Generationcited by 11
  12. 2023KNN-LM Does Not Improve Open-ended Text Generationcited by 10
6 more
  1. 2024FT2Ra: A Fine-Tuning-Inspired Approach to Retrieval-Augmented Code Completioncited by 9
  2. 2023On Retrieval Augmentation and the Limitations of Language Model Trainingcited by 2
  3. 2025Long-Tail Crisis in Nearest Neighbor Language Modelscited by 1
  4. 2025Separating Knowledge and Perception with Procedural Datacited by 0
  5. 2026Oilbird: Training-Free Speculative Decoding with Keys the Verifier Already Computescited by 0
  6. 2026Does Episodic Memory Help Close the Lexical Frequency Gap in Sensitivity to Syntactic Contrasts? A Test Using Retrieval-Augmented Language Modelscited by 0