mlsanityData to 7 Oct 2026

kNN Prompting: Beyond-Context Learning with Calibration-Free Nearest Neighbor Inference

arXiv 2303.13824 ↗First posted 24 Mar 2023cs.CL cs.AIcited by 47

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

  1. 2020Language Models are Few-Shot Learnerscited by 32,199
  2. 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,491
  3. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
  4. 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,160
  5. 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,049
  6. 2020Measuring Massive Multitask Language Understandingcited by 7,768
  7. 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,304
  8. 2022Large Language Models are Zero-Shot Reasonerscited by 4,323
  9. 2021On the Opportunities and Risks of Foundation Modelscited by 3,961
  10. 2021Finetuned Language Models Are Zero-Shot Learnerscited by 3,747
  11. 2022OPT: Open Pre-trained Transformer Language Modelscited by 3,464
  12. 2022Emergent Abilities of Large Language Modelscited by 2,483
37 more
  1. 2015Character-level Convolutional Networks for Text Classificationcited by 2,293
  2. 2021SimCSE: Simple Contrastive Learning of Sentence Embeddingscited by 2,168
  3. 2022Beyond the Imitation Game: Quantifying and extrapolating the capabilities of language modelscited by 1,970
  4. 2021Multitask Prompted Training Enables Zero-Shot Task Generalizationcited by 1,462
  5. 2021Calibrate Before Use: Improving Few-Shot Performance of Language Modelscited by 1,371
  6. 2021Improving language models by retrieving from trillions of tokenscited by 1,278
  7. 2021Scaling Language Models: Methods, Analysis & Insights from Training Gophercited by 1,199
  8. 2021What Makes Good In-Context Examples for GPT-3?cited by 1,184
  9. 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,122
  10. 2019How Can We Know What Language Models Know?cited by 953
  11. 2020Language (Technology) is Power: A Critical Survey of "Bias" in NLPcited by 951
  12. 2022Atlas: Few-shot Learning with Retrieval Augmented Language Modelscited by 940
  13. 2020Exploiting Cloze Questions for Few Shot Text Classification and Natural Language Inferencecited by 934
  14. 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 915
  15. 2020StereoSet: Measuring stereotypical bias in pretrained language modelscited by 911
  16. 2019Generalization through Memorization: Nearest Neighbor Language Modelscited by 788
  17. 2021Learning To Retrieve Prompts for In-Context Learningcited by 641
  18. 2022Using DeepSpeed and Megatron to Train Megatron-Turing NLG 530B, A Large-Scale Generative Language Modelcited by 557
  19. 2017Deep Learning Scaling is Predictable, Empiricallycited by 556
  20. 2021MetaICL: Learning to Learn In Contextcited by 450
  21. 2020How Can We Know When Language Models Know? On the Calibration of Language Models for Question Answeringcited by 439
  22. 2021Surface Form Competition: Why the Highest Probability Answer Isn't Always Rightcited by 256
  23. 2018A Simple Method for Commonsense Reasoningcited by 223
  24. 2020Nearest Neighbor Machine Translationcited by 209
  25. 2018Deep k-Nearest Neighbors: Towards Confident, Interpretable and Robust Deep Learningcited by 203
  26. 2019A Constructive Prediction of the Generalization Error Across Scalescited by 202
  27. 2021Noisy Channel Language Model Prompting for Few-Shot Text Classificationcited by 163
  28. 2021Meta-learning via Language Model In-context Tuningcited by 163
  29. 2017Generating Sentences by Editing Prototypescited by 88
  30. 2018Retrieve and Refine: Improved Sequence Generation Models For Dialoguecited by 82
  31. 2017Learning to Remember Rare Eventscited by 63
  32. 2022Training Data is More Valuable than You Think: A Simple and Effective Method by Retrieving from Training Datacited by 61
  33. 2022Mitigating Gender Bias in Distilled Language Models via Counterfactual Role Reversalcited by 40
  34. 2022Decoupling Knowledge from Memorization: Retrieval-augmented Prompt Learningcited by 36
  35. 2022kNN-Prompt: Nearest Neighbor Zero-Shot Inferencecited by 27
  36. 2018A Simple Cache Model for Image Recognitioncited by 20
  37. 2021Trans-Encoder: Unsupervised sentence-pair modelling through self- and mutual-distillationscited by 20

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2023: 18; 2024: 16; 2025: 8; 2026: 5.

47 papers.

Sort:

