kNN Prompting: Beyond-Context Learning with Calibration-Free Nearest Neighbor Inference
Not on the map. Why?
Abstract (arXiv)
In-Context Learning (ICL), which formulates target tasks as prompt completion conditioned on in-context demonstrations, has become the prevailing utilization of LLMs. In this paper, we first disclose an actual predicament for this typical usage that it can not scale up with training data due to context length restriction. Besides, existing works have shown that ICL also suffers from various biases and requires delicate calibration treatment. To address both challenges, we advocate a simple and effective solution, kNN Prompting, which first queries LLM with training data for distributed representations, then predicts test instances by simply referring to nearest neighbors. We conduct comprehensive experiments to demonstrate its two-fold superiority: 1) Calibration-Free: kNN Prompting does not directly align LLM output distribution with task-specific label space, instead leverages such distribution to align test and training instances. It significantly outperforms state-of-the-art calibration-based methods under comparable few-shot scenario. 2) Beyond-Context: kNN Prompting can further scale up effectively with as many training data as are available, continually bringing substantial improvements. The scaling trend holds across 10 orders of magnitude ranging from 2 shots to 1024 shots as well as different LLMs scales ranging from 0.8B to 30B. It successfully bridges data scaling into model scaling, and brings new potentials for the gradient-free paradigm of LLM deployment. Code is publicly available.
Key facts. Cited by 47 papers in the map (data through 7 Oct 2026). Builds on 49 of its 65 references that are in the map. First posted on arXiv 24 Mar 2023.
Builds on
49 of 65 references.
References · 49
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,491
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,160
- 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,049
- 2020Measuring Massive Multitask Language Understandingcited by 7,768
- 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,304
- 2022Large Language Models are Zero-Shot Reasonerscited by 4,323
- 2021On the Opportunities and Risks of Foundation Modelscited by 3,961
- 2021Finetuned Language Models Are Zero-Shot Learnerscited by 3,747
- 2022OPT: Open Pre-trained Transformer Language Modelscited by 3,464
- 2022Emergent Abilities of Large Language Modelscited by 2,483
37 more
- 2015Character-level Convolutional Networks for Text Classificationcited by 2,293
- 2021SimCSE: Simple Contrastive Learning of Sentence Embeddingscited by 2,168
- 2022Beyond the Imitation Game: Quantifying and extrapolating the capabilities of language modelscited by 1,970
- 2021Multitask Prompted Training Enables Zero-Shot Task Generalizationcited by 1,462
- 2021Calibrate Before Use: Improving Few-Shot Performance of Language Modelscited by 1,371
- 2021Improving language models by retrieving from trillions of tokenscited by 1,278
- 2021Scaling Language Models: Methods, Analysis & Insights from Training Gophercited by 1,199
- 2021What Makes Good In-Context Examples for GPT-3?cited by 1,184
- 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,122
- 2019How Can We Know What Language Models Know?cited by 953
- 2020Language (Technology) is Power: A Critical Survey of "Bias" in NLPcited by 951
- 2022Atlas: Few-shot Learning with Retrieval Augmented Language Modelscited by 940
- 2020Exploiting Cloze Questions for Few Shot Text Classification and Natural Language Inferencecited by 934
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 915
- 2020StereoSet: Measuring stereotypical bias in pretrained language modelscited by 911
- 2019Generalization through Memorization: Nearest Neighbor Language Modelscited by 788
- 2021Learning To Retrieve Prompts for In-Context Learningcited by 641
- 2022Using DeepSpeed and Megatron to Train Megatron-Turing NLG 530B, A Large-Scale Generative Language Modelcited by 557
- 2017Deep Learning Scaling is Predictable, Empiricallycited by 556
- 2021MetaICL: Learning to Learn In Contextcited by 450
- 2020How Can We Know When Language Models Know? On the Calibration of Language Models for Question Answeringcited by 439
- 2021Surface Form Competition: Why the Highest Probability Answer Isn't Always Rightcited by 256
- 2018A Simple Method for Commonsense Reasoningcited by 223
- 2020Nearest Neighbor Machine Translationcited by 209
- 2018Deep k-Nearest Neighbors: Towards Confident, Interpretable and Robust Deep Learningcited by 203
- 2019A Constructive Prediction of the Generalization Error Across Scalescited by 202
- 2021Noisy Channel Language Model Prompting for Few-Shot Text Classificationcited by 163
- 2021Meta-learning via Language Model In-context Tuningcited by 163
- 2017Generating Sentences by Editing Prototypescited by 88
- 2018Retrieve and Refine: Improved Sequence Generation Models For Dialoguecited by 82
- 2017Learning to Remember Rare Eventscited by 63
- 2022Training Data is More Valuable than You Think: A Simple and Effective Method by Retrieving from Training Datacited by 61
- 2022Mitigating Gender Bias in Distilled Language Models via Counterfactual Role Reversalcited by 40
- 2022Decoupling Knowledge from Memorization: Retrieval-augmented Prompt Learningcited by 36
- 2022kNN-Prompt: Nearest Neighbor Zero-Shot Inferencecited by 27
- 2018A Simple Cache Model for Image Recognitioncited by 20
- 2021Trans-Encoder: Unsupervised sentence-pair modelling through self- and mutual-distillationscited by 20
Built on by
Citing papers per year: 2023: 18; 2024: 16; 2025: 8; 2026: 5.
47 papers.
Sort:
By area:
- 2023Jailbreak and Guard Aligned Language Models with Only Few In-Context Demonstrationscited by 401
- 2023In-context Vectors: Making In Context Learning More Effective and Controllable Through Latent Space Steeringcited by 240
- 2023Unified Demonstration Retriever for In-Context Learningcited by 141
- 2023ExpertPrompting: Instructing Large Language Models to be Distinguished Expertscited by 140
- 2023Batch Calibration: Rethinking Calibration for In-Context Learning and Prompt Engineeringcited by 91
- 2023On the Calibration of Large Language Models and Alignmentcited by 72
- 2023Self-Knowledge Guided Retrieval Augmentation for Large Language Modelscited by 69
- 2024Demystifying Chains, Trees, and Graphs of Thoughtscited by 63
- 2023Self-Verification Improves Few-Shot Clinical Information Extractioncited by 52
- 2023Forward-Backward Reasoning in Large Language Models for Mathematical Verificationcited by 39
- 2023Which Examples to Annotate for In-Context Learning? Towards Effective and Efficient Selectioncited by 36
- 2024Mixture of In-Context Prompters for Tabular PFNscited by 32
35 more
- 2023Tree Prompting: Efficient Task Adaptation without Fine-Tuningcited by 17
- 2024Enhancing In-context Learning via Linear Probe Calibrationcited by 16
- 2023InstructEval: Systematic Evaluation of Instruction Selection Methodscited by 12
- 2023Large Knowledge Model: Perspectives and Challengescited by 12
- 2023Are Human-generated Demonstrations Necessary for In-context Learning?cited by 11
- 2024Few-shot Dialogue Strategy Learning for Motivational Interviewing via Inductive Reasoningcited by 11
- 2024Token-based Decision Criteria Are Suboptimal in In-context Learningcited by 9
- 2024Vocabulary-Defined Semantics: Latent Space Clustering for Improving In-Context Learningcited by 7
- 2023Dynamic Demonstrations Controller for In-Context Learningcited by 6
- 2023RecallM: An Adaptable Memory Mechanism with Temporal Understanding for Large Language Modelscited by 5
- 2024No Train, all Gain: Self-Supervised Gradients Improve Deep Frozen Representationscited by 5
- 2024LAMPO: Large Language Models as Preference Machines for Few-shot Ordinal Classificationcited by 5
- 2024Self-Instructed Derived Prompt Generation Meets In-Context Learning: Unlocking New Potential of Black-Box LLMscited by 5
- 2025From Promising Capability to Pervasive Bias: Assessing Large Language Models for Emergency Department Triagecited by 5
- 2024A Study on Training and Developing Large Language Models for Behavior Tree Generationcited by 4
- 2024Attribute Structuring Improves LLM-Based Evaluation of Clinical Text Summariescited by 4
- 2024Evaluating and Safeguarding the Adversarial Robustness of Retrieval-Based In-Context Learningcited by 4
- 2025TestNUC: Enhancing Test-Time Computing Approaches and Scaling through Neighboring Unlabeled Data Consistencycited by 4
- 2023kNN-ICL: Compositional Task-Oriented Parsing Generalization with Nearest Neighbor In-Context Learningcited by 3
- 2023Matching Table Metadata with Business Glossaries Using Large Language Modelscited by 2
- 2024AICL: Action In-Context Learning for Video Diffusion Modelcited by 2
- 2024Learning-From-Mistakes Prompting for Indigenous Language Translationcited by 2
- 2025StaICC: Standardized Evaluation for Classification Task in In-context Learningcited by 2
- 2024Feature-Adaptive and Data-Scalable In-Context Learningcited by 1
- 2025Latent Factor Models Meets Instructions: Goal-conditioned Latent Factor Discovery without Task Supervisioncited by 1
- 2025CEA-LIST at CheckThat! 2025: Evaluating LLMs as Detectors of Bias and Opinion in Textcited by 1
- 2025PANICL: Mitigating Over-Reliance on Single Prompt in Visual In-Context Learningcited by 1
- 2026ARASH: Adaptive Retrieval And Shot Selection for Tabular Predictioncited by 1
- 2024Leveraging Biases in Large Language Models: "bias-kNN'' for Effective Few-Shot Learningcited by 0
- 2025Efficient Knowledge Feeding to Language Models: A Novel Integrated Encoder-Decoder Architecturecited by 0
- 2025On the Difficulty of Selecting Few-Shot Examples for Effective LLM-based Vulnerability Detectioncited by 0
- 2026Nearest-Neighbor Radii under Dependent Samplingcited by 0
- 2026Self-Improving In-Context Learningcited by 0
- 2026Differentially Private Datastore Generation for Retrieval-Augmented Inferencecited by 0
- 2026HIRA: A Human-in-the-Loop Retrieval-Augmented Cascade for Document Classification in Regulated Industriescited by 0
- 2026HIRA: A Human-in-the-Loop Retrieval-Augmented Cascade for Document Classification in Regulated Industries22 Aug 2026
- 2026ARASH: Adaptive Retrieval And Shot Selection for Tabular Prediction18 Aug 2026
- 2026Differentially Private Datastore Generation for Retrieval-Augmented Inference31 May 2026
- 2026Self-Improving In-Context Learning22 May 2026
- 2026Nearest-Neighbor Radii under Dependent Sampling14 May 2026
- 2025On the Difficulty of Selecting Few-Shot Examples for Effective LLM-based Vulnerability Detection31 Oct 2025
- 2025PANICL: Mitigating Over-Reliance on Single Prompt in Visual In-Context Learning26 Sep 2025
- 2025CEA-LIST at CheckThat! 2025: Evaluating LLMs as Detectors of Bias and Opinion in Text10 Jul 2025
- 2025From Promising Capability to Pervasive Bias: Assessing Large Language Models for Emergency Department Triage22 Apr 2025
- 2025TestNUC: Enhancing Test-Time Computing Approaches and Scaling through Neighboring Unlabeled Data Consistency26 Feb 2025
- 2025Latent Factor Models Meets Instructions: Goal-conditioned Latent Factor Discovery without Task Supervision21 Feb 2025
- 2025Efficient Knowledge Feeding to Language Models: A Novel Integrated Encoder-Decoder Architecture7 Feb 2025
35 more
- 2025StaICC: Standardized Evaluation for Classification Task in In-context Learning27 Jan 2025
- 2024Self-Instructed Derived Prompt Generation Meets In-Context Learning: Unlocking New Potential of Black-Box LLMs3 Sep 2024
- 2024LAMPO: Large Language Models as Preference Machines for Few-shot Ordinal Classification6 Aug 2024
- 2024Learning-From-Mistakes Prompting for Indigenous Language Translation18 Jul 2024
- 2024No Train, all Gain: Self-Supervised Gradients Improve Deep Frozen Representations15 Jul 2024
- 2024Token-based Decision Criteria Are Suboptimal in In-context Learning24 Jun 2024
- 2024Mixture of In-Context Prompters for Tabular PFNs25 May 2024
- 2024Evaluating and Safeguarding the Adversarial Robustness of Retrieval-Based In-Context Learning24 May 2024
- 2024Feature-Adaptive and Data-Scalable In-Context Learning17 May 2024
- 2024Few-shot Dialogue Strategy Learning for Motivational Interviewing via Inductive Reasoning23 Mar 2024
- 2024AICL: Action In-Context Learning for Video Diffusion Model18 Mar 2024
- 2024Attribute Structuring Improves LLM-Based Evaluation of Clinical Text Summaries1 Mar 2024
- 2024Vocabulary-Defined Semantics: Latent Space Clustering for Improving In-Context Learning29 Jan 2024
- 2024Demystifying Chains, Trees, and Graphs of Thoughts25 Jan 2024
- 2024Enhancing In-context Learning via Linear Probe Calibration22 Jan 2024
- 2024Leveraging Biases in Large Language Models: "bias-kNN'' for Effective Few-Shot Learning18 Jan 2024
- 2024A Study on Training and Developing Large Language Models for Behavior Tree Generation16 Jan 2024
- 2023kNN-ICL: Compositional Task-Oriented Parsing Generalization with Nearest Neighbor In-Context Learning17 Dec 2023
- 2023Large Knowledge Model: Perspectives and Challenges5 Dec 2023
- 2023On the Calibration of Large Language Models and Alignment22 Nov 2023
- 2023In-context Vectors: Making In Context Learning More Effective and Controllable Through Latent Space Steering11 Nov 2023
- 2023Which Examples to Annotate for In-Context Learning? Towards Effective and Efficient Selection30 Oct 2023
- 2023Tree Prompting: Efficient Task Adaptation without Fine-Tuning21 Oct 2023
- 2023Jailbreak and Guard Aligned Language Models with Only Few In-Context Demonstrations10 Oct 2023
- 2023Self-Knowledge Guided Retrieval Augmentation for Large Language Models8 Oct 2023
- 2023Dynamic Demonstrations Controller for In-Context Learning30 Sep 2023
- 2023Batch Calibration: Rethinking Calibration for In-Context Learning and Prompt Engineering29 Sep 2023
- 2023Are Human-generated Demonstrations Necessary for In-context Learning?26 Sep 2023
- 2023Matching Table Metadata with Business Glossaries Using Large Language Models8 Sep 2023
- 2023Forward-Backward Reasoning in Large Language Models for Mathematical Verification15 Aug 2023
- 2023RecallM: An Adaptable Memory Mechanism with Temporal Understanding for Large Language Models6 Jul 2023
- 2023InstructEval: Systematic Evaluation of Instruction Selection Methods1 Jul 2023
- 2023Self-Verification Improves Few-Shot Clinical Information Extraction30 May 2023
- 2023ExpertPrompting: Instructing Large Language Models to be Distinguished Experts24 May 2023
- 2023Unified Demonstration Retriever for In-Context Learning7 May 2023
- 2023Batch Calibration: Rethinking Calibration for In-Context Learning and Prompt Engineeringcited by 91
- 2024Demystifying Chains, Trees, and Graphs of Thoughtscited by 63
- 2023Self-Verification Improves Few-Shot Clinical Information Extractioncited by 52
- 2023Forward-Backward Reasoning in Large Language Models for Mathematical Verificationcited by 39
- 2024Few-shot Dialogue Strategy Learning for Motivational Interviewing via Inductive Reasoningcited by 11
- 2025TestNUC: Enhancing Test-Time Computing Approaches and Scaling through Neighboring Unlabeled Data Consistencycited by 4
- 2025TestNUC: Enhancing Test-Time Computing Approaches and Scaling through Neighboring Unlabeled Data Consistency26 Feb 2025
- 2024Few-shot Dialogue Strategy Learning for Motivational Interviewing via Inductive Reasoning23 Mar 2024
- 2024Demystifying Chains, Trees, and Graphs of Thoughts25 Jan 2024
- 2023Batch Calibration: Rethinking Calibration for In-Context Learning and Prompt Engineering29 Sep 2023
- 2023Forward-Backward Reasoning in Large Language Models for Mathematical Verification15 Aug 2023
- 2023Self-Verification Improves Few-Shot Clinical Information Extraction30 May 2023
- 2024Evaluating and Safeguarding the Adversarial Robustness of Retrieval-Based In-Context Learningcited by 4
- 2025Efficient Knowledge Feeding to Language Models: A Novel Integrated Encoder-Decoder Architecturecited by 0
- 2026HIRA: A Human-in-the-Loop Retrieval-Augmented Cascade for Document Classification in Regulated Industriescited by 0
- 2026HIRA: A Human-in-the-Loop Retrieval-Augmented Cascade for Document Classification in Regulated Industries22 Aug 2026
- 2025Efficient Knowledge Feeding to Language Models: A Novel Integrated Encoder-Decoder Architecture7 Feb 2025
- 2024Evaluating and Safeguarding the Adversarial Robustness of Retrieval-Based In-Context Learning24 May 2024
- 2024AICL: Action In-Context Learning for Video Diffusion Model18 Mar 2024
- 2023In-context Vectors: Making In Context Learning More Effective and Controllable Through Latent Space Steeringcited by 240
- 2023Unified Demonstration Retriever for In-Context Learningcited by 141
- 2023On the Calibration of Large Language Models and Alignmentcited by 72
- 2023Self-Knowledge Guided Retrieval Augmentation for Large Language Modelscited by 69
- 2023Which Examples to Annotate for In-Context Learning? Towards Effective and Efficient Selectioncited by 36
- 2024Mixture of In-Context Prompters for Tabular PFNscited by 32
- 2023Tree Prompting: Efficient Task Adaptation without Fine-Tuningcited by 17
- 2024Enhancing In-context Learning via Linear Probe Calibrationcited by 16
- 2023InstructEval: Systematic Evaluation of Instruction Selection Methodscited by 12
- 2023Large Knowledge Model: Perspectives and Challengescited by 12
- 2023Are Human-generated Demonstrations Necessary for In-context Learning?cited by 11
- 2024Token-based Decision Criteria Are Suboptimal in In-context Learningcited by 9
12 most cited of 34 All 34 (JSON)
- 2026ARASH: Adaptive Retrieval And Shot Selection for Tabular Prediction18 Aug 2026
- 2026Differentially Private Datastore Generation for Retrieval-Augmented Inference31 May 2026
- 2026Self-Improving In-Context Learning22 May 2026
- 2026Nearest-Neighbor Radii under Dependent Sampling14 May 2026
- 2025On the Difficulty of Selecting Few-Shot Examples for Effective LLM-based Vulnerability Detection31 Oct 2025
- 2025PANICL: Mitigating Over-Reliance on Single Prompt in Visual In-Context Learning26 Sep 2025
- 2025CEA-LIST at CheckThat! 2025: Evaluating LLMs as Detectors of Bias and Opinion in Text10 Jul 2025
- 2025From Promising Capability to Pervasive Bias: Assessing Large Language Models for Emergency Department Triage22 Apr 2025
- 2025Latent Factor Models Meets Instructions: Goal-conditioned Latent Factor Discovery without Task Supervision21 Feb 2025
- 2025StaICC: Standardized Evaluation for Classification Task in In-context Learning27 Jan 2025
- 2024LAMPO: Large Language Models as Preference Machines for Few-shot Ordinal Classification6 Aug 2024
- 2024Learning-From-Mistakes Prompting for Indigenous Language Translation18 Jul 2024
12 newest of 34 All 34 (JSON)