---
title: Many-Shot Prompting
url: https://www.emergentmind.com/topics/many-shot-prompting
type: topic
---

# Many-Shot Prompting

Many-shot prompting is an in-context learning regime in which the amount of supervision injected at inference is scaled beyond conventional few-shot prompting. In the literature, the term covers several related mechanisms: packing many demonstrations into one long prompt, composing many smaller prompts and aggregating their outputs, retrieving large external demonstration sets that do not fit in context, using earlier generated outputs inside a batch as demonstrations for later items, and issuing many prompt-derived queries whose votes are denoised downstream. Across these formulations, many-shot prompting is treated as a form of test-time adaptation in which model parameters remain fixed and the update occurs entirely through the input context. Recent work shows that this input-space update can produce substantial gains on structured classification, extraction, and reasoning tasks, but it is highly sensitive to selection policy, ordering, redundancy, and task type, and it can fail or even become harmful in open-ended or semantically stringent settings such as code translation [2311.09782][2603.05829][2510.16809].

## 1. Conceptual scope and relation to in-context learning

The canonical formulation of many-shot prompting extends the usual in-context learning template from a small prompt of the form \(\{I + (x_1,y_1)+\dots+(x_k,y_k)+x\}\) to substantially larger demonstration sets. One line of work asks whether the additional examples should be packed into one increasingly long prompt or distributed across multiple prompts whose predictions are later aggregated. In this framing, many-shot prompting is not merely “more examples,” but a design problem over context allocation, diversity, and aggregation under a finite context window [2311.09782].

A second line of work formulates many-shot prompting as test-time adaptation. Given a query \(x\) and demonstrations \(D=\{(x_i,y_i)\}_{i=1}^k\), the model induces \(p(y \mid x, D)\), and the strength of the update is controlled by the number of demonstrations, their token length, their ordering, and their selection policy. This perspective makes many-shot prompting an input-space test-time update, distinct from parameter updates such as fine-tuning or LoRA [2603.05829].

Other papers broaden the term beyond a single demonstration block. In weak supervision, many-shot prompting denotes multiple distinct prompts per unlabeled example, each acting as a labeling function whose outputs are mapped to labels or abstentions and then denoised with a Snorkel-style label model [2205.02318]. In batch prompting, Auto-Demo Prompting turns earlier generated question–answer pairs within the same batch into demonstrations for later items, thereby creating an autoregressive many-shot effect without manually inserting all demonstrations into the input [2410.01724]. In security analysis, Many-Shot Regurgitation prompting uses multiple faux “user–assistant” rounds inside one prompt to drive verbatim continuation and probe memorization [2405.08134].

This conceptual breadth implies that many-shot prompting is best understood as a family of long-context conditioning strategies rather than a single method. A plausible implication is that the central research question is not how to maximize shot count in the abstract, but how to maximize information gain per token under architectural, computational, and reliability constraints.

## 2. Operational forms and core mechanisms

Recent work has produced several operationally distinct variants of many-shot prompting.

| Form | Core mechanism | Representative source |
|---|---|---|
| Single long-prompt ICL | Many demonstrations inside one prompt | [2311.09782] |
| Prompt composition / ICS | Many small prompts with vote aggregation | [2311.09782] |
| Beyond-context retrieval | External anchor datastore with nearest-neighbor inference | [2303.13824] |
| Batch autoregressive demonstrations | Earlier generated Q–A pairs condition later items | [2410.01724] |
| Prompt ensemble weak supervision | Many prompts per example, denoised by a label model | [2205.02318] |
| Faux conversational continuation | Alternating user/assistant segments to elicit regurgitation | [2405.08134] |

In In-Context Sampling (ICS), many-shot prompting is realized through prompt composition rather than a single many-shot input. A small number of shots per prompt is fixed—\(k=3\) in the paper for NLI and QA—while the number of prompts per query varies as \(M \in \{3,5,10,20\}\). For each query, the method constructs \(M\) distinct prompts from a candidate pool and aggregates their predictions by majority vote,
\[
\hat{y} = \arg\max_y \sum_{m=1}^{M} \mathbf{1}[y_m = y].
\]
The paper studies candidate pool sizes \(n \in \{50,100,250,500\}\) and reports best overall performance at \(n=100\) and \(M=10\) [2311.09782].

