Retrieval

Retrieve In-Context Examples for LLMs

First page
Retrieve In-Context Examples for LLMs
Paper summary

A framework to iteratively train dense retrievers that identify high-quality in-context examples.

Ask this paper

Key points
01

Iterative training: Trains retrievers using LLM feedback in an iterative loop - retrieved examples that help the LLM answer correctly are used as positive signals.

02

30-task evaluation: Evaluated across 30 NLP tasks showing consistent improvements over random or similarity-based retrieval.

03

Pattern-similar examples: Confirms that examples sharing abstract patterns (not just surface similarity) are most useful for ICL.

04

Scale-invariant gains: Improvements are consistent across model sizes, suggesting dense retrieval is a robust ICL enhancement that transfers across model scales.

Abstract

Large language models (LLMs) have demonstrated their ability to learn in-context, allowing them to perform various tasks based on a few input-output examples. However, the effectiveness of in-context learning is heavily reliant on the quality of the selected examples. In this paper, we propose a novel framework to iteratively train dense retrievers that can identify high-quality in-context examples for LLMs. Our framework initially trains a reward model based on LLM feedback to evaluate the quality of candidate examples, followed by knowledge distillation to train a bi-encoder based dense retriever. Our experiments on a suite of $30$ tasks demonstrate that our framework significantly enhances in-context learning performance. Furthermore, we show the generalization ability of our framework to unseen tasks during training. An in-depth analysis reveals that our model improves performance by retrieving examples with similar patterns, and the gains are consistent across LLMs of varying sizes. The code and data are available at https://github.com/microsoft/LMOps/tree/main/llm_retriever .

Every Monday
Get next week’s papers.
Subscribe on Substack