Cited by 385Topic ModelingDomain Adaptation and Few-Shot LearningNatural Language Processing Techniques

Learning To Retrieve Prompts for In-Context Learning

Open access
Rubin, Ohad, Herzig, Jonathan, Berant, Jonathan·2022·Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies

Abstract

In-context learning is a recent paradigm in natural language understanding, where a large pretrained language model (LM) observes a test instance and a few training examples as its input, and directly decodes the output without any update to its parameters.However, performance has been shown to strongly depend on the selected training examples (termed prompts).In this work, we propose an efficient method for retrieving prompts for in-context learning using annotated data and an LM.Given an inputoutput pair, we estimate the probability of the output given the input and a candidate training example as the prompt, and label training examples as positive or negative based on this probability.We then train an efficient dense retriever from this data, which is used to retrieve training examples as prompts at test time.We evaluate our approach on three sequence-tosequence tasks where language utterances are mapped to meaning representations, and find that it substantially outperforms prior work and multiple baselines across the board.

AI snapshot

Written from the paper’s full text.

TL;DR

The paper proposes Efficient Prompt Retrieval (EPR), which uses a language model to label which training examples are good in-context prompts and trains a dense retriever from that signal. EPR substantially outperforms prior prompt-retrieval baselines on BREAK, MTOP, and SMCALFLOW.

Key findings

  • With GPT-NEO as both scoring and inference LM, EPR improves over the best baseline from 26.0 to 31.9 on BREAK, from 57.0 to 64.2 on MTOP, and from 51.4 to 54.3 on SMCALFLOW.
  • In the one-shot BREAK setting, EPR reaches 23.0 LF-EM, outperforming the best baseline by 8.5 points and BM25-ORACLE by 5 points.
  • When GPT-NEO is used as a proxy scoring LM for larger inference LMs, EPR outperforms BM25 and CBR by 2–8 points across all datasets and pretrained models.
  • Prompt-copying analysis shows high abstract copying in MTOP and SMCALFLOW (>80%); on MTOP, 84.5% of examples were abstractly copied, and EPR achieved 71.6% EM on that copied subset versus 64.2% overall.

Methods

  • EPR generates training data by retrieving candidate prompts with an unsupervised retriever (BM25 or SBERT; BM25 chosen), scoring each candidate with a scoring LM as Prob(y | candidate, x), and labeling top-k as positive and bottom-k as negative (k=5, L=50).
  • It trains a dense retriever with DPR-style contrastive learning using BERT-base input and prompt encoders, then uses FAISS maximum inner-product search at inference to retrieve prompts within the inference LM’s context limit.
  • Evaluation covers three structured sequence-to-sequence tasks—BREAK, MTOP, and SMCALFLOW—using GPT-NEO as scoring LM and GPT-NEO, GPT-J, GPT-3, or CODEX as inference LMs, with LF-EM/NEM/EM metrics and a 2,048-token context size.

Limitations

  • Paper-stated: the authors note that large language models exhibit bias, and since EPR is trained on signal from such LMs, it might also exhibit these biases.
  • Paper-stated: the method scores each training example independently at training time, while at test time the LM observes a sequence of examples; modeling dependence between examples is left to future work.
  • Evident from the text: evaluation is limited to three English structured tasks mapping utterances to meaning representations, and the approach relies on a scoring LM as a proxy for the inference LM.

Model-written summary. Check it against the paper before relying on it.

Integrity signals

Registry

Crossref · 10.18653/v1/2022.naacl-main.191

Cites

56 of 56 references verified0 citation errors · 0 not checkable

Statistics

Nothing to recompute.

Claims the paper makes

