Skip to main content
QUICK REVIEW

[Paper Review] In-Context Learning with Iterative Demonstration Selection

Chengwei Qin, Aston Zhang|arXiv (Cornell University)|Oct 15, 2023
Topic ModelingComputer Science6 citations
TL;DR

This paper proposes Iterative Demonstration Selection (IDS), a method that iteratively selects diverse yet semantically correlated demonstrations for in-context learning (ICL) using zero-shot chain-of-thought (Zero-shot-CoT) reasoning. By generating reasoning paths for the test sample and selecting demonstrations similar to these paths across iterations, IDS achieves consistent performance gains over existing baselines across multiple NLP tasks, outperforming methods that rely solely on similarity or diversity.

ABSTRACT

Spurred by advancements in scale, large language models (LLMs) have demonstrated strong few-shot learning ability via in-context learning (ICL). However, the performance of ICL has been shown to be highly sensitive to the selection of few-shot demonstrations. Selecting the most suitable examples as context remains an ongoing challenge and an open problem. Existing literature has highlighted the importance of selecting examples that are diverse or semantically similar to the test sample while ignoring the fact that the optimal selection dimension, i.e., diversity or similarity, is task-specific. Based on how the test sample is answered, we propose Iterative Demonstration Selection (IDS) to leverage the merits of both dimensions. Using zero-shot chain-of-thought reasoning (Zero-shot-CoT), IDS iteratively selects examples that are diverse but still strongly correlated with the test sample as ICL demonstrations. Specifically, IDS applies Zero-shot-CoT to the test sample before demonstration selection. The output reasoning path is then used to choose demonstrations that are prepended to the test sample for inference. The generated answer is followed by its corresponding reasoning path for extracting a new set of demonstrations in the next iteration. After several iterations, IDS adopts majority voting to obtain the final result. Through extensive experiments on tasks including reasoning, question answering, and topic classification, we demonstrate that IDS can consistently outperform existing ICL demonstration selection methods.

Motivation & Objective

  • To address the sensitivity of in-context learning (ICL) to demonstration selection, which significantly impacts performance.
  • To identify that the optimal demonstration selection strategy—diversity vs. similarity—is task-specific, challenging the assumption that one dimension universally outperforms the other.
  • To propose a unified method that leverages both diversity and similarity through iterative refinement using zero-shot chain-of-thought reasoning.
  • To improve ICL performance without requiring model fine-tuning or access to model parameters, making it applicable to frozen LLMs.
  • To demonstrate robustness and consistent gains across diverse NLP tasks and LLM architectures.

Proposed method

  • IDS begins by applying zero-shot chain-of-thought prompting (e.g., 'Let’s think step by step.') to the test sample to generate a reasoning path.
  • It then selects training examples most semantically similar to this reasoning path as initial demonstrations, prepended to the test input for inference.
  • The model generates a new answer and its corresponding reasoning path from the inference, which is used as the basis for selecting a new set of demonstrations in the next iteration.
  • This iterative process continues for a fixed number of steps, with each iteration refining the demonstration set based on the evolving reasoning path.
  • After multiple iterations, the final prediction is obtained via majority voting over the outputs from all iterations.
  • Semantic similarity between reasoning paths and demonstrations is computed using Sentence-BERT embeddings to guide selection.
Figure 1: Illustration of in-context learning (ICL) on sentiment analysis. A frozen large language model directly generates the sentiment ‘Positive’ for the test sample ‘I like this movie.’ by taking the demonstrations and the test sample as input.
Figure 1: Illustration of in-context learning (ICL) on sentiment analysis. A frozen large language model directly generates the sentiment ‘Positive’ for the test sample ‘I like this movie.’ by taking the demonstrations and the test sample as input.

Experimental results

Research questions

  • RQ1Is there a consistent superiority of diversity or similarity as the primary criterion for selecting in-context learning demonstrations across different NLP tasks?
  • RQ2Can combining both diversity and similarity in demonstration selection improve in-context learning performance beyond current state-of-the-art methods?
  • RQ3Does iterative refinement using zero-shot chain-of-thought reasoning lead to progressively better demonstration selection and final predictions?
  • RQ4How robust is the proposed method to variations in the number of demonstrations, iterations, and underlying LLM architecture?
  • RQ5Can the method be applied effectively to frozen large language models without parameter updates or access to internal model statistics?

Key findings

  • IDS consistently outperforms existing ICL demonstration selection methods, including Top-k-Consistency-CoT and Random-Voting-CoT, across six diverse NLP datasets.
  • On average, IDS achieves a 0.9% absolute accuracy gain over Top-k-Consistency-CoT across all evaluated datasets, with improvements ranging from 0.4% to 1.2% on individual tasks.
  • With four demonstrations, IDS achieves 90.9% accuracy on the benchmark, compared to 90.0% for Top-k-Consistency-CoT, demonstrating consistent superiority across different demonstration set sizes.
  • IDS maintains strong performance across different numbers of iterations, with peak performance at three iterations, and shows no consistent degradation with more iterations, suggesting robustness to hyperparameter choice.
  • When evaluated on GPT-4, IDS achieves 93.6% accuracy compared to 92.8% for Top-k-Consistency-CoT, confirming its robustness across LLM architectures.
  • The average semantic similarity between test samples and selected demonstrations in IDS (0.46) is lower than Top-k-Consistency-CoT (0.69), indicating that IDS successfully selects more diverse examples while maintaining strong correlation with the test input.
Figure 2: Illustration of our proposed Iterative Demonstration Selection (IDS). IDS first applies Zero-shot-CoT to the test sample to obtain a reasoning path, which is then used to select few-shot demonstrations from training examples through KNN. The selected demonstration examples are prepended to
Figure 2: Illustration of our proposed Iterative Demonstration Selection (IDS). IDS first applies Zero-shot-CoT to the test sample to obtain a reasoning path, which is then used to select few-shot demonstrations from training examples through KNN. The selected demonstration examples are prepended to

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.