You can't pick your neighbors, or can you? When and how to rely on retrieval in the kNN-LM
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
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,160
- 2016Pointer Sentinel Mixture Modelscited by 2,992
- 2020REALM: Retrieval-Augmented Language Model Pre-Trainingcited by 2,126
- 2019Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelismcited by 1,829
- 2016Understanding deep learning requires rethinking generalizationcited by 1,657
- 2021Improving language models by retrieving from trillions of tokenscited by 1,278
- 2022LaMDA: Language Models for Dialog Applicationscited by 1,218
- 2019Generalization through Memorization: Nearest Neighbor Language Modelscited by 788
- 2017Reading Wikipedia to Answer Open-Domain Questionscited by 777
- 2021Deduplicating Training Data Makes Language Models Bettercited by 705
- 2019Compressive Transformers for Long-Range Sequence Modellingcited by 699
26 more
- 2019Latent Retrieval for Weakly Supervised Open Domain Question Answeringcited by 691
- 2022Deduplicating Training Data Mitigates Privacy Risks in Language Modelscited by 309
- 2018Adaptive Input Representations for Neural Language Modelingcited by 226
- 2022Memorizing Transformerscited by 219
- 2020Nearest Neighbor Machine Translationcited by 209
- 2021How much do language models copy from their training data? Evaluating linguistic novelty in text generation using RAVENcited by 124
- 2021COIL: Revisit Exact Lexical Match in Information Retrieval with Contextualized Inverted Listcited by 113
- 2022Training Language Models with Memory Augmentationcited by 112
- 2020Self-training Improves Pre-training for Natural Language Understandingcited by 96
- 2021Efficient Nearest Neighbor Language Modelscited by 93
- 2021Adaptive Semiparametric Language Modelscited by 83
- 2016Improving Neural Language Models with a Continuous Cachecited by 81
- 2022RankGen: Improving Text Generation with Large Ranking Modelscited by 72
- 2022Neuro-Symbolic Language Modeling with Automaton-augmented Retrievalcited by 60
- 2021Adaptive Nearest Neighbor Machine Translationcited by 58
- 2020Augmenting Transformers with KNN-Based Composite Memory for Dialoguecited by 53
- 2022Retrieval-Enhanced Machine Learningcited by 46
- 2021Joint Passage Ranking for Diverse Multi-Answer Retrievalcited by 43
- 2020BERT-kNN: Adding a kNN Search Component to Pretrained Language Models for Better QAcited by 36
- 2021GNN-LM: Language Modeling based on Global Contexts via GNNcited by 27
- 2020Guided Transformer: Leveraging Multiple External Sources for Representation Learning in Conversational Searchcited by 23
- 2022Chunk-based Nearest Neighbor Machine Translationcited by 21
- 2019Multi-step Entity-centric Information Retrieval for Multi-Hop Question Answeringcited by 20
- 2020Learning Sparse Prototypes for Text Generationcited by 15
- 2021RETRONLU: Retrieval Augmented Task-Oriented Semantic Parsingcited by 15
- 2021Capturing Structural Locality in Non-parametric Language Modelscited by 8
Built on by
Citing papers per year: 2022: 1; 2023: 7; 2024: 5; 2025: 3; 2026: 2.
18 papers.
Sort:
By area:
- 2022When Not to Trust Language Models: Investigating Effectiveness of Parametric and Non-Parametric Memoriescited by 1,103
- 2023Unlimiformer: Long-Range Transformers with Unlimited Length Inputcited by 127
- 2024Reliable, Adaptable, and Attributable Language Models with Retrievalcited by 73
- 2023SILO Language Models: Isolating Legal Risk In a Nonparametric Datastorecited by 71
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completioncited by 55
- 2023How Do Large Language Models Capture the Ever-changing World Knowledge? A Review of Recent Advancescited by 33
- 2023Why do Nearest Neighbor Language Models Work?cited by 29
- 2025Adaptive Tool Use in Large Language Models with Meta-Cognition Triggercited by 29
- 2024Nearest Neighbor Speculative Decoding for LLM Generation and Attributioncited by 26
- 2023Learn to Memorize: Scalable Continual Learning in Semiparametric Models with Mixture-of-Neighbors Induction Memorycited by 12
- 2024Plan*RAG: Efficient Test-Time Planning for Retrieval Augmented Generationcited by 11
- 2023KNN-LM Does Not Improve Open-ended Text Generationcited by 10
6 more
- 2024FT2Ra: A Fine-Tuning-Inspired Approach to Retrieval-Augmented Code Completioncited by 9
- 2023On Retrieval Augmentation and the Limitations of Language Model Trainingcited by 2
- 2025Long-Tail Crisis in Nearest Neighbor Language Modelscited by 1
- 2025Separating Knowledge and Perception with Procedural Datacited by 0
- 2026Oilbird: Training-Free Speculative Decoding with Keys the Verifier Already Computescited by 0
- 2026Does Episodic Memory Help Close the Lexical Frequency Gap in Sensitivity to Syntactic Contrasts? A Test Using Retrieval-Augmented Language Modelscited by 0
- 2026Does Episodic Memory Help Close the Lexical Frequency Gap in Sensitivity to Syntactic Contrasts? A Test Using Retrieval-Augmented Language Models24 Aug 2026
- 2026Oilbird: Training-Free Speculative Decoding with Keys the Verifier Already Computes4 Aug 2026
- 2025Separating Knowledge and Perception with Procedural Data12 Aug 2025
- 2025Long-Tail Crisis in Nearest Neighbor Language Models28 Mar 2025
- 2025Adaptive Tool Use in Large Language Models with Meta-Cognition Trigger18 Feb 2025
- 2024Plan*RAG: Efficient Test-Time Planning for Retrieval Augmented Generation28 Oct 2024
- 2024Nearest Neighbor Speculative Decoding for LLM Generation and Attribution29 May 2024
- 2024FT2Ra: A Fine-Tuning-Inspired Approach to Retrieval-Augmented Code Completion2 Apr 2024
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completion15 Mar 2024
- 2024Reliable, Adaptable, and Attributable Language Models with Retrieval5 Mar 2024
- 2023On Retrieval Augmentation and the Limitations of Language Model Training16 Nov 2023
- 2023How Do Large Language Models Capture the Ever-changing World Knowledge? A Review of Recent Advances11 Oct 2023
6 more
- 2023SILO Language Models: Isolating Legal Risk In a Nonparametric Datastore8 Aug 2023
- 2023KNN-LM Does Not Improve Open-ended Text Generation24 May 2023
- 2023Unlimiformer: Long-Range Transformers with Unlimited Length Input2 May 2023
- 2023Learn to Memorize: Scalable Continual Learning in Semiparametric Models with Mixture-of-Neighbors Induction Memory2 Mar 2023
- 2023Why do Nearest Neighbor Language Models Work?7 Jan 2023
- 2022When Not to Trust Language Models: Investigating Effectiveness of Parametric and Non-Parametric Memories20 Dec 2022
- 2022When Not to Trust Language Models: Investigating Effectiveness of Parametric and Non-Parametric Memoriescited by 1,103
- 2024Reliable, Adaptable, and Attributable Language Models with Retrievalcited by 73
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completioncited by 55
- 2023Why do Nearest Neighbor Language Models Work?cited by 29
- 2023KNN-LM Does Not Improve Open-ended Text Generationcited by 10
- 2024FT2Ra: A Fine-Tuning-Inspired Approach to Retrieval-Augmented Code Completioncited by 9
- 2025Long-Tail Crisis in Nearest Neighbor Language Modelscited by 1
- 2026Does Episodic Memory Help Close the Lexical Frequency Gap in Sensitivity to Syntactic Contrasts? A Test Using Retrieval-Augmented Language Modelscited by 0
- 2026Does Episodic Memory Help Close the Lexical Frequency Gap in Sensitivity to Syntactic Contrasts? A Test Using Retrieval-Augmented Language Models24 Aug 2026
- 2025Long-Tail Crisis in Nearest Neighbor Language Models28 Mar 2025
- 2024FT2Ra: A Fine-Tuning-Inspired Approach to Retrieval-Augmented Code Completion2 Apr 2024
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completion15 Mar 2024
- 2024Reliable, Adaptable, and Attributable Language Models with Retrieval5 Mar 2024
- 2023KNN-LM Does Not Improve Open-ended Text Generation24 May 2023
- 2023Why do Nearest Neighbor Language Models Work?7 Jan 2023
- 2022When Not to Trust Language Models: Investigating Effectiveness of Parametric and Non-Parametric Memories20 Dec 2022
- 2023Unlimiformer: Long-Range Transformers with Unlimited Length Inputcited by 127
- 2023SILO Language Models: Isolating Legal Risk In a Nonparametric Datastorecited by 71
- 2023How Do Large Language Models Capture the Ever-changing World Knowledge? A Review of Recent Advancescited by 33
- 2023Learn to Memorize: Scalable Continual Learning in Semiparametric Models with Mixture-of-Neighbors Induction Memorycited by 12
- 2023On Retrieval Augmentation and the Limitations of Language Model Trainingcited by 2
- 2025Separating Knowledge and Perception with Procedural Datacited by 0
- 2025Separating Knowledge and Perception with Procedural Data12 Aug 2025
- 2023On Retrieval Augmentation and the Limitations of Language Model Training16 Nov 2023
- 2023How Do Large Language Models Capture the Ever-changing World Knowledge? A Review of Recent Advances11 Oct 2023
- 2023SILO Language Models: Isolating Legal Risk In a Nonparametric Datastore8 Aug 2023
- 2023Unlimiformer: Long-Range Transformers with Unlimited Length Input2 May 2023
- 2023Learn to Memorize: Scalable Continual Learning in Semiparametric Models with Mixture-of-Neighbors Induction Memory2 Mar 2023