Papers
Topics
Authors
Recent
Search
2000 character limit reached

Max–Min Similarity Prompt Sampling

Updated 4 July 2026
  • The paper’s main contribution is introducing a dual objective in prompt sampling that maximizes query similarity while ensuring diversity among selected examples.
  • It details various algorithmic implementations—including diversity, similarity, hybrid, and graph-based methods—to effectively balance representativeness and non-redundancy.
  • Empirical evaluations demonstrate that strategies balancing similarity with diversity yield higher accuracy in few-shot in-context learning compared to random sampling.

Searching arXiv for papers related to max–min similarity prompt sampling and its adjacent formulations. Max–Min Similarity Prompt Sampling is a prompt construction and selection paradigm in which similarity and diversity are jointly managed when forming prompts or prompt sets for LLMs. In the most direct few-shot formulation, it can be understood as a query-aware extension of In-Context Sampling (ICS): rather than using a single in-context learning prompt, one constructs multiple prompts for the same query, seeks examples that are similar to the query, avoids over-concentrating highly similar examples within the same prompt, and aggregates predictions across prompts by majority vote (Yao et al., 2023). Across adjacent literatures, the same design intuition appears under several technical forms: rank-based diversity and hybrid sampling in ICS (Yao et al., 2023), worst-group or reweighted active sampling under min-max objectives (Abernethy et al., 2020), bilevel similarity minimization and maximization (Luo et al., 2023), graph-based prompt selection via Maximum Independent Set on similarity graphs (Kjorvezir et al., 31 May 2026), metric-fair joint prompting of similar items (Wang et al., 8 Dec 2025), discriminative min–max similarity/dissimilarity assignment (Kostadinov et al., 2019), and distribution-level textual regularization over prompt sets (Cui et al., 20 Feb 2025).

1. Conceptual definition and problem setting

In standard In-Context Learning (ICL), a single prompt is formed as

{I+(xicl1,yicl1)++(xicl,yicl)+x},\{I + (x^{\text{icl}_1}, y^{\text{icl}_1}) + \dots + (x^{\text{icl}_\ell}, y^{\text{icl}_\ell}) + x\},

where II is a natural language task instruction, (xicli,yicli)(x^{\text{icl}_i}, y^{\text{icl}_i}) are labeled in-context examples, and xx is the query instance (Yao et al., 2023). In-Context Sampling generalizes this by sampling a candidate pool C={(xi,yi)}i=1nC = \{(x_i, y_i)\}_{i=1}^n, constructing kk distinct prompts for the same query from subsets SjCS_j \subset C of size \ell, querying the model once per prompt, and aggregating predictions using majority vote: y^final=mode(y^1,,y^k).\hat{y}_{\text{final}} = \operatorname{mode}(\hat{y}_1, \dots, \hat{y}_k). This committee-based design treats prompts as committee members and uses voting to increase reliability and confidence (Yao et al., 2023).

Within that setting, a Max–Min Similarity Prompt Sampling view introduces two simultaneous desiderata. First, selected demonstrations should be similar to the query or representative of the data distribution. Second, selected demonstrations should not collapse into a narrow cluster. The data block states this explicitly as the desire to “maximize similarity between query xx and selected in-context examples” and to “maximize diversity among selected examples (or equivalently, maximize the minimum pairwise distance/similarity margin)” (Yao et al., 2023). The same two-term structure also appears in graph-based benchmark reduction, where the goal is to select prompts that are “maximally non-redundant / diverse” while preserving ranking behavior (Kjorvezir et al., 31 May 2026).

A plausible implication is that “Max–Min Similarity Prompt Sampling” is less a single algorithm than a family of prompt-selection procedures in which one term enforces relevance or representativeness and the other enforces separation, coverage, or robustness. The data block repeatedly frames this trade-off as central rather than incidental (Yao et al., 2023, Kjorvezir et al., 31 May 2026).

2. In-Context Sampling as the immediate prompting formulation

