Source-linked AI summary

DemoShapley: Valuation of Demonstrations for In-Context Learning

Shan Xie, Man Luo, Chadly Daniel Stern, Mengnan Du, Lu Cheng

arXiv:2410.07523v3cs.CLcs.AIcs.LG

TL;DR

ICL results are sensitive to which demonstrations appear and in what order, while existing influence approaches often assess them at fixed prompt sizes. DemoShapley averages marginal contributions across prompt permutations, and Beta-DemoShapley weights smaller subsets; the paper reports gains in performance, OOD transfer, noise identification, and fairness.

  • Problem

    Existing influence-based approaches often evaluate demonstrations at a fixed prompt size, despite contributions varying across prompt sizes and short prompts being common under context limits.

    Source: §I · p. 1
  • Method

    DemoShapley estimates each demonstration’s marginal effect across prompt permutations, and Beta-DemoShapley gives greater weight to smaller subsets.

    Source: §I · pp. 1–2
  • Results

    The methods are reported to improve ICL performance and OOD transfer, identify mislabeled examples, and reduce demographic disparities while maintaining accuracy.

    Source: §I · p. 2, F. Discussion · p. 8
  • Takeaways & Limitations

    Inference-time valuation makes the framework applicable to closed-source models where fine-tuning is not feasible.

    Source: F. Discussion · p. 8

Abstract

from arXiv · show

Large language models (LLMs) using in-context learning (ICL) excel in many tasks without task-specific fine-tuning. However, demonstration selection and ordering greatly impact ICL effectiveness. Focus on this issue, we propose DemoShapley, a Shapley-value based method that evaluates each demonstration's contribution by measuring its marginal effect across different prompt permutations. To further account for ICL's limited context windows and frequent low-shot settings, we introduce Beta-DemoShapley, a weighted extension that emphasizes the influence of smaller prompt sizes. Experiments on multiple benchmarks show that DemoShapley consistently outperforms existing influence-based selection strategies, while Beta-DemoShapley further improves performance in low-shot scenarios. Both methods also detect mislabeled data, enhance generalization to out-of-distribution tasks, and reduce demographic bias. Together, they provide a unified and robust framework for demonstration valuation in ICL.

I. INTRODUCTION

ICL performance is sensitive to demonstration choice, order, and format, while existing valuation approaches often miss how contributions vary across prompt sizes. DemoShapley averages marginal contributions across prompt permutations, and Beta-DemoShapley weights smaller subsets; the paper reports benefits for performance, OOD generalization, label-noise identification, and fairness.

I. INTRODUCTION

  • ICL outcomes vary with demonstration choice, order, and format, making high-quality selection important for robust predictions.Noisy or poorly chosen examples may degrade performance.Source: §I · p. 1
  • Existing approaches often assess examples at a fixed prompt size or order, while similarity and diversity measures may not align with the task metric.Gradient- or retraining-dependent approaches may also be infeasible for closed-source LLMs and inference-only ICL; short prompts are common under context limits.Source: §I · p. 1
  • DemoShapley estimates each demonstration’s marginal contribution across prompt permutations, while Beta-DemoShapley weights smaller subsets to reflect low-shot and short-context settings.The methods adapt Shapley-based valuation to order-sensitive ICL.Source: §I · p. 1
  • The framework assesses demonstrations across different prompt permutations to identify examples with positive or negative effects on predictions.This averages out ordering effects rather than judging an example from a single prompt.Source: §I · p. 2
  • Shapley-based demonstration selection is reported to improve performance and OOD generalization, identify mislabeled examples, and reduce demographic disparities while maintaining accuracy.The paper presents these results as making ICL more reliable and robust in practice.Source: §I · p. 2

A. Data Valuation

Data valuation methods estimate the importance of examples, while ICL selection strategies use similarity, diversity, learned signals, or direct optimization. DemoShapley adds order-aware valuation, and Beta-DemoShapley weights smaller subsets.

A. Data Valuation

  • Data valuation approaches include leave-one-out, cooperative-game methods such as Shapley values, and desiderata-driven variants that trade theoretical guarantees against efficiency or particular goals.Other approaches include reinforcement-learning valuation and influence methods that track gradient-descent dynamics.Source: A. Data Valuation · p. 2