In \(k\)NN Prompting, the many-shot component is moved largely out of the prompt. A small demonstration set remains in context, but a large anchor set is stored externally as LLM-derived representations. For each anchor \(x_i^a\), the method caches the full next-token probability distribution
\[
k_i = f_\theta(x_i^a) = p_\theta(v \mid P(x_i^a)) \in \mathbb{R}^{|V|},
\]
and for a test input retrieves nearest neighbors by minimizing
\[
D_{KL}(p_{\text{test}} \,\|\, k_i) = \sum_{v \in V} p_{\text{test}}(v)\log\frac{p_{\text{test}}(v)}{k_i(v)}.
\]
Prediction is then performed by unweighted majority vote over neighbor labels, with \(k=3\) in the experiments. This design is explicitly “Beyond-Context,” because the anchor set can scale independently of prompt length [2303.13824].

Auto-Demo Prompting uses a different mechanism. Let a batch be \(B=\{(q_i,y_i)\}_{i=1}^N\), and let \(D_{<t}=\{(q_i,y_i)\}_{i=1}^{t-1}\) denote earlier generated pairs. The conditional distribution for item \(t\) becomes \(p(y_t \mid q_t, D_{<t}, \theta)\). By enforcing a repeated Q–A schema, the model’s own earlier outputs become demonstrations for later items. The paper formalizes this relation as
\[
\text{Auto-Demo Prompting} \approx \text{Batch Prompting} + \text{Few-Shot Demonstrations},
\]
and treats batch data selection as approximately equivalent to demonstration selection [2410.01724].

The weak-supervision formulation is structurally different but conceptually related. Here, many-shot prompting means many distinct prompt templates per example. Each prompt output is mapped by a labeling function \(M_j\) to a class label or abstention, the label matrix \(\Lambda\) is denoised with a generative label model, and an end classifier is trained on the resulting soft labels [2205.02318]. Many-Shot Regurgitation prompting likewise uses a single long prompt, but its objective is not task accuracy; it is a black-box membership inference analysis that divides a document into segments \(T_1,\dots,T_n\), arranges them into alternating faux rounds, and asks the model to generate the final withheld segment [2405.08134].

## 3. Example selection, ordering, and aggregation

Selection policy is one of the strongest determinants of many-shot performance. In ICS, candidate selection is either random or guided by sentence-transformer embeddings. The paper defines an averaged similarity score
\[
s(x,D) = \cos(\operatorname{embed}(x), \sum_{j=1}^{|D|}\operatorname{embed}(x_j)),
\]
and uses it to implement four strategies: random sampling, similarity-based retrieval, diversity sampling by evenly spaced items across the ranked list, and a hybrid of diversity and similarity. The general pairwise cosine similarity remains
\[
s(u,v) = \frac{u \cdot v}{\|u\|\,\|v\|}.
\]
Notably, random augmentation within prompts often outperformed similarity-constrained augmentation, suggesting that placing very similar examples inside the same prompt can induce prompt interference even when similarity helps at the candidate-pool stage [2311.09782].

Test-time adaptation studies reach a closely related conclusion. On Banking77, four Dynamic ICL strategies are instantiated: Cross-label Random, Label-wise Random, Cross-label Similarity, and Label-wise Similarity. Similarity-based retrieval is strongest at small update magnitudes, but degrades with larger \(N\); cross-label random selection scales more robustly at large \(N\) because it preserves contextual diversity. Label-wise similarity remains better than label-wise random across \(n\), but still degrades with scale, falling from \(83.4\%\) accuracy at \(n=1\) to \(67.4\%\) at \(n=70\) [2603.05829].