The clearest prompting instantiation comes from ICS. For a fixed query II0, ICS samples a candidate pool, constructs multiple prompts with II1 demonstrations in the paper, obtains II2 predictions, and returns the majority label (Yao et al., 2023). The paper evaluates three data similarity-based strategies for the candidate-sampling stage and, optionally, the prompt-construction stage: Diversity, Similarity, and Hybrid (Yao et al., 2023).

Similarity is computed in embedding space with a sentence-transformer encoder (Sentence-BERT; Reimers & Gurevych, 2019) using cosine similarity: II3 For each datum II4 in a pool II5, average similarity to the dataset is defined as

II6

This is described as similarity to the mean embedding of the dataset (Yao et al., 2023).

The Diversity strategy computes these scores, sorts them in descending order, sets II7, and selects evenly spaced points along the ranking: II8 The paper states that this approximates sampling across the whole similarity spectrum and gives a “Conceptual connection to max–min diversity,” while noting that it is not an explicit solution of

II9

Instead, it is described as a cheap heuristic to increase pairwise diversity by spreading selected points out in embedding space (Yao et al., 2023).

The Similarity strategy takes the top (xicli,yicli)(x^{\text{icl}_i}, y^{\text{icl}_i})0 points with highest average similarity to the dataset mean: (xicli,yicli)(x^{\text{icl}_i}, y^{\text{icl}_i})1 The paper says this is closer to a max-mean similarity objective than to max–min, but that it can be combined with diversity-based selection (Yao et al., 2023). The Hybrid strategy selects (xicli,yicli)(x^{\text{icl}_i}, y^{\text{icl}_i})2 points via Diversity, removes them from the ranked list, then selects (xicli,yicli)(x^{\text{icl}_i}, y^{\text{icl}_i})3 highest-ranked remaining examples, yielding

(xicli,yicli)(x^{\text{icl}_i}, y^{\text{icl}_i})4

This is said to “implicitly balance” high similarity to the dataset mean and spread across the embedding spectrum (Yao et al., 2023).

These strategies are global rather than query-specific. The data block therefore proposes a query-aware extension by replacing the global score (xicli,yicli)(x^{\text{icl}_i}, y^{\text{icl}_i})5 with

(xicli,yicli)(x^{\text{icl}_i}, y^{\text{icl}_i})6

This suggests a direct Max–Min Similarity Prompt Sampling formulation in which examples are first filtered or ranked by query similarity and then diversified within the prompt (Yao et al., 2023).

3. Similarity, diversity, and explicit max–min formulations

The data block distinguishes carefully between heuristic diversity and explicit max–min optimization. For query relevance, one can rank examples by (xicli,yicli)(x^{\text{icl}_i}, y^{\text{icl}_i})7. For diversity, the stated explicit objective is

(xicli,yicli)(x^{\text{icl}_i}, y^{\text{icl}_i})8

where (xicli,yicli)(x^{\text{icl}_i}, y^{\text{icl}_i})9 can be cosine distance xx0 (Yao et al., 2023). A common greedy max–min algorithm is then described: pick an initial point, for example the most similar to the query, and iteratively add the point that maximizes its minimum distance to the already selected set,

xx1

The paper does not implement this explicit formula, but states that its Diversity and Hybrid strategies are cheap approximations to the same intuition and that “too much similarity inside the same prompt is harmful” (Yao et al., 2023).

This trade-off is also visible in the paper’s guidance for a two-level design. First, candidate pool selection should find globally representative examples or examples similar to the query. Second, prompt construction should ensure that all chosen examples are reasonably similar to the query while maximizing pairwise distance among them (Yao et al., 2023). The data block gives a concrete greedy scheme: filter examples by a similarity threshold xx2, pick the most query-similar example first, then repeatedly select the point that maximizes the minimum cosine distance to the current prompt set (Yao et al., 2023).