0 of 3 cited sources checked · 0 supported · 0 flagged

  • Findingown data

    EPR substantially improves performance compared to BM25 and CBR on the BREAK and MTOP test sets.

    “Table 3 shows test results on BREAK and MTOP corroborating that EPR substantially improves performance compared to BM25 and CBR.”
    Quote in the paperSubstantial claim
  • Findingnone given

    BM25 outperforms SBERT for prompt retrieval.

    “BM25 outperforms SBERT for prompt retrieval, and consequently we use BM25 in all of our supervised approaches to retrieve the set of candidates, Ē.”
    Quote in the paperSubstantial claim
  • Findingown data

    EPR substantially outperforms all other baselines in the LM-as-a-service setting.

    “EPR substantially outperforms all other baselines.”
    Quote in the paperSubstantial claim
    • The authors state this as an assumption: The candidate set Ē includes good prompt candidates and hard negatives.
  • Findingreasoning

    CODEX outperforms GPT-3.

    “CODEX outperforms GPT-3, which can be explained by the fact that it was trained on code, and our datasets involve mapping to programs or meaning representations.”
    Quote in the paperNot a substantial claim
  • Findingown data

    Accuracy on examples where copying occurred is much higher compared to accuracy where no copying happened.

    “Moreover, accuracy on examples where copying occurred is much higher compared to accuracy where no copying happened.”
    Quote in the paperNot a substantial claim
  • May combine two claims. 10
  • Classified as probably not a substantial claim. 5
  • The quote only partly states this claim. 1
  • May combine two claims.

    Findingown data

    ANYCORRECT-ORACLE reaches 53.6%, 20 points above LM-ORACLE.

    “ANYCORRECT-ORACLE reaches 53.6%, 20 points above LM-ORACLE.”
    Quote in the paperSubstantial claim
  • Probably not a substantial claim: may not pass S3 (load-bearing).

    Findingown data

    Using the target sequence y only for the unsupervised retriever leads to slightly higher performance than using the training pair (x, y).

    “For both, we experimented with passing the retriever the training pair (x, y) or the target sequence y only, and found that using y leads to slightly higher performance.”
    Quote in the paperNot a substantial claim
  • May combine two claims.

    Findingreasoning

    EPR outperforms BM25-ORACLE on MTOP and SMCALFLOW and is comparable on BREAK.

    “Interestingly, EPR outperforms BM25-ORACLE on MTOP and SMCALFLOW and is comparable on BREAK.”
    Quote in the paperSubstantial claim
  • May combine two claims. The quote only partly states this claim.

    Findingown data

    In the BREAK example where EPR is correct and CBR is incorrect, all training examples retrieved by EPR perform an argmax (argmin in the original utterance) and return in the final step a code, while the third example retrieved by CBR does not perform an argmax or argmin and does not involve a code.

    “All training examples retrieved by EPR perform an argmax (argmin in the original utterance), and return in the final step”
    Quote in the paperNot a substantial claim
  • Probably not a substantial claim: may not pass S3 (load-bearing).

    Findingreasoning

    GPT-J performs slightly better than GPT-NEO across the board.

    “Zooming in on different inference LMs, GPT-J performs slightly better than GPT-NEO across the board, since it was trained on the same data and using the same procedure as GPT-NEO.”
    Quote in the paperNot a substantial claim
  • May combine two claims.

    Findingown data

    In the one-shot setup, EPR outperforms the best baseline by 8.5% and BM25-ORACLE by 5%.

    “Indeed, EPR outperforms the best baseline by 8.5%, and BM25-ORACLE by 5%.”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Findingown data

    On MTOP, 84.5% of examples were abstractly copied, and on that subset EPR achieves 71.6% EM, compared to 64.2% on the entire validation set.

    “For example, on MTOP, 84.5% of the examples were abstractly copied, and on that subset of examples, EPR achieves 71.6% EM, compared to 64.2% on the entire validation set.”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Findingown data

    GPT-J outperforms CODEX (except on MTOP) and GPT-3 despite being 30x smaller.

    “Surprisingly, GPT-J outperforms CODEX (except on MTOP) and GPT-3 despite being 30x smaller.”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Findingown data

    In examples from the development sets, EPR is correct while CBR is incorrect.

    “Tables 9, 10, and 11 provide more examples for cases where EPR is correct while CBR is incorrect along with the top-3 prompts for each method.”
    • Also stated in: § 6 Conclusions · plain
      “An example from MTOP development set where EPR is correct and CBR is incorrect along with the top-3 training examples retrieved from each retriever.”
    • Also stated in: § 6 Conclusions · plain
      “An example from SMCALFLOW development set where EPR is correct and CBR is incorrect along with the top-3 training examples retrieved from each retriever.”
    Quote in the paperNot a substantial claim
  • May combine two claims.

    Findingown data

    The rate of copying is much higher in MTOP and SM-CALFLOW compared to BREAK, where in MTOP and SMCALFLOW abstract copying reaches more than 80%.

    “We observe that the rate of copying is much higher in MTOP and SM-CALFLOW compared to BREAK, where in MTOP and SMCALFLOW abstract copying reaches more than 80%.”
    Quote in the paperNot a substantial claim
  • Probably not a substantial claim: may not pass S3 (load-bearing).

    Premisecitation

    Large language models have been shown to exhibit various kinds of bias.

    “Large language models have been shown to exhibit various kinds of bias (Bender et al., 2021)”
    Quote in the paperNot a substantial claim0 of 1 sources checked
    • cites Bender et al., 2021

      Not checked in the free run.

  • Probably not a substantial claim: may not pass S3 (load-bearing).

    Interpretationreasoning

    EPR might also exhibit the biases that large language models exhibit, because EPR is trained on the signal obtained from such large LMs.

    “since EPR is trained on the signal obtained from such large LMs, it might also exhibit these biases.”
    Quote in the paperNot a substantial claim
  • Probably not a substantial claim: may not pass S3 (load-bearing).

    Premisecitation

    LF-EM is a better metric compared to Normalized Exact Match (NEM) for evaluating BREAK because it measures whether two meaning representations are semantically equivalent.

    “On BREAK, we evaluate performance on the development set with LF-EM (Hasson and Berant, 2021), which is a better metric compared to Normalized Exact Match (NEM), the official metric, as it measures whether two meaning representations are semantically equivalent.”
    Quote in the paperNot a substantial claim0 of 1 sources checked
    • cites Hasson and Berant, 2021

      Not checked in the free run.

  • May combine two claims.

    Interpretationown data

    The supervision provided by the scoring LM is strong, and training a better retriever from this signal can substantially enhance performance.

    “The performance of LM-ORACLE is substantially higher than EPR, showing that the supervision provided by the scoring LM is strong, and training a better retriever from this signal can substantially enhance performance.”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Interpretationown data

    EPR captures both lexical and structure similarity.

    “shows that EPR captures both lexical and structure similarity.”
    Quote in the paperSubstantial claim