In domain-specific software requirement classification, example selection is evaluated through random sampling, semantic embedding–based selection with SimCSE, and TF-IDF vector–based selection. The paper defines
\[
\text{tf-idf}(w,d,D)=\text{tf}(w,d)\times \log\frac{|D|}{\text{df}(w,D)}
\]
and again uses cosine similarity for retrieval. A class-stratified candidate pool is built by round-robin selection over classes, after which TF-IDF retrieval is applied per input. Across models and datasets, TF-IDF selection consistently outperforms both random sampling and semantic embedding, with one stated exception in the binary PROMISE setup for LLaMA-3.2-3B-instruct [2509.13196].

Ordering remains a separate source of instability. On Banking77, performance varied by \(2\)–\(3\%\) across \(10\) random demonstration orderings, an effect attributed to primacy, recency, and “lost in the middle” dynamics [2603.05829]. ICS did not optimize demonstration ordering beyond sampling order, yet was reported as robust regardless [2311.09782]. Auto-Demo Prompting does not prescribe a special within-batch order either, but its retrieval-based batch formation is intended to place mutually helpful items together so that early outputs serve as useful demonstrations for later outputs [2410.01724].

Aggregation policy differs by formulation. ICS uses majority vote as its default, but the same paper enumerates probability averaging, log-odds averaging for binary classification, and similarity-weighted ensembles as formal alternatives [2311.09782]. Weak-supervision many-shot prompting replaces direct output aggregation with a Snorkel-style label model,
\[
P_\theta(Y_i \mid \lambda(X_i)) \propto P_\theta(Y_i)\prod_{j=1}^{m} P_\theta(\lambda_j(X_i)\mid Y_i),
\]
which explicitly models source accuracy and abstention [2205.02318]. This diversity of aggregation rules underscores that many-shot prompting is as much an ensemble-design problem as a context-length problem.

## 4. Empirical gains and task regimes in which many-shot prompting helps

On natural language inference and QA, ICS reports consistent gains over single-prompt ICL baselines. Using FlanT5-XL, Mistral-7B, and Mixtral-8x7B on e-SNLI, Multi-NLI, ANLI, Contract-NLI, and CommonsenseQA, the method “consistently improved accuracy across all datasets and models,” with improvements for Mistral-7B and Mixtral-8x7B averaging \(>5\%\) in many settings. Gains saturate when \(n>100\), and the best overall setting is \(n=100\) and \(M=10\). In a strategy evaluation with Mistral-7B, \(n=100\), and \(M=10\), baseline ICL accuracies were e-SNLI \(64.74\), Multi-NLI \(56.90\), ANLI \(40.42\), and Contract-NLI \(78.83\); similarity sampling with random prompt augmentation reached \(74.11\), \(62.09\), \(42.60\), and \(90.48\), respectively [2311.09782].

Beyond-context many-shot prompting also produces strong scaling results in classification. \(k\)NN Prompting reports, under comparable few-shot scenarios, average improvements of \(+3.56\) points at \(m=4\) and \(+7.07\) points at \(m=8\) over the best baseline. At \(m=128\), it reports \(79.73\) versus \(62.77\) average accuracy for a \(0.8\)B model relative to standard ICL, a gain of \(+16.96\) points, and \(79.73\) versus \(63.65\) relative to ICL Ensemble, a gain of \(+16.08\) points. In full many-shot scaling from \(2\) to \(1024\) shots, absolute improvements reach \(+18.84\), and the best average performance on OPT \(30\)B reaches \(86.02\) [2303.13824].

As test-time adaptation, many-shot prompting is particularly effective on structured tasks with constrained outputs. With LLaMA-3.1-8B-Instruct, Banking77 accuracy rises steadily and then plateaus at approximately \(50\)–\(70\) shots per class, corresponding to \(N \approx 3850\)–\(5390\). Across the broader evaluation harness, ARC-Challenge accuracy rises from \(38.82\) to \(93.72\) with \(4\)-shot and then remains at \(93.48\) at \(16\)-shot and \(93.45\) at \(32\)-shot; GSM8K improves from \(87.56\) to approximately \(94.7\)–\(94.8\) with \(4\)–\(32\) shots; FDA moves from \(39.65\) to \(86.8\), \(89.4\), and \(89.7\); SWDE from \(74.17\) to \(92.9\), \(95.1\), and \(96.4\); and DROP F1 from \(10.8\) to \(13.1\), \(14.2\), and \(15.8\) [2603.05829].