A related but not identical structure appears in “Similarity Min-Max: Zero-Shot Day-Night Domain Adaptation,” where a transformation xx3 minimizes feature similarity while a feature extractor xx4 maximizes it: xx5 There, cosine similarity is minimized at the transformation stage and maximized via BYOL-style loss at the model stage (Luo et al., 2023). This is not prompt sampling, but it provides a concrete “similarity min–max” paradigm with a min step that enlarges a gap and a max step that learns invariance to that gap (Luo et al., 2023). A plausible implication is that prompt-level variants can separate a hard-example generation stage from a robustness-alignment stage, rather than solving both within a single combinatorial sampler.

4. Algorithmic realizations across prompt selection and grouping

Several distinct algorithmic realizations of max–min-style prompt selection are represented in the data block.

The first is ICS-style few-shot prompt construction. The paper evaluates candidate pool sizes xx6, numbers of prompts xx7, and fixed xx8 examples per prompt (Yao et al., 2023). For a given query, the implementation samples a candidate set using Random, Diversity, Similarity, or Hybrid; for each of xx9 prompts it samples 3 demonstrations from the remaining pool; and used demonstrations are removed so prompts are disjoint in that implementation (Yao et al., 2023).

The second is graph-based prompt selection for benchmark reduction. “Consistent and Distinctive: LLM Benchmark Efficiency via Maximum Independent Set Prompt Selection on Similarity Graphs” models a benchmark as a similarity graph and selects a subset via Maximum Independent Set (MIS) (Kjorvezir et al., 31 May 2026). Each prompt C={(xi,yi)}i=1nC = \{(x_i, y_i)\}_{i=1}^n0 is embedded as C={(xi,yi)}i=1nC = \{(x_i, y_i)\}_{i=1}^n1; distances considered are cosine distance, Pearson correlation distance, and standardized Euclidean distance on L2-normalized embeddings (Kjorvezir et al., 31 May 2026). The graph is built from percentile thresholds C={(xi,yi)}i=1nC = \{(x_i, y_i)\}_{i=1}^n2 derived from 10,000 random prompt pairs (Kjorvezir et al., 31 May 2026). The paper notes a wording mismatch in one description of edge construction, but states that conceptually, for max-min diversity, edges should encode prompt conflict under similarity, so that an independent set forbids selecting two prompts that are too similar (Kjorvezir et al., 31 May 2026). In that conceptualization, MIS becomes a hard-threshold max–min sampler: enforce a minimum separation and maximize the number of selected prompts.

The third is metric-fair grouping of similar items. “Metric-Fair Prompting: Treating Similar Samples Similarly” embeds question stems with the Qwen3-4B embedding model, computes cosine similarity, and pairs each question with its nearest neighbor, then solves both jointly under instructions that impose a “Lipschitz-like constraint” so that similar inputs yield similar scores (Wang et al., 8 Dec 2025). The prompt instructs the model to think in terms of a margin-based classifier C={(xi,yi)}i=1nC = \{(x_i, y_i)\}_{i=1}^n3, with prediction C={(xi,yi)}i=1nC = \{(x_i, y_i)\}_{i=1}^n4, and to prefer cross-item consistency unless a clear clinical conflict exists (Wang et al., 8 Dec 2025). This is a max-similarity grouping strategy rather than a max–min diversity strategy, but the same paper explicitly suggests future directions such as “cluster-then-cover” and “active pairing,” which the data block interprets as natural contexts for max–min sampling (Wang et al., 8 Dec 2025).

The fourth is assignment by discriminative min–max score in a learned transform space. “Clustering with Jointly Learned Nonlinear Transforms Over Discriminating Min-Max Similarity/Dissimilarity Assignment” defines a parametric discriminative prior

C={(xi,yi)}i=1nC = \{(x_i, y_i)\}_{i=1}^n5

where C={(xi,yi)}i=1nC = \{(x_i, y_i)\}_{i=1}^n6 is a sign-aware similarity score and C={(xi,yi)}i=1nC = \{(x_i, y_i)\}_{i=1}^n7 is a support-intersection energy (Kostadinov et al., 2019). Although this work addresses clustering rather than prompting, it provides a fully explicit min–max similarity/dissimilarity assignment rule. The data block then interprets this as transferable to prompt selection by comparing prompt-conditioned embeddings against good and bad prototypes and choosing the prompt with minimum discriminative score (Kostadinov et al., 2019).