By area:

  1. 2023Jailbreak and Guard Aligned Language Models with Only Few In-Context Demonstrationscited by 401
  2. 2023In-context Vectors: Making In Context Learning More Effective and Controllable Through Latent Space Steeringcited by 240
  3. 2023Unified Demonstration Retriever for In-Context Learningcited by 141
  4. 2023ExpertPrompting: Instructing Large Language Models to be Distinguished Expertscited by 140
  5. 2023Batch Calibration: Rethinking Calibration for In-Context Learning and Prompt Engineeringcited by 91
  6. 2023On the Calibration of Large Language Models and Alignmentcited by 72
  7. 2023Self-Knowledge Guided Retrieval Augmentation for Large Language Modelscited by 69
  8. 2024Demystifying Chains, Trees, and Graphs of Thoughtscited by 63
  9. 2023Self-Verification Improves Few-Shot Clinical Information Extractioncited by 52
  10. 2023Forward-Backward Reasoning in Large Language Models for Mathematical Verificationcited by 39
  11. 2023Which Examples to Annotate for In-Context Learning? Towards Effective and Efficient Selectioncited by 36
  12. 2024Mixture of In-Context Prompters for Tabular PFNscited by 32
35 more
  1. 2023Tree Prompting: Efficient Task Adaptation without Fine-Tuningcited by 17
  2. 2024Enhancing In-context Learning via Linear Probe Calibrationcited by 16
  3. 2023InstructEval: Systematic Evaluation of Instruction Selection Methodscited by 12
  4. 2023Large Knowledge Model: Perspectives and Challengescited by 12
  5. 2023Are Human-generated Demonstrations Necessary for In-context Learning?cited by 11
  6. 2024Few-shot Dialogue Strategy Learning for Motivational Interviewing via Inductive Reasoningcited by 11
  7. 2024Token-based Decision Criteria Are Suboptimal in In-context Learningcited by 9
  8. 2024Vocabulary-Defined Semantics: Latent Space Clustering for Improving In-Context Learningcited by 7
  9. 2023Dynamic Demonstrations Controller for In-Context Learningcited by 6
  10. 2023RecallM: An Adaptable Memory Mechanism with Temporal Understanding for Large Language Modelscited by 5
  11. 2024No Train, all Gain: Self-Supervised Gradients Improve Deep Frozen Representationscited by 5
  12. 2024LAMPO: Large Language Models as Preference Machines for Few-shot Ordinal Classificationcited by 5
  13. 2024Self-Instructed Derived Prompt Generation Meets In-Context Learning: Unlocking New Potential of Black-Box LLMscited by 5
  14. 2025From Promising Capability to Pervasive Bias: Assessing Large Language Models for Emergency Department Triagecited by 5
  15. 2024A Study on Training and Developing Large Language Models for Behavior Tree Generationcited by 4
  16. 2024Attribute Structuring Improves LLM-Based Evaluation of Clinical Text Summariescited by 4
  17. 2024Evaluating and Safeguarding the Adversarial Robustness of Retrieval-Based In-Context Learningcited by 4
  18. 2025TestNUC: Enhancing Test-Time Computing Approaches and Scaling through Neighboring Unlabeled Data Consistencycited by 4
  19. 2023kNN-ICL: Compositional Task-Oriented Parsing Generalization with Nearest Neighbor In-Context Learningcited by 3
  20. 2023Matching Table Metadata with Business Glossaries Using Large Language Modelscited by 2
  21. 2024AICL: Action In-Context Learning for Video Diffusion Modelcited by 2
  22. 2024Learning-From-Mistakes Prompting for Indigenous Language Translationcited by 2
  23. 2025StaICC: Standardized Evaluation for Classification Task in In-context Learningcited by 2
  24. 2024Feature-Adaptive and Data-Scalable In-Context Learningcited by 1
  25. 2025Latent Factor Models Meets Instructions: Goal-conditioned Latent Factor Discovery without Task Supervisioncited by 1
  26. 2025CEA-LIST at CheckThat! 2025: Evaluating LLMs as Detectors of Bias and Opinion in Textcited by 1
  27. 2025PANICL: Mitigating Over-Reliance on Single Prompt in Visual In-Context Learningcited by 1
  28. 2026ARASH: Adaptive Retrieval And Shot Selection for Tabular Predictioncited by 1
  29. 2024Leveraging Biases in Large Language Models: "bias-kNN'' for Effective Few-Shot Learningcited by 0
  30. 2025Efficient Knowledge Feeding to Language Models: A Novel Integrated Encoder-Decoder Architecturecited by 0
  31. 2025On the Difficulty of Selecting Few-Shot Examples for Effective LLM-based Vulnerability Detectioncited by 0
  32. 2026Nearest-Neighbor Radii under Dependent Samplingcited by 0
  33. 2026Self-Improving In-Context Learningcited by 0
  34. 2026Differentially Private Datastore Generation for Retrieval-Augmented Inferencecited by 0
  35. 2026HIRA: A Human-in-the-Loop Retrieval-Augmented Cascade for Document Classification in Regulated Industriescited by 0