[Paper Review] Compositional Exemplars for In-context Learning
CEIL models the joint probability of in-context exemplars with a conditional DPP, trained via a contrastive objective, to select diverse yet relevant demonstration sets for in-context learning, achieving state-of-the-art results across 12 tasks/datasets and demonstrating transferability and compositionality.
Large pretrained language models (LMs) have shown impressive In-Context Learning (ICL) ability, where the model learns to do an unseen task via a prompt consisting of input-output examples as the demonstration, without any parameter updates. The performance of ICL is highly dominated by the quality of the selected in-context examples. However, previous selection methods are mostly based on simple heuristics, leading to sub-optimal performance. In this work, we formulate in-context example selection as a subset selection problem. We propose CEIL (Compositional Exemplars for In-context Learning), which is instantiated by Determinantal Point Processes (DPPs) to model the interaction between the given input and in-context examples, and optimized through a carefully-designed contrastive learning objective to obtain preference from LMs. We validate CEIL on 12 classification and generation datasets from 7 distinct NLP tasks, including sentiment analysis, paraphrase detection, natural language inference, commonsense reasoning, open-domain question answering, code generation, and semantic parsing. Extensive experiments demonstrate not only the state-of-the-art performance but also the transferability and compositionality of CEIL, shedding new light on effective and efficient in-context learning. Our code is released at https://github.com/HKUNLP/icl-ceil.
Motivation & Objective
- Motivate robust in-context learning (ICL) by optimizing exemplar selection rather than relying on hand-crafted heuristics.
- Model the inter-relationships among in-context examples to avoid redundancy and improve coverage of the task.
- Develop a learnable retriever that jointly selects a subset of exemplars conditioned on the test input.
- Align the exemplar subset quality with LM guidance via a contrastive learning objective.
Proposed method
- Define a conditional DPP kernel that combines relevance to the test input and diversity among exemplars.
- Incorporate a learning-based embedding for inputs and exemplars to compute the DPP kernel; introduce a trade-off parameter lambda to balance relevance and diversity.
- Train with a contrastive loss (InfoNCE or pair-wise margin) using LM-derived subset scores to rank exemplar subsets.
- Perform MAP inference with a greedy algorithm (with Cholesky updates) for efficient subset selection at test time.
- Use a two-stage retrieval setup to sample candidate subsets and train the retriever without requiring ground-truth exemplar sets.
Experimental results
Research questions
- RQ1Can a conditional DPP-based retriever capture inter-example interactions to improve ICL performance?
- RQ2Does jointly modeling relevance and diversity in exemplar selection yield better downstream results than independent retrieval methods?
- RQ3Are CEIL-trained exemplars transferable across different LMs and datasets, and can CEIL reveal compositionality in exemplars?
- RQ4How does exemplar subset size and the trade-off parameter affect performance across tasks?
Key findings
- CEIL substantially outperforms learning-free and learning-based baselines across 12 datasets and 7 tasks, including NLI, sentiment, commonsense reasoning, and code generation.
- CEIL demonstrates transferability across LMs (GPT-Neo, GPT-2 XL, Codex) and across datasets, enabling learning-free deployment in some cases.
- CEIL inherently learns to compose exemplars, improving performance on compositional semantic parsing tasks and showing advantages in compositional splits.
- Small exemplar sets benefit many tasks, with CEIL maintaining strong performance even with constrained prompt lengths.
- Compared to EPR and TopK-BERT, CEIL achieves consistent absolute gains across most tasks, and gains are especially notable on NLI tasks.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.