5. Empirical behavior and operating regimes

The central empirical claim from ICS is that multiple prompts plus voting outperform single-prompt ICL, and that similarity-based candidate sampling improves over fully random ICS (Yao et al., 2023). On Mistral-7B with C={(xi,yi)}i=1nC = \{(x_i, y_i)\}_{i=1}^n8 and C={(xi,yi)}i=1nC = \{(x_i, y_i)\}_{i=1}^n9, the baseline single-prompt ICL accuracy is reported as 64.74 on e-SNLI, 56.90 on Multi-NLI, 40.42 on ANLI, and 78.83 on Contract-NLI (Yao et al., 2023). Random ICS increases these to 72.57, 61.17, 42.22, and 86.69, respectively (Yao et al., 2023). Best similarity-based ICS configurations are reported as approximately 74.0–74.1 on e-SNLI for Similarity/Random or Hybrid/Random, approximately 62.41 on Multi-NLI for Hybrid/Random, about 42.6 on ANLI for Diversity-based or Hybrid-based strategies, and approximately 90.48 on Contract-NLI for Similarity/Random (Yao et al., 2023). The stated pattern is that any non-random similarity-based strategy in at least one ICS step beats fully random ICS, and that candidate-sampling strategy matters more than per-prompt sampling strategy (Yao et al., 2023).

The same paper also reports clear operating heuristics. Increasing kk0 beyond 100 gives diminishing returns, accuracy gains plateau, increasing kk1 from 3 to 10 helps, and 10 to 20 yields marginal improvements with extra cost; thus a moderate candidate set kk2 and moderate number of prompts kk3 form a good balance (Yao et al., 2023). The paper caps generation to 10 tokens and does not deeply analyze context length (Yao et al., 2023).

The graph-based MIS work reports a different but complementary operating regime. Across 2563 completed configurations, mean Spearman kk4 is approximately 0.967–0.968 depending on algorithm, about 84% of configurations have kk5, and stochastic solvers yield mean Kendall’s kk6, with kk7 in 99.2% of configurations (Kjorvezir et al., 31 May 2026). Threshold percentile controls the trade-off. At kk8, mean kk9, mean SjCS_j \subset C0, mean subset size is about 70 prompts, and reduction is 88–93%; at SjCS_j \subset C1, mean SjCS_j \subset C2, mean SjCS_j \subset C3, mean subset size is about 429 prompts, and reduction is 37–45%; at SjCS_j \subset C4, mean SjCS_j \subset C5, mean SjCS_j \subset C6, mean subset size is about 593 prompts, and reduction is 17–23% (Kjorvezir et al., 31 May 2026). The primary failure mode is overly dense graphs at low thresholds, especially on GPQA and IFEval, leading to tiny independent sets and poorer representativeness (Kjorvezir et al., 31 May 2026).

Metric-Fair Prompting reports a different kind of gain: on MedQA with Qwen3-14B, single-item prompting achieves 68.0 accuracy and the metric-fair two-item prompt achieves 84.0 (Wang et al., 8 Dec 2025). The paper evaluates fairness qualitatively rather than via an explicit fairness metric and notes that performance is “not completely understood from a rigorous theoretical perspective” and that results are “not always stable” (Wang et al., 8 Dec 2025).

6. Theoretical lenses: robustness, fairness, and representative coverage

One theoretical lens comes from min-max fairness. “Active Sampling for Min-Max Fairness” studies

SjCS_j \subset C7

where SjCS_j \subset C8 is group-wise expected loss (Abernethy et al., 2020). The paper’s key algorithmic idea is to identify the worst-off group under the current model and sample from that group for the next update, or to maintain a reweighting distribution

SjCS_j \subset C9

The data block explicitly maps this to prompts by replacing demographic groups with prompt groups or prompt clusters, maintaining per-group validation buffers, and sampling from the worst-performing prompt group (Abernethy et al., 2020). This suggests a min-max prompt sampler that does not optimize geometric diversity directly, but instead minimizes the maximum loss across prompt regions.