15 of 15
  • The authors state this as an assumption.

    The candidate set Ē includes good prompt candidates and hard negatives.

    “This should lead to relevant positive examples, assuming that the set of candidates, Ē includes good prompt candidates and hard negatives, since all candidates have high similarity with (x, y) according to R u (y, D).”
1 of 1

Claims other papers make about this one

Each is checked against this paper’s own text: does it say what the citing paper says it does?

  • Instance-level demonstrations generally perform better than task-level demonstrations.

    “Although instance-level demonstrations generally perform better than task-level demonstrations, it requires a labeled training set in advance for retrieval.”

    From What Makes Good In-Context Demonstrations for Code Intelligence Tasks with LLMs? (2023) · cites this paper as [32]

    Section 4.2 compares demonstrations retrieved for each test utterance with randomly sampled training examples, and the Experimental Results report better performance for retrieval on the three tasks studied. The paper does not explicitly compare instance-level with task-level demonstrations as categories, so it does not establish the broader claim that the former generally perform better. The Background section also assumes a training set of input-output pairs for retrieval. (LLM, conf=0.79)

    Experimental — accuracy not yet measured
  • Retrieval allows LLMs to access databases, mitigating hallucinations.

    “Retrieval allows LLMs to access databases, mitigating hallucinations (Li et al. 2022;Wang, Yang, and Wei 2023;Rubin, Herzig, and Berant 2022;Liu et al. 2022).”

    From Expel: LLM agents are experiential learners (2024) · cites this paper as Rubin, Herzig, and Berant 2022

    The Background: Prompt Retrieval Problem setup section describes retrieving examples from a training set and supplying them to a language model as a prompt. This supports retrieval of stored examples, but the paper does not establish that retrieval gives LLMs access to databases or mitigates hallucinations. (LLM, conf=0.81)

    Experimental — accuracy not yet measured
  • Retrieval-based mechanisms can improve language models for various tasks requiring factual or procedural knowledge.

    “Recent work has demonstrated that retrieval-based mechanisms can improve language models for various tasks requiring factual or procedural knowledge (Liu et al., 2021;Poesia et al., 2021;Rubin et al., 2022;Madaan et al., 2022;Shrivastava et al., 2023).”

    From Learning Performance-Improving Code Edits (2023) · cites this paper as Rubin et al., 2022

  • Earlier research has shown several positive pedagogical impacts of using NLP-based social conversational agents on children's perception of their own competencies and their attitudes towards learning.

    “earlier research has showed several positive pedagogical impacts of using NLP-based social conversational agents on children's perception of their own competencies and their attitudes towards learning ([51]).”

Cites

Flagged first, then by citations

Research works printed but not linked: 2

  1. Geoffrey E. Hinton and Sam T. Roweis. 2002. Stochas- tic neighbor embedding. In NIPS.
  2. Urvashi Khandelwal, Angela Fan, Dan Jurafsky, Luke Zettlemoyer, and Mike Lewis. 2021. Nearest Neigh- bor Machine Translation. In Proceedings of ICLR.

Cited by

Sorted by citations

Authors
Rubin, O., Herzig, J., & Berant, J.
Affiliations
Tel Aviv University (IL)
Venue
Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies
Published
2022
Pages
2655-2671
OpenAlex
W4287891464
Cited by
374
References
54
Citations by year
2026: 57 · 2025: 97 · 2024: 91 · 2023: 119 · 2022: 10
FWCI
43.96
Type
conference paper
Language
en
Open access
Licence
cc-by
Locations
  • Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (NAACL-HLT) (publishedVersion, cc-by)
  • arXiv (Cornell University) (submittedVersion)
  • arXiv (Cornell University) (cc-by)
Funders
European Commission
Topics
  • Physical Sciences › Computer Science › Artificial Intelligence › Topic Modeling
  • Physical Sciences › Computer Science › Artificial Intelligence › Domain Adaptation and Few-Shot Learning
  • Physical Sciences › Computer Science › Artificial Intelligence › Natural Language Processing Techniques
Keywords
in-context learning, dense retrievers, training data selection, pre-trained language models, annotated dataset, meaning representation

About these checks

Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.

Claims read by deepseek-v4.1-flash under definition version 3 (extract-v3) on 2026-10-06.

Classified by jev-1.13-20260917 (gold-guideline-v0.2) on 2026-10-06.

Statistics and arithmetic are recomputed, not judged.

Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.

What counts as a claim ›How we measure confidence ›How we check this ›

Are you an author, or do you see a problem with this page? Request a review