Pool-Search-Demonstrate: Improving Data-wrangling LLMs via better in-context examples

Joon Suk Huh, Changho Shin, Elina ChoiTRL @ NeurIPS 2023

TL;DR

This paper introduces "Pool-Search-Demonstrate" (PSD), a novel method for selecting better in-context examples to improve the performance of Large Language Models (LLMs) on data-wrangling tasks. By leveraging embeddings to find relevant and diverse examples from a pool, PSD significantly outperforms random and manual selection, demonstrating the power of intelligent example selection for LLM prompting.

What Problem Does This Paper Address?

Data-wrangling, the process of cleaning and transforming raw data for analysis, is a crucial but often tedious task. While recent work has shown that foundation models (FMs) can automate data-wrangling, the effectiveness of these models heavily relies on how prompts are constructed. A key component of these prompts is the inclusion of "in-context examples" (demonstrations) that guide the LLM. However, previous methods relied on manually selected examples, which is time-consuming and not scalable to new datasets. This paper addresses the challenge of automatically selecting high-quality, individualized in-context examples that maximize LLM performance on data-wrangling tasks.

Methods

The core of this paper is the Pool-Search-Demonstrate (PSD) method. It works in two main stages:

  1. Embedding-based Example Retrieval:
    • A "demonstration pool" is created, typically from the training dataset.
  2. For a given input data-wrangling query, its embedding is computed.
  3. The method then searches the demonstration pool for examples whose embeddings are closest to the input query's embedding. This ensures relevancy.
  4. To promote diversity, the pool is initially clustered (e.g., using k-means), and examples are selected from these diverse clusters. The number of clusters (k) controls diversity, while the number of selected examples (m) controls quantity and relevancy.
  5. Class Embedding (Post-processing):
    • This method addresses the output of the LLM. For tasks with a finite and relatively large label space (e.g., classification), it uses embeddings to map the LLM's raw output to the correct label.
  6. It leverages a "closed-world assumption" and an embedding map to find the label whose embedding is closest to the LLM's output embedding. This is particularly useful when the LLM's output might be slightly noisy or phrased differently than the true label.

Datasets

The paper evaluates its methods on several standard datasets for data-wrangling tasks:

  • Data Imputation: Buy, Restaurant
  • Entity Matching: DBLP-ACM, Walmart-Amazon
  • Error Detection: Hospital, Adult

These datasets are standard benchmarks for data-wrangling tasks and were used in prior work, allowing for direct comparison.

Key Insights and Ideas

  • Intelligent Example Selection is Crucial: The paper strongly reinforces that how you select demonstration examples for LLMs matters immensely, especially for complex tasks like data-wrangling.
  • Relevancy and Diversity Pay Off: PSD's success highlights that selecting examples that are both similar to the input (relevancy) and come from different types of data points (diversity) significantly boosts performance.
  • Larger Models Benefit More from Better Examples: The study observed that larger models (like Vicuna-7B) show a more pronounced improvement with better demonstration examples compared to smaller models (like FLAN-T5-3B), suggesting they are more adept at leveraging in-context learning.
  • Class Embedding for Robustness: The class embedding post-processing method offers a clever way to improve accuracy, especially for tasks with many possible labels, by making the LLM's output more robust to minor variations.
  • Demonstrations are More Important Than Ever: The paper confirms that demonstrations play a critical role, and their quality can even compensate for smaller model sizes.

Key Results

The proposed Pool-Search-Demonstrate (PSD) method, combined with class embedding, achieved significant performance improvements:

  • Up to 84% improvement over randomly selected examples.
  • Up to 49% improvement over manually selected examples.
  • PSD often achieved performance comparable to or better than previous state-of-the-art ML and FM-based methods, even with smaller models.
  • The class embedding method showed a proportional gain with the cardinality of the label space, indicating its utility for tasks with many potential outputs.

Limitations and Future Work

  • Model Size Dependency: While PSD improves performance across models, the gains are more substantial for larger models. Future work could explore how to optimize PSD for smaller models.
  • Cost of Full Pool: Using the entire training dataset as the demonstration pool yields the best results, but this can be computationally expensive. The paper suggests that clustering (using centroids) can offer comparable results with reduced cost, hinting at future work on efficient pool management.
  • Class Embedding Scope: The class embedding method's effectiveness is tied to the cardinality of the label space. Future research could explore its application to tasks with larger or continuous label spaces, such as text generation.
  • Generalization: While tested on data-wrangling, exploring PSD and class embedding on other complex NLP tasks like text classification or generation could reveal broader applicability.

Summary updated

BibTeX
@inproceedings{huh2023pool,
  author = {Joon Suk Huh and Changho Shin and Elina Choi},
  title = {{Pool-Search-Demonstrate: Improving Data-wrangling LLMs via better in-context examples}},
  booktitle = {TRL @ NeurIPS},
  year = {2023},
  url = {https://openreview.net/forum?id=6Kb3pE9nWQ},
}
Figure