A second lens is metric fairness. Metric-Fair Prompting adopts the Lipschitz-style condition

\ell0

typically \ell1, so that similar instances receive similar scores (Wang et al., 8 Dec 2025). In prompting, this is implemented softly by pairing similar items and instructing the model to reason jointly, extract decisive features, and maintain cross-item consistency (Wang et al., 8 Dec 2025). This suggests a local max-similarity principle: within a prompt, similarity is deliberately high so that consistency constraints become salient.

A third lens is robust alignment under worst-case perturbation. SPTR uses optimal transport between the set of hand-crafted textual features and tuned textual features, plus a similarity paradigm

\ell2

where \ell3 comes from PGD adversarial perturbation and \ell4 is the average of multiple hand-crafted prompts (Cui et al., 20 Feb 2025). The data block interprets OT as a distribution-level regularizer that discourages collapse toward a single prompt and implicitly encourages the tuned prompt to stay close to the whole hand-crafted prompt distribution (Cui et al., 20 Feb 2025). A plausible implication is that prompt selection can be formulated not only over pairwise distances but also over similarity distributions and their worst-case deviations.

7. Limitations, misconceptions, and open directions

A common misconception is that maximizing similarity everywhere should improve few-shot prompting. The ICS data directly contradict this: using Similarity strategy to make the three demonstrations inside a prompt very similar to each other can hurt performance compared with a random mix, and the beneficial effect of similarity-based methods is strongest at the candidate-sampling step rather than naive within-prompt concentration (Yao et al., 2023). The data block therefore presents “balancing similarity and diversity, not simply maximizing similarity” as the key lesson (Yao et al., 2023).

Another misconception is that max–min prompt selection must take the form of an explicit combinatorial solver. The sources show several alternatives. Even spacing across a similarity ranking can approximate diversity without solving a max–min optimization (Yao et al., 2023). Worst-group active sampling optimizes a min-max objective over prompt groups rather than pairwise distances (Abernethy et al., 2020). Joint prompting of nearest neighbors prioritizes similarity and consistency rather than coverage (Wang et al., 8 Dec 2025). Conversely, MIS on a similarity graph imposes a hard threshold and maximizes subset size under the independence constraint, which is a packing-style rather than continuous max–min objective (Kjorvezir et al., 31 May 2026).

The limitations recurring across the sources are computational cost, embedding dependence, and instability of overly aggressive adversarial or similarity-only designs. ICS requires \ell5 forward passes per query rather than one, and similarity computation over large pools can be expensive without precomputation (Yao et al., 2023). Its results also depend on the quality and domain alignment of the fixed sentence-transformer embeddings (Yao et al., 2023). MIS selection depends critically on embedding quality and threshold choice; low thresholds produce overly dense graphs and poor representativeness (Kjorvezir et al., 31 May 2026). Metric-Fair Prompting depends on the quality of the embedding-based clinical similarity metric and only evaluates MedQA (Wang et al., 8 Dec 2025). SPTR incurs extra compute from adversarial training and depends on a bank of hand-crafted prompts (Cui et al., 20 Feb 2025). The clustering-based min–max assignment method requires jointly learned transform spaces and alternating optimization (Kostadinov et al., 2019).

The most direct future directions are stated repeatedly in the data block: query-conditioned explicit max–min sampling algorithms, better domain-aligned embeddings, adaptive number of examples per prompt and adaptive \ell6, integration of model uncertainty or confidence, cluster-then-cover and active pairing, weighted or multi-objective MIS, and prompt-group reweighting or sampling policies that directly target worst-case performance (Yao et al., 2023, Abernethy et al., 2020, Wang et al., 8 Dec 2025, Kjorvezir et al., 31 May 2026). Taken together, these sources suggest that Max–Min Similarity Prompt Sampling is best understood as a general design principle: select prompts or demonstrations so that they are sufficiently relevant, sufficiently non-redundant, and sufficiently robust under the particular downstream objective being optimized.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Max-Min Similarity Prompt Sampling.