Batch-based many-shot effects can also be beneficial. On GSM8K with GPT-4o, Auto-Demo Prompting at batch size \(32\) achieves \(0.957\), compared with \(0.953\) for a single prompt and \(0.927\) for standard batch prompting. On SVAMP with GPT-4o, Auto-Demo Prompting at batch size \(32\) maintains \(0.940\), equal to the single-prompt baseline and above batch prompting at \(0.900\). With retrieval-based batch selection, GPT-4o reaches \(0.903\) on RTE at batch size \(32\), compared with \(0.884\) for both the single prompt and batch prompting with selection; on QQP it reaches \(0.873\), compared with \(0.857\) and \(0.860\) [2410.01724].

The weak-supervision formulation likewise yields measurable gains. On the WRENCH benchmark, the paper reports an average \(19.5\%\) reduction in errors over zero-shot performance in the abstract. With T0++, zero-shot distillation on YouTube gives \(58.7 \pm 2.4\) accuracy, whereas Prompted Weak Supervision yields \(92.0 \pm 0.5\); on SMS, F1 improves from \(83.2 \pm 2.4\) to \(91.8 \pm 1.6\); and on Spouse, F1 improves from \(41.5 \pm 13.1\) to \(62.9 \pm 0.8\) [2205.02318]. Taken together, these results indicate that many-shot prompting is most reliable when demonstrations are highly informative, outputs are constrained, and the aggregation or denoising mechanism can suppress prompt-specific variance.

## 5. Limits, paradoxes, and over-prompting

The strongest empirical challenge to naive “more is better” intuitions comes from code translation. A large-scale study over \(90{,}000\) translations evaluates \(0\), \(5\), \(25\), \(125\), and \(625\) shots with prompt lengths ranging from approximately \(100{,}000\) to \(800{,}000\) tokens. Across Gemini 1.5 Flash, Gemini 2.0 Flash, and Gemini 2.0 Flash Lite, Pass@1 rises from zero-shot to a peak in the few-shot range and then declines in the many-shot regime. For Gemini 1.5 Flash, Pass@1 follows \(53.8\%\rightarrow 60.4\%\rightarrow 61.8\%\rightarrow 60.2\%\rightarrow 56.4\%\); for Gemini 2.0 Flash, \(57.4\%\rightarrow 61.5\%\rightarrow 61.8\%\rightarrow 60.1\%\rightarrow 57.9\%\); and for Gemini 2.0 Flash Lite, \(55.1\%\rightarrow 56.3\%\rightarrow 55.9\%\rightarrow 55.6\%\rightarrow 54.8\%\). Static metrics diverge from functional correctness: for Gemini 1.5 Flash, BLEU continues from \(12.14\) at zero-shot to \(12.98\) at \(625\) shots, while functional success degrades. The paper terms this mismatch the “many-shot paradox” [2510.16809].

Cost amplifies the same point. For Gemini 2.0 Flash, the average per-translation cost rises from \(\$0.0783\) at \(25\) shots to \(\$1.6807\) at \(625\) shots, approximately \(21\times\), while Pass@1 drops from \(61.8\%\) to \(57.9\%\). The degradation is not attributed to truncation, because the longest measured prompts remain within the \(\ge 1\)M-token context windows of the tested models [2510.16809].

A related phenomenon is “over-prompting” in software requirement classification. The paper studies \(k \in \{0,5,10,20,40,80,120,160\}\) and reports unimodal F1-versus-shot-count curves for many models. On PURE, models peak around \(k \approx 5\)–\(20\) and then decline; GPT-4o, GPT-3.5-turbo, LLaMA-3.1-8B, and Gemma-3-4B all show this pattern, whereas DeepSeek-V3 plateaus and Mistral-7B improves steadily. On binary PROMISE with TF-IDF selection and \(10\)-fold cross-validation, stated model-optimal shot counts are approximately \(40\) for GPT-4o, \(120\) for GPT-3.5-turbo, \(80\) for Mistral-7B-instruct, \(40\) for LLaMA-3.1-8B-instruct, and \(10\) for LLaMA-3.2-3B-instruct [2509.13196].

