[Paper Review] Learning To Retrieve Prompts for In-Context Learning
This paper proposes EPR (Efficient Prompt Retrieval), a method that uses a language model as a scoring function to label training examples as good or bad prompts based on their likelihood of generating the correct output. It then trains a dense retriever via contrastive learning on these labels, significantly improving in-context learning performance across three sequence-to-sequence tasks, with gains of up to 7.7% on Break and 7.2% on MTop compared to prior baselines.
In-context learning is a recent paradigm in natural language understanding, where a large pre-trained 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 prompt). In this work, we propose an efficient method for retrieving prompts for in-context learning using annotated data and a LM. Given an input-output 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-to-sequence tasks where language utterances are mapped to meaning representations, and find that it substantially outperforms prior work and multiple baselines across the board.
Motivation & Objective
- To address the critical challenge that in-context learning performance heavily depends on the choice of few-shot training examples (prompts).
- To develop a method that learns to retrieve high-quality prompts without requiring access to model parameters or fine-tuning.
- To train a lightweight, efficient dense retriever using language model-generated supervision for prompt selection.
- To enable effective interaction with large language models, especially in settings where model weights are inaccessible (e.g., API-only use).
- To improve performance on structured sequence-to-sequence tasks such as semantic parsing and task-oriented dialogue.
Proposed method
- For each training example (x, y), the method uses an unsupervised retriever to retrieve candidate prompts from the training set.
- A scoring language model estimates P(y|x, prompt) for each candidate prompt, measuring how likely the correct output y is given the input x and the prompt.
- Prompts with high P(y|x, prompt) are labeled as positive; those with low probability are labeled as negative.
- A contrastive learning objective is used to train a dense retriever on the labeled data, learning to retrieve high-quality prompts at test time.
- The scoring LM can be smaller than the inference LM, enabling efficient data generation, or identical to it, supporting API-based deployment.
- The final retriever is used at inference time to retrieve the most relevant training examples as prompts for a test input.
Experimental results
Research questions
- RQ1Can a language model be used as a proxy to generate high-quality supervision for training a prompt retriever in in-context learning?
- RQ2Does using LM-generated labels for prompt quality lead to better retrieval performance than surface-similarity heuristics?
- RQ3Can a lightweight retriever trained on LM-supervised data outperform baselines on downstream sequence-to-sequence tasks?
- RQ4How effective is the method when the scoring LM is smaller than the inference LM, or when both are identical (e.g., GPT-3)?
- RQ5To what extent does the retriever rely on high-ranking prompts during inference, and does it generalize beyond exact pattern copying?
Key findings
- EPR improves in-context learning performance on the Break benchmark by 5.9 percentage points, increasing accuracy from 26% to 31.9% when using GPT-Neo as both scoring and inference LM.
- On the MTop dataset, EPR achieves a 7.2 percentage point improvement, rising from 57% to 64.2% accuracy under the same setup.
- On SMCalFlow, EPR boosts performance from 51.4% to 54.3%, demonstrating consistent gains across diverse tasks.
- When using GPT-Neo as a proxy for larger models (GPT-J, GPT-3, Codex), EPR still achieves substantial gains, showing robustness across model scales.
- The retriever primarily copies from high-ranking prompts, as shown by the distribution of copying distances in Break, indicating effective retrieval of semantically relevant examples.
- Even in cases without exact copying, the model generalizes to new structures, indicating that the retriever supports meaningful in-context learning beyond memorization.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.