B. ICL Demonstration Selection

  • ICL demonstration selection spans similarity retrieval, diversity, complexity, learned signals, gradient matching, generative preference learning, and affinity-diversity metrics.Prior work reports gains from these approaches, including improvements over random selection across 4–128-shot settings for gradient matching.Source: B. ICL Demonstration Selection · p. 2
  • DemoShapley averages contribution estimates across prompt permutations, while Beta-DemoShapley adds cardinality-aware weighting that emphasizes smaller subsets.The methods rely on inference rather than gradients or fine-tuning, making them applicable to closed-source LLMs.Source: B. ICL Demonstration Selection · p. 2
  • The illustrated procedure starts from zero-shot prompts, adds demonstrations sequentially, and updates values; Beta-DemoShapley applies a precomputed weight during updates.The algorithm repeats the process to evaluate candidate examples.Source: Figure 1 · p. 3

A. Preliminaries

Data Shapley values examples by their marginal effects across subsets, and Beta Shapley changes the weighting of subset sizes. DemoShapley adapts this valuation to prompt order, while truncated Monte Carlo sampling reduces its computation cost.

1) Data Shapley:

  • Data Shapley assigns a data point a value based on its marginal contribution to a learning algorithm’s performance across subsets.The binomial coefficient normalizes contributions over subsets of size |S|.Source: 1) Data Shapley · p. 3

2) Beta Shapley:

  • Beta Shapley replaces uniform subset-size weighting with a Beta-distribution weighting that emphasizes smaller subsets.The motivation is that marginal contributions may vanish for large subsets, limiting distinctions among examples under uniform weighting.Source: 2) Beta Shapley · p. 3

B. From Data Shapley to (Beta-)DemoShapley

  • DemoShapley estimates a demonstration’s marginal contribution by adding demonstrations to prompts in different orders; Beta-DemoShapley gives greater weight to smaller subsets.The weighting aligns with limited prompt length, where an individual demonstration can substantially affect predictions.Source: B. From Data Shapley to… · p. 3
  • Exact DemoShapley computation is expensive because it requires evaluating exponentially many prompt permutations, so the method uses truncated Monte Carlo sampling to reduce cost.The sampling approximates Shapley values using randomly sampled subsets.Source: B. From Data Shapley to… · p. 3

1) Weight Computation for (Beta-)DemoShapley:

Beta-DemoShapley uses predetermined Beta-distribution weights to emphasize selected subset sizes. The parameters control whether smaller or larger subsets receive greater emphasis, while α = β = 1 recovers uniform weighting.

1) Weight Computation for (Beta-)DemoShapley:

  • The Beta-distribution weighting is motivated by short context windows, where contributions within small subsets are more informative, and its one-time precomputation does not increase runtime complexity.Weights can be reused during estimation and their calculation is negligible compared with LLM inference.Source: 1) Weight Computation for… · pp. 3–4
  • When α > 1 and β = 1, the weighting emphasizes smaller subsets, corresponding to prompts with few demonstrations.This setting also reduces the effect of noisy signals from very large subsets.Source: 1) Weight Computation for… · p. 4
  • When α = 1 and β > 1, the weighting emphasizes larger subsets, a setting described as more suitable when long prompts are available.Source: 1) Weight Computation for… · p. 4
  • The special case α = β = 1 recovers Data Shapley’s uniform weighting across subset sizes and yields the original DemoShapley algorithm.The normalized weight is one for every subset size.Source: 1) Weight Computation for… · p. 4

2) A Unified Framework:

The unified framework adapts TMC-Shapley to value demonstrations by estimating marginal contributions across sampled prompt subsets and permutations. Beta-DemoShapley changes the subset-cardinality weights to emphasize smaller subsets.