The test-time adaptation study generalizes these failures beyond one domain. Many-shot prompting is effective for structured tasks, but it often shows limited benefits for open-ended generation. On WMT16, BLEU improves only modestly: En–De from \(34.51\) to \(37.0\) at \(4\)-shot and \(37.5\) at \(32\)-shot, and De–En from \(44.76\) to \(46.3\) and \(47.0\). GPQA shows modest gains at small \(n\) and then stagnates or declines, moving from \(47.99\) to \(51.9\) at \(4\)-shot and back to \(48.8\) at \(32\)-shot. High-capacity models can also suffer from over-conditioning at the largest update magnitudes, while long chain-of-thought traces induce attention competition and “lost in the middle” effects [2603.05829].

Across these studies, the principal failure modes are consistent: diminishing marginal relevance of additional examples, redundancy growth, prompt interference, positional bias, and a syntax–semantics gap in which longer contexts can improve surface similarity while harming executable or semantically faithful behavior. This suggests that many-shot prompting is fundamentally task-dependent rather than universally monotonic.

## 6. Security, privacy, and broader research implications

Many-shot prompting has also been used to expose memorization. Many-Shot Regurgitation prompting constructs a single prompt with alternating faux “user” and “assistant” turns built from contiguous segments of a source document, then asks the model to generate the final withheld segment. The model output \(T_n'\) is compared with the true segment \(T_n\) using Longest Common Substring–based counts across thresholds \(k \in [\ell_{\min}, \ell_{\max}]\), with \(\ell_{\min}=5\) and \(\ell_{\max}=12\) in the main experiments. Distributional differences between likely pretraining documents \(D_{\rm pre}\) and post-cutoff documents \(D_{\rm post}\) are then evaluated by Cliff’s delta, Kolmogorov–Smirnov distance, and Kruskal–Wallis \(H\) [2405.08134].

The reported separations are large. For GPT-3.5 on Wikipedia, the paper reports Cliff’s delta \(=-0.984\) and KS distance \(=0.875\); elsewhere in the paper’s Wikipedia results, GPT-3.5 is also reported with \(\delta=-1.0\), KS \(=1.0\), \(H=11.31\), and \(p=0.0008\). The study further finds that increasing shots from \(2\) to \(8\) generally increases verbatim matches, with \(6\) shots performing best in the reported setup, while increasing temperature from \(0.1\) to \(0.7\) reduces verbatim matches across thresholds [2405.08134].

These results matter because they show that the same repeated-conditioning mechanisms that improve utility can also amplify privacy and copyright risks. A plausible implication is that many-shot prompting should be evaluated not only for task accuracy but also for undesirable behaviors such as verbatim continuation, membership leakage, or excessive sensitivity to repeated contextual cues.

The broader literature therefore treats many-shot prompting as a powerful but bounded inference-time control mechanism. ICS proposes practical defaults such as \(n \approx 100\), \(M \approx 10\), and \(k'=3\) for NLI and QA [2311.09782]. Test-time adaptation studies recommend moderate shot counts for structured tasks and caution against aggressive scaling for open-ended generation [2603.05829]. \(k\)NN Prompting shows that some of the benefits of many-shot conditioning can be recovered without enlarging prompts, by moving the “many-shot” component into a datastore of LLM-derived representations [2303.13824]. Auto-Demo Prompting shows that many-shot behavior can also emerge inside a single batched inference, with only a slight compromise in token usage [2410.01724].

In aggregate, the modern view of many-shot prompting is neither that long-context prompting should be maximized nor that it should be avoided. It is that prompt length, example relevance, diversity, ordering, aggregation, and evaluation metric must be jointly designed. When those factors align, many-shot prompting can function as a strong input-space update; when they do not, it can plateau, over-condition, regurgitate, or fail on exactly the tasks for which additional context might have seemed most attractive.

Source: https://www.emergentmind.com/topics/many-shot-prompting