Skip to main content
QUICK REVIEW

[Paper Review] Dr.ICL: Demonstration-Retrieved In-context Learning

Man Luo, Xin Xu|arXiv (Cornell University)|May 23, 2023
Topic ModelingComputer Science7 citations
TL;DR

This paper introduces Dr.ICL, a demonstration-retrieved in-context learning framework that enhances LLM performance by retrieving semantically similar demonstrations using off-the-shelf retrievers (BM25, GTR) or a task-specific demonstration retriever. It demonstrates that retrieval-based ICL outperforms random demonstrations, especially in one-shot settings, and improves performance even on instruction-fine-tuned models and with Chain-of-Thought prompting.

ABSTRACT

In-context learning (ICL), teaching a large language model (LLM) to perform a task with few-shot demonstrations rather than adjusting the model parameters, has emerged as a strong paradigm for using LLMs. While early studies primarily used a fixed or random set of demonstrations for all test queries, recent research suggests that retrieving semantically similar demonstrations to the input from a pool of available demonstrations results in better performance. This work expands the applicability of retrieval-based ICL approaches by demonstrating that even simple word-overlap similarity measures such as BM25 outperform randomly selected demonstrations. Furthermore, we extend the success of retrieval-based ICL to instruction-finetuned LLMs as well as Chain-of-Thought (CoT) prompting. For instruction-finetuned LLMs, we find that although a model has already seen the training data at training time, retrieving demonstrations from the training data at test time yields better results compared to using no demonstrations or random demonstrations. Last but not least, we train a task-specific demonstration retriever that outperforms off-the-shelf retrievers.

Motivation & Objective

  • To improve in-context learning (ICL) performance by replacing random or fixed demonstrations with semantically similar ones retrieved from a demonstration pool.
  • To investigate whether training data can be reused at inference time via retrieval to improve performance, even for instruction-fine-tuned LLMs.
  • To evaluate the synergy between Dr.ICL and advanced prompting techniques like Chain-of-Thought (CoT).
  • To develop and train a task-specific demonstration retriever that outperforms off-the-shelf retrieval methods.
  • To assess whether retrieval benefits stem from label overlap or genuine semantic relevance, ruling out simple label identification as the cause.

Proposed method

  • Utilize off-the-shelf sparse (BM25) and dense (GTR) retrievers to retrieve demonstrations semantically similar to the input query.
  • Construct a demonstration retrieval training set by using a language model to re-rank candidate demonstrations retrieved via an off-the-shelf retriever.
  • Form positive and hard-negative examples from top- and bottom-ranked demonstration candidates to train a task-specific demonstration retriever.
  • Apply the trained retriever to select optimal demonstrations for inference, integrating them into the prompt for in-context learning.
  • Combine Dr.ICL with Chain-of-Thought (CoT) prompting to evaluate performance gains in reasoning tasks.
  • Use majority voting in few-shot settings and analyze answer overlap with ground truth to rule out label bias as the cause of performance gains.
Figure 1: The average performance of PaLM and Flan-PaLM on five datasets, with one and few-shot ICL. Retrieved demonstrations given by either BM25 or GTR yield better performance than random demonstrations.
Figure 1: The average performance of PaLM and Flan-PaLM on five datasets, with one and few-shot ICL. Retrieved demonstrations given by either BM25 or GTR yield better performance than random demonstrations.

Experimental results

Research questions

  • RQ1Can retrieval-based ICL with off-the-shelf retrievers (BM25, GTR) outperform random or fixed demonstrations in in-context learning?
  • RQ2Does retrieving demonstrations from the training data improve performance for instruction-fine-tuned LLMs, even when the model has already seen the data during training?
  • RQ3Can Dr.ICL further enhance the performance of advanced prompting techniques like Chain-of-Thought (CoT)?
  • RQ4Does a task-specific demonstration retriever trained on model-generated re-ranking signals outperform off-the-shelf retrievers?
  • RQ5Are the performance gains from retrieval due to label overlap or genuine semantic similarity between queries and demonstrations?

Key findings

  • Off-the-shelf retrievers (BM25 and GTR) consistently outperform random demonstrations in both one-shot and few-shot ICL, with GTR generally retrieving more representative examples than BM25.
  • For instruction-fine-tuned LLMs like Flan-PaLM, retrieving training data demonstrations at inference time yields better performance than using no demonstrations or random ones, even though the model has seen the data during training.
  • Dr.ICL combined with Chain-of-Thought (CoT) improves performance on GSM8k, StrategyQA, and AQuA across both one-shot and few-shot settings, indicating synergy with advanced prompting.
  • A task-specific demonstration retriever trained on re-ranked candidates outperforms off-the-shelf retrievers, with a 1.4-point absolute improvement on NQ and 1.6-point on GSM8k in one-shot ICL.
  • The performance gains from retrieval are not due to label overlap, as demonstrated by low answer overlap ratios in most datasets, suggesting genuine semantic relevance drives the improvements.
  • The most significant improvements from the trained retriever occur in one-shot ICL, where lower latency and memory usage are critical, making it highly suitable for real-world deployment.
Figure 2: Pipeline for training demonstration retriever and inference (R for a neural retriever). Figure on the left shows the procedure of obtaining data to train a demonstration retriever: an off-the-shelf retriever takes an input query $x_{q}$ and retrieves top- $k$ (e.g., 100) demonstrations can
Figure 2: Pipeline for training demonstration retriever and inference (R for a neural retriever). Figure on the left shows the procedure of obtaining data to train a demonstration retriever: an off-the-shelf retriever takes an input query $x_{q}$ and retrieves top- $k$ (e.g., 100) demonstrations can

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.