2) A Unified Framework:

  • DemoShapley’s value for a demonstration is a weighted mean of its marginal contributions across sampled subsets, with j denoting subset size excluding that demonstration.Setting α = β = 1 gives uniform weights; other settings yield Beta-DemoShapley.Source: 2) A Unified Framework · p. 4
  • The algorithm samples K demonstrations, randomly permutes them, and adds them sequentially to the task-instruction prompt while evaluating performance against a zero-shot baseline.The same development set is used for successive evaluations.Source: 2) A Unified Framework · p. 4
  • A newly added demonstration’s Shapley value is updated when its performance change exceeds a threshold, and sampling stops at the iteration limit or a Gelman-Rubin convergence check.The algorithm outputs a Shapley-score table for the candidate demonstrations.Source: 2) A Unified Framework · pp. 4–5
  • The framework’s estimator is described as efficient and stable, quantifying demonstration contributions under ICL constraints for selection.The paper provides the complete algorithm pseudocode.Source: 2) A Unified Framework · pp. 4–5

IV. EXPERIMENTS & APPLICATIONS

The experiments evaluate DemoShapley and Beta-DemoShapley across predictive performance, label-noise detection, OOD generalization, and fairness.

IV. EXPERIMENTS & APPLICATIONS

  • The evaluation covers predictive performance and detection of label noise in demonstrations.These are two of the four experiment sets described.Source: §IV · p. 5
  • A separate experiment set tests generalization on out-of-distribution tasks.Source: §IV · p. 5
  • The fourth experiment set analyzes LLM fairness.Source: §IV · p. 5

A. Experimental Settings

The experiments use four LLMs and six datasets across prediction, OOD generalization, label-noise robustness, and fairness settings, comparing the methods with four selection baselines.

A. Experimental Settings

  • The evaluation uses ChatGPT-3.5-Turbo, GPT-J-6B, Mistral-7B-v0.3, and Llama3-8B across six datasets spanning toxicity, income, emotion, question answering, sentiment, and financial text.Source: A. Experimental Settings · p. 5
  • Prediction efficacy uses Adult, Toxi-text-3M, and Emotion; OOD evaluation uses BoolQ, BoolQ Contrast, SST-2, and FinancialPhraseBank, while noisy Adult and Toxi-text-3M variants flip 10% of labels.Source: A. Experimental Settings · p. 5
  • Fairness is evaluated on Adult; DemoShapley uses α = β = 1, Beta-DemoShapley uses α = 4 and β = 1, and experiments generally use temperature 0 with three repetitions.Mean scores are reported to reduce variance.Source: A. Experimental Settings · p. 5
  • The methods are compared with CondAcc, Influence, Leave-One-Out, and Random selection.CondAcc and Influence are identified as state-of-the-art influence-based strategies.Source: A. Experimental Settings · p. 5

B. The Prediction Efficacy of DemoShapley

Across the reported settings, high-valued demonstrations generally improve ICL performance and low-valued ones are often detrimental, while removing them has opposite effects. Beta-DemoShapley performs slightly better with smaller prompts.

B. The Prediction Efficacy of DemoShapley

  • The experiments use Adult, Toxi-text-3M, and Emotion, with 100 candidate demonstrations sampled per dataset and evaluation on the corresponding test sets.Accuracy is used for binary tasks and macro-F1 for Emotion.Source: B. The Prediction Efficacy of… · p. 5
  • Starting from zero-shot prompts, the study incrementally adds demonstrations with the highest or lowest values, and removes the five highest- or lowest-valued examples from 10-example prompts.Source: B. The Prediction Efficacy of… · pp. 5–6
  • High DemoShapley-value demonstrations generally improve performance, while adding low-value demonstrations often lowers it; too many high-value examples can also hurt.The reported pattern holds across model architectures, and Beta-DemoShapley performs slightly better when prompts contain fewer demonstrations.Source: B. The Prediction Efficacy of… · p. 6
  • Removing the top five highest-valued demonstrations from a 10-example set causes the sharpest performance drop, whereas removing low- or negative-valued examples improves performance.Source: B. The Prediction Efficacy of… · p. 6

C. DemoShapley for OOD Generalization

The section reports that DemoShapley methods outperform baselines on OOD tasks, with Beta-DemoShapley performing better with fewer demonstrations. It also examines label-noise detection, finding stronger sensitivity on toxic classification than on Adult and differences across model sizes.

C. DemoShapley for OOD Generalization

  • DemoShapley methods outperform baselines on OOD tasks, and Beta-DemoShapley performs better with fewer demonstrations, especially on FinancialPhraseBank-v1.0.Table II reports accuracy on BoolQ Contrast and FinancialPhraseBank-v1.0, with zero-shot baselines shown in parentheses.Source: C. DemoShapley for OOD Generalization · p. 6, Table II · p. 6

