In demonstration ensembling (DENSE), how are demonstrations split into buckets, and how are the buckets' predictions combined?
answer
- partition instead of concatenate
- one call per bucket
- probabilities, not just labels
- product, mixture, max
- cosine similarity sets the weight
basics
~20 sDENSE partitions the demonstrations into non-empty buckets, runs one prompt per bucket on the same input, and merges each bucket's label probabilities with a product, a mixture or a maximum, optionally weighting buckets by similarity to the input.
solid answer
~50 sConcatenating every demonstration gives little control over each one's contribution and can exhaust the context window. DENSE (Khalifa et al., 2023) instead allocates n demonstrations to b non-empty buckets, either in list order or through k-means clustering, and conditions the model on each bucket plus the test input. Each bucket yields a probability per label. Three operators merge them: product of experts, mixture of experts, and max, which takes the highest weighted probability across buckets. Buckets can be weighted by the average cosine similarity of their demonstrations to the input. On one 6-billion-parameter model across 12 tasks, weighted max beat concatenation by 2.4 average points at six shots and similarity-sorted concatenation by 1.2. Unweighted ensembling lost to the sorted baseline, and no clustering strategy clearly won. Each bucket is a call, so this is a modest gain for b calls.
code
plaintext · 12 linesWeights: w = 0.4, 0.3, 0.3
P(billing | b_i): 0.70, 0.70, 0.05
P(refund | b_i): 0.30, 0.30, 0.95
Mixture billing = 0.28 + 0.21 + 0.015 = 0.505 <- selected
refund = 0.12 + 0.09 + 0.285 = 0.495
Max billing = max(0.28, 0.21, 0.015) = 0.280
refund = max(0.12, 0.09, 0.285) = 0.285 <- selected
Product billing = 0.70^0.4 x 0.70^0.3 x 0.05^0.3 = 0.317
refund = 0.30^0.4 x 0.30^0.3 x 0.95^0.3 = 0.424 <- selectedgo deeper
Recall that the demonstrations are split into groups, each group gets its own call on the same input, and the results are merged. Concatenation is the single-group case.
Explain the three operators on real numbers and show how one confident bucket can flip the result. Say what a bucket's similarity weight is computed from and why it changes per input.
Argue from the baseline: sorted concatenation captures part of the gain at one call. Check that the endpoint exposes probabilities before planning around these operators, and scope the figures to one older model.
Ask whether a small published gain justifies b calls on your traffic. The paper's motivation includes long-input tasks that cannot fit many examples, so a context limit may be a stronger reason than accuracy.
## Why split demonstrations at all A **demonstration** is an input-output pair shown to the model before the real input. The standard approach **concatenates** them all ahead of the test input. Khalifa et al. (2023) name three drawbacks: almost no control over what each demonstration contributes, a long list can use up the context window, and a long chain can worsen sensitivity to demonstration order. **Demonstration ensembling (DENSE)** replaces the one long prompt with several shorter ones. A **bucket** is a non-empty subset of the demonstrations. With one bucket, DENSE is simply concatenation. ## How buckets are formed The paper studies three allocations, and each places a demonstration in one bucket: - **Arbitrary.** Cut the list in order, so each bucket takes the next group of demonstrations. - **Similar-together.** Run k-means over demonstration embeddings and use each cluster as a bucket. Bucket sizes can then differ. - **Diverse.** Build clusters of exactly b demonstrations, then form b buckets by taking one unique demonstration from each cluster. The paper adds that clustering makes assignment less sensitive to the original list order, which matters because order is a known source of variance in few-shot prompts. A partition also keeps the prompts disjoint. Methods that draw demonstrations at random for each prompt, which Pitis et al. (2023) call bagged prompts, can reuse an example unless you forbid it. ## How predictions are combined Each bucket, together with the test input, gives a probability for every candidate label. Each bucket also carries a normalized weight. | Operator | For label y | What it favours | |---|---|---| | Product of experts | product of each bucket's probability raised to its weight | Labels no bucket rules out | | Mixture of experts | sum of weight times probability | Labels with broad support | | Max | highest weight times probability across buckets | The single most confident weighted bucket | **Weights** are either uniform or similarity-based. In the second case a bucket's weight is the average cosine similarity between its demonstrations' embeddings and the test input's embedding, so it changes per input. ## A worked case Take the eight-label ticket classifier with six demonstrations in three buckets of two. For one ticket, the scenario's probabilities concentrate on `billing` and `refund`, and the weights are 0.4, 0.3 and 0.3. The worked example below shows that the mixture selects `billing` (0.505 against 0.495), while max and product both select `refund`. The operator is a real design choice. One very confident bucket decides the result under max and can pull the product with it, while the mixture dilutes it. In this paper's experiments max performed best overall, but that is one result on one model. ## What the paper measured These results come from one 6-billion-parameter open model, 12 tasks, three seeds of demonstrations and 6 or 10 shots. - **Unweighted ensembling** beat arbitrary concatenation, by 0.8 average points with max at 6 shots and 0.6 with mixture at 10 shots. It lost to similarity-sorted concatenation. - **Similarity weights** helped in every case. Weighted max beat concatenation by 2.4 and sorted concatenation by 1.2 at 6 shots, and by 1.9 and 0.75 at 10 shots. - **Bucket count.** A small count seemed to do worse across the board, and at 6 shots performance rose with the count. - **Clustering.** The authors report no conclusive winner. Diverse always beat similar-together at 10 shots, but not at 6. This is one workshop study on one model from before 2023. A later model may behave differently. ## In production 1. **Check that you can get probabilities.** All three operators need a probability per label. An endpoint that returns only text leaves you counting votes, which is a different combine step, so the paper's figures do not carry over. 2. **Count the calls honestly.** Three buckets means three calls. Each prompt is shorter, so input tokens grow by less than the call count. If six demonstrations take 100 tokens each and the instruction and ticket take 100, one long prompt is 700 input tokens. Three buckets of two are 300 each, or 900 in total (scenario's figures). 3. **Watch for hidden labels.** A two-demonstration bucket cannot show eight labels, so common practice keeps the full label list in the instruction. 4. **Compare against the right baseline.** Sorted concatenation uses the same similarity signal for one call, and it already captured part of the gain.
- Why compare demonstration ensembling with similarity-sorted concatenation rather than plain concatenation?Sorted concatenation uses the same similarity signal for one call. In Khalifa et al. (2023), weighted max's margin shrank from 2.4 points against plain concatenation to 1.2 against sorted at six shots, and unweighted ensembling lost to the sorted baseline. The fair question is what the extra calls buy beyond sorting.
- What changes if your endpoint returns only a label and no probabilities?The product, mixture and max operators are defined on probabilities, so they no longer apply. You can count labels, optionally weighted by bucket similarity. That is a different combine step from the ones the paper measured, so its figures do not transfer, and it needs its own held-out comparison.
- Demonstration ensembling samples one prompt many times and votes on the samples.
- Max ensembling picks the label that most buckets chose.
- Similar-together clustering is the proven best way to form buckets.
- Shorter prompts mean demonstration ensembling reduces the number of model calls.
- Unweighted buckets beat every concatenation baseline in the paper.