GistScore: Learning Better Representations for In-Context Example Selection with Gist Bottlenecks

Shivanshu Gupta, Clemens Rosenbaum, Ethan R. Elenberg · OpenReview

Abstract

Large language models (LLMs) have the ability to perform in-context learning (ICL) of new tasks by conditioning on prompts comprising a few task examples. This work studies the problem of selecting the best examples given a candidate pool to improve ICL performance on a given test input. Existing approaches either require training with feedback from a much larger LLM or are computationally expensive. We propose a novel metric, GistScore, based on Example Gisting, a novel approach for training example retrievers for ICL using an attention bottleneck via Gisting. On 21 diverse datasets spanning 9 tasks, we show that our fine-tuned models get state-of-the-art ICL performance with 20% absolute average gain over off-the-shelf retrievers and 7% over the best prior methods. Our multi-task model generalizes well out-of-the-box to new task categories, datasets, and prompt templates with retrieval speeds that are consistently thousands of times faster than the best prior training-free method.

Introduction

Large Language Models (LLMs) are remarkably capable of In-Context Learning (ICL)—the ability to perform new tasks by observing a few examples within a prompt. However, ICL performance is notoriously sensitive to the specific examples selected. Standard retrieval methods, such as BM25 (keyword matching) or SBERT (general semantic similarity), are often "task-blind," failing to prioritize the specific features—like emotional tone or logical structure—that define a task. Conversely, advanced methods like BERTScore offer higher accuracy but are computationally heavy, making them impractical for real-time applications involving long contexts. GistScore addresses this gap by providing a task-aware retriever that is both highly accurate and exceptionally fast.

Methods: Example Gisting and GistScore

The researchers introduce a two-part framework: Example Gisting for training and GistScore for retrieval.

Example Gisting

This novel training technique utilizes an encoder-decoder architecture with an inserted "bottleneck" of special gist tokens. During training, the model is forced to predict the target output (e.g., a label or a translation) by attending only to these gist tokens. This pressure forces the model to compress the most salient, task-specific information from the input instruction and example into a compact set of token embeddings, effectively filtering out task-irrelevant noise.

Overview of Example Gisting training and GistScore retrieval.

GistScore Retrieval

Once trained, the decoder is discarded. To find the optimal examples for a new test input, both the test input and all candidate examples are passed through the gisting encoder. The similarity between their respective gist tokens is then calculated to produce the GistScore. Because the computation involves comparing a few compressed tokens rather than entire sequences, the process is highly efficient. The study evaluates both a fine-tuned version (optimized for specific datasets) and a multi-task version (trained on 5 million prompts from the FLAN 2022 collection) designed for zero-shot generalization.

Key Insights

  • The Bottleneck as a Filter: By restricting the model's view to gist tokens, it learns to ignore superficial details (like specific names or dates) and focus on underlying logic or sentiment. Visualizations show that gist embeddings naturally cluster by task-relevant features, such as sentiment polarity, even without explicit supervision.
  • Scalability for Complex Tasks: While a single gist token suffices for simple classification, complex tasks like semantic parsing benefit from multiple gist tokens (up to 15), allowing the model to capture multiple facets of information.

Key Results

The proposed method was evaluated across 21 datasets covering 9 task categories, including Natural Language Inference (NLI), Reasoning (CoT), and Semantic Parsing.

  • Superior Accuracy: Fine-tuned GistScore models achieved state-of-the-art performance, outperforming standard retrievers by over 20% absolute average gain and beating the best specialized prior methods by 7%.
  • Extreme Efficiency: GistScore is roughly three orders of magnitude (1,000x) faster than BERTScore-Recall (BSR), the strongest previous training-free baseline. As illustrated in Figure 6, this speedup is consistent across a wide array of datasets, sometimes even outperforming BM25 in GPU-accelerated settings.
  • Robust Generalization: The multi-task model generalized effectively to unseen tasks and prompt templates, matching or exceeding the performance of prior specialized methods out-of-the-box.
Speedup of GistScore compared to BM25 and BERTScore-Recall (BSR).

Conclusion and Future Work

GistScore represents a significant advancement in efficient, task-aware example selection for ICL. While the multi-task model shows impressive generalization, a performance gap remains in complex semantic parsing tasks not represented in the training corpus. Future work will explore dynamic gisting lengths to adapt to input complexity and the application of gisting to Retrieval-Augmented Generation (RAG) to improve the efficiency of processing large-scale retrieved contexts.

Summary updated

BibTeX
@inproceedings{gupta2024gistscore,
  author = {Shivanshu Gupta and Clemens Rosenbaum and Ethan R. Elenberg},
  title = {{GistScore: Learning Better Representations for In-Context Example Selection with Gist Bottlenecks}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=WCVC5wGZyz},
}
Figure