D. DemoShapley Robust to Label Noise

  • On Adult and the English subset of Toxi-text-3M, the study uses 100 randomly sampled demonstrations per dataset, flips 10% of labels, and evaluates detection by counting flipped labels among the bottom-10 and bottom-20 examples ranked by estimated value.Source: D. DemoShapley Robust to Label Noise · p. 6
  • On toxic classification, DemoShapley methods detect label-flipped samples more sensitively than other approaches across ChatGPT-3.5-Turbo and GPT-J-6B; performance is less robust on Adult.The authors attribute this contrast to flipped labels contradicting pretrained semantics in toxic classification but not in Adult; LOO shows a similar trend, while CondAcc and Influence perform better on Adult.Source: D. DemoShapley Robust to Label Noise · pp. 6–7
  • Across Llama3 and Mistral datasets, Table I reports that DemoShapley approaches better capture the relationship between demonstration scores and actual performance impact.The table caption describes comparisons with other benchmarks that assign scores to each datum.Source: Table I · p. 7
  • ChatGPT-3.5-Turbo has a better average rank than GPT-J-6B across datasets, which the authors interpret as larger models being more sensitive to label noise [46].Lower average-rank scores indicate a stronger negative impact of flipped-label examples in ICL.Source: D. DemoShapley Robust to Label Noise · p. 7

E. Evaluation for Algorithmic Fairness

The section evaluates how demonstration-set composition relates to fairness in ICL, measuring bias and accuracy as candidate demonstrations vary in base-rate parity. DemoShapley methods show lower bias while maintaining high accuracy in the reported settings.

E. Evaluation for Algorithmic Fairness

  • The section frames fairness in ICL as reducing systematic prediction differences across sensitive groups, noting that biased demonstrations can propagate or amplify disparities.The experiments focus on income prediction in Adult, using gender as the sensitive attribute.Source: E. Evaluation for Algorithmic Fairness · pp. 7–8
  • Demographic parity difference measures positive-prediction probabilities conditioned on sensitive attribute A, while equalized odds difference also accounts for ground-truth labels.The section identifies as a drawback that demographic parity difference does not consider ground-truth labels; equalized odds includes true- and false-positive differences.Source: E. Evaluation for Algorithmic Fairness · p. 8
  • The evaluation fixes test-set base rate parity at BPT = 0.0, varies candidate demonstrations' BPC across 0, 0.5, and 1, and reports bias and accuracy in 16- and 32-shot settings.Accuracy is reported to capture the trade-off between bias and predictive performance.Source: E. Evaluation for Algorithmic Fairness · p. 8
  • With context and test datasets at BPT = 0, DemoShapley and Beta-DemoShapley achieve the highest accuracy with minimal bias, and their selected samples retain lower bias and high accuracy as BPC increases.Bias generally rises across methods as BPC increases.Source: E. Evaluation for Algorithmic Fairness · p. 8

F. Discussion

The discussion reports benefits across prediction, OOD transfer, label-noise identification, and fairness. The conclusion presents DemoShapley and Beta-DemoShapley as variable-size valuation methods, with Beta-DemoShapley weighting smaller subsets more heavily.

F. Discussion

  • Experiments associated high-valued demonstrations with performance gains and report improved OOD transfer, identification of mislabeled examples, and reduced demographic disparities while maintaining accuracy.Beta-DemoShapley proved especially effective in low-shot OOD settings.Source: F. Discussion · p. 8
  • Operating entirely at inference time keeps the framework applicable to closed-source models where fine-tuning is not feasible.The discussion also describes the methods as practical and reliable tools for real-world applications.Source: F. Discussion · p. 8

V. CONCLUSION

  • DemoShapley measures marginal impact across prompt sizes from zero-shot, while Beta-DemoShapley weights smaller cardinalities to reflect prompt-length and computational constraints.This dynamic valuation differs from influence methods that use a fixed number of demonstrations.Source: §V · p. 8
  • The conclusion characterizes the methods as an efficient demonstration-selection solution that consistently improves performance.Source: §V · p. 9
Loading 2410.07523v3…