Source-linked AI summary
Calibrate Before Use: Improving Few-Shot Performance of Language Models
Tony Z. Zhao, Eric Wallace, Shi Feng, Dan Klein, Sameer Singh
TL;DR
Few-shot GPT-3 accuracy can vary sharply with prompt format, examples, and their ordering. Contextual calibration estimates answer biases using content-free inputs and adjusts output scores to make those inputs uniform across answers. Across tasks, it improves GPT-3 and GPT-2 accuracy by up to 30.0% absolute and reduces variation across prompts.
Problem
Few-shot GPT-3 accuracy is highly sensitive to prompt format, example selection, and example order, making consistently good performance difficult to obtain.
Source: §1 · p. 1Method
Contextual calibration estimates answer biases from content-free inputs and adjusts output scores so those inputs receive uniform scores across answers.
Source: §1 · p. 2Results
Up to 30.0% absolute accuracy gains are reported, with contextual calibration consistently improving GPT-3 and GPT-2 accuracy and stability across tasks and prompt choices.
Source: §1 · p. 2Takeaways & Limitations
Small decisions such as calibration can substantially influence few-shot results, complicating the development and comparison of new methods.
Source: §8 · p. 8Contextual calibration mitigates but does not eliminate the need for prompt engineering.
Source: §6 · p. 7
Abstract
from arXiv · showhide
GPT-3 can perform numerous tasks when provided a natural language prompt that contains a few training examples. We show that this type of few-shot learning can be unstable: the choice of prompt format, training examples, and even the order of the training examples can cause accuracy to vary from near chance to near state-of-the-art. We demonstrate that this instability arises from the bias of language models towards predicting certain answers, e.g., those that are placed near the end of the prompt or are common in the pre-training data. To mitigate this, we first estimate the model's bias towards each answer by asking for its prediction when given the training prompt and a content-free test input such as "N/A". We then fit calibration parameters that cause the prediction for this input to be uniform across answers. On a diverse set of tasks, this contextual calibration procedure substantially improves GPT-3 and GPT-2's average accuracy (up to 30.0% absolute) and reduces variance across different choices of the prompt.
1. Introduction
Contextual calibration counteracts answer biases that make few-shot language-model predictions sensitive to prompt choices. It improves GPT-3 and GPT-2 accuracy and stability without additional training data.
1. Introduction
- GPT-3 performs numerous tasks from a few examples in natural-language prompts (Brown et al., 2020), without updating model parameters.This is the paper’s in-context few-shot learning setting.Source: §1 · p. 1
- In-context learning enables rapid prototyping and natural-language system creation by nontechnical users, while model reuse reduces memory requirements and serving complexity across tasks.Changing the prompt immediately produces a new model behavior.Source: §1 · p. 1
- 54% to 93% sentiment-analysis accuracy results from merely reordering training examples, illustrating GPT-3’s sensitivity to prompt format, example selection, and ordering.This instability means manually designed prompts cannot reliably deliver good accuracy.Source: §1 · p. 1
- Majority-label, recency, and common-token biases favor frequent training answers, answers near the prompt’s end, and answers common in pretraining, respectively.These biases typically shift the model’s output distribution.Source: §1 · p. 1
- Up to 30.0% absolute accuracy improvement accompanies consistently better GPT-3 and GPT-2 accuracy and reduced variability across prompt formats and examples.Greater stability mitigates the need for prompt engineering.Source: Figure 1 · p. 2, §1 · p. 2
- Contextual calibration estimates answer biases using content-free inputs, then fits parameters to make those inputs’ answer scores uniform without additional training data.A dummy test input such as “N/A” reveals the model’s preference among answers.Source: §1 · p. 2
2. Background and Experimental Setup
The experimental setup evaluates prompted language models on text classification, fact retrieval, and information extraction using task-specific prediction and evaluation procedures. GPT-3 accuracy varies substantially with prompt examples, their ordering, and prompt format.
2. Background and Experimental Setup
- In-context learning prompts combine a format, training examples, and their ordering, which matters because language models update hidden states left to right.Training examples demonstrate how to solve the task; zero-shot prompts contain none.Source: §2 · p. 2
2.1. Datasets and Prompt Formats
- Six text-classification datasets cover sentiment analysis, question classification, textual entailment, and topic classification; each dataset uses a fixed prompt format unless otherwise specified.Classification uses SST-2, 6-way TREC, 3-way CB, and binary RTE, with CB and RTE drawn from SuperGLUE (Wang et al., 2019). Topic classification uses 4-way AGNews (Zhang et al., 2015) and 14-way DBPedia (Zhang et al., 2015).Source: §2.1 · pp. 2–3
2. Background and Experimental Setup
- GPT-3 2.7B shows high accuracy variance on SST-2 when training-example sets, example order, or prompt formats change.Figure 2 varies permutations within ten sets of four examples; Figure 3 compares ten formats using different sets of four examples.Source: Figure 2 · p. 3, Figure 3 · p. 3
2.1. Datasets and Prompt Formats
- Fact retrieval uses LAMA, retaining templates whose missing answers occur at the end and reporting average accuracy across all triples.Knowledge-base triples become prompts with missing objects; answers are always single tokens.Source: §2.1 · p. 3
- ATIS and MIT Movies trivia10k13 evaluate slot filling using Exact Match between generated outputs and ground-truth spans.The selected slots are airline and departure date for ATIS, and director name and movie genre for MIT Movies.Source: §2.1 · p. 3
2.2. Model Details
- Experiments use three GPT-3 sizes and GPT-2, scoring classification through label-name probabilities and generating greedily until a newline for generation tasks.GPT-3 has 2.7B, 13B, or 175B parameters; GPT-2 has 1.5B. Test inputs are inserted into the prompt’s test placeholder.Source: §2 · p. 2, §2.2 · p. 3
3. Accuracy Varies Highly Across Prompts
GPT-3’s accuracy varies sharply with training-example selection, ordering, and prompt format. More examples and larger models do not necessarily eliminate this instability.
3. Accuracy Varies Highly Across Prompts
- 54.3% to 93.4% accuracy on 4-shot SST-2 with GPT-3 2.7B can result solely from changing the order of training examples.With prompt format fixed, ordering can matter as much as or more than example selection. Majority-label and recency biases favor labels prevalent in the prompt or repeated near its end.Source: §3 · p. 3, Figure 4 · p. 4
- Accuracy variance remains high even with 16 training examples and can persist with larger models; adding training examples to prompts does not necessarily reduce variance and can sometimes hurt accuracy.Training-example counts were swept for three datasets; DBPedia mean accuracy drops from 36.0% at 0-shot to 25.9% at 1-shot.Source: §3 · p. 3
- Prompt formats differ in average SST-2 accuracy, but all still exhibit high variance across training sets.Holding examples and ordering fixed, the authors test 14 additional formats, including question-answer, conversation-style, Web-page-like templates, and variations in label names.Source: §3 · p. 4
4. What Causes the High Variance?
GPT-3’s accuracy varies because majority-label, recency, and common-token biases shift its answer distribution. These biases make predictions sensitive to training-example selection and order, label names, and answer rarity.
Majority Label Bias
- 50.2% of GPT-3 2.7B’s 4-shot LAMA validation predictions repeat a training answer, versus a correct repeat rate of 24.7%, illustrating majority-label bias.Favoring labels frequent in the prompt degrades accuracy on balanced SST-2. Repeating the lone training example’s class also explains frequent accuracy drops from 0-shot to 1-shot.Source: §4 · p. 4
Recency Bias
- Nearly 90% of predictions are Negative for a P P P N prompt, showing that recency bias can outweigh a three-to-one Positive majority.For 4-shot LAMA, overprediction of answers from training positions 1–4 is 8.5%, 8.3%, 14.3%, and 16.1%, respectively, helping explain sensitivity to example order. Overprediction means model repeat rate minus ground-truth repeat rate.Source: §4 · p. 4
Common Token Bias
- 11× more frequent predictions for “book” than “artist” on balanced 14-way DBPedia illustrate GPT-3’s common-token bias.Label-name frequency correlates with class prediction rate (r = 0.67), helping explain sensitivity to label names. On LAMA, the model often predicts common entities instead of rare ground-truth answers.Source: §4 · pp. 4–5
The Impact of Biases on Model Predictions
- 94% validation accuracy would be achievable for the illustrated SST-2 classifier with an optimal p(Positive) = 0.68 threshold, correcting frequent false positives.The three biases typically shift the model’s output distribution. For this prompt, high Positive confidence causes frequent false positives under the default 50% threshold.Source: Figure 5 · p. 5, §4 · p. 5
5. Contextual Calibration
Contextual calibration estimates prompt-dependent answer bias using content-free inputs and adjusts output probabilities to counter it. It improves accuracy across classification and generation tasks and can reduce variability across training examples and prompt formats.
5. Contextual Calibration
- Contextual calibration estimates answer bias from content-free inputs and sets transformation parameters to make their class scores uniform, without calibration training data.For content-free probabilities p_cf, the method sets W = diag(p_cf)^-1 and b = 0, then predicts using argmax(Wp + b). Content-free predictions depend on the training examples, their order, and prompt format.Source: §5 · p. 5
- Implementation adds trivial computational overhead by saving content-free probabilities and adjusting outputs; experiments average predictions from “N/A”, “[MASK]”, and the empty string.This ensemble performed best on AGNews and was reused across the other datasets.Source: §5 · p. 5
- Inverse-probability scaling performs better for classification, while subtracting content-free probabilities with W set to the identity performs better for generation.Classification uses renormalized label probabilities; generation calibrates only first-token probabilities because later predictions were highly deterministic on the studied tasks. Restricting W to diagonal avoids quadratic parameter growth.Source: §5 · p. 5
5.1. Results for Contextual Calibration
- Up to 30.0% absolute gains improve GPT-3’s mean and worst-case accuracy across classification and generation tasks.Calibrated GPT-3 2.7B sometimes outperforms the GPT-3 175B baseline by up to 19.3%, despite being over 50x smaller.Source: Table 1 · p. 6, §5.1 · p. 6
- Across the evaluated datasets and language models, contextual calibration considerably reduces accuracy variance across training-example sets in a majority of cases, with only small increases in the remaining cases.Evaluation used five random training-example sets, a fixed prompt format, and labeling budgets of 0–8 examples; contextual calibration and the baseline (standard decoding without calibration) used the same sets.Source: §5.1 · p. 6, Figure 6 · p. 7
- GPT-2 1.5B also exhibits substantial prompt sensitivity, and contextual calibration works out-of-the-box to improve mean accuracy and reduce variance for most tasks.This extends the observed prompt instability and calibration benefits beyond GPT-3.Source: §5.1 · p. 7
- Across prompt formats, contextual calibration improves average and worst-case accuracy for SST-2 and LAMA, while reducing variance for SST-2.Experiments held training examples fixed and tested 15 formats for SST-2 and each of three LAMA relations.Source: §5.1 · p. 7, Figure 7 · p. 7
5.2. Ablations on Contextual Calibration
- Contextual calibration approaches validation-tuned oracle accuracy on AGNews, while SST-2 and AGNews ablations show that content-free input choice matters but many choices work well.The oracle uses the validation set to find the best diagonal W.Source: §5.2 · p. 7
6. Discussion
Contextual calibration mitigates, but does not eliminate, the need for prompt engineering. The study uses a fixed language model without finetuning, leaving its interaction with contextual calibration for future work.
Does Calibration Eliminate the Need to Engineer Prompts?
- Contextual calibration makes best-, average-, and worst-case prompt accuracies higher and more similar, reducing rather than eliminating the need for prompt engineering.Prompt format and examples still warrant tuning for the best performance (Brown et al., 2020; Gao et al., 2020).Source: §6 · p. 7
Should You Finetune in the Few-shot Setting?
- Using a fixed language model without finetuning enables rapid prototyping, a fully natural language interface, and lower memory requirements and serving complexity across tasks.These practical advantages motivate the study’s choice not to finetune.Source: §6 · p. 7
- Finetuning can improve accuracy over in-context learning when its disadvantages are acceptable or avoidable (Schick & Sch¨utze, 2020; Gao et al., 2020).Finetuning can also be unstable in few-shot settings (Schick & Sch¨utze, 2021). Future work could test whether contextual calibration reduces the need for finetuning, or vice versa.Source: §6 · p. 7
7. Related Work
Contextual calibration builds on few-shot in-context learning and may improve prompt-based probing of language models. The paper extends prior work on instability to in-context learning, analyzes its causes, and connects its findings to known language-model failures.
Few-shot Learning with Language Models
- Contextual calibration improves the few-shot setting of Radford et al. (2019) and Brown et al. (2020), while potentially correcting underestimation in prompt-based probing.The paper recommends calibration for probes of factual knowledge (Shin et al., 2020) and commonsense knowledge (Bosselut et al., 2019).Source: §7 · pp. 7–8
Volatility of Few-shot Learning in NLP
- The paper extends instability findings to left-to-right in-context learning without finetuning, identifies example-order sensitivity, and analyzes causes to develop mitigation.Prior work found prompt-format sensitivity in zero-shot masked models (Shin et al., 2020). Independent concurrent work found training-example sensitivity during few-shot finetuning (Schick & Sch¨utze, 2020; Gao et al., 2020).Source: §7 · p. 8
Failures of Language Models
- The paper connects in-context learning failures, including recency bias, to previously documented failures in language-model text generation.These include repetition (Holtzman et al., 2020), overconfidence (Braverman et al., 2020; Jiang et al., 2020a), recency bias (Khandelwal et al., 2018; Ravfogel et al., 2019), and preference for generic responses over rare text.Source: §7 · p. 8
8. Conclusion and Future Work
The results motivate more robust few-shot learning methods and closer analysis of what GPT-3 learns from prompts. Calibration can greatly influence results, while improvements from additional examples coexist with learning superficial patterns.
- Small decisions such as calibration can greatly influence few-shot results, complicating the development and comparison of pretraining schemes and model architectures.Source: §8 · p. 8
- Future methods work aims to make few-shot learning more robust and extend calibration to a wider range of tasks, including open-ended generation.Source: §8 · p. 8
- GPT-3 improves with more training examples but also learns superficial prompt patterns, including repetition of common answers, motivating closer analysis of in-context learning.Source: §8 · p. 8
A. Additional Results on Variance and Calibration
Additional results show that example ordering and the choice of content-free input affect accuracy. They also examine calibration across prompt formats for GPT-3 on LAMA and its effect on GPT-2.
- 88.5% accuracy falls to 51.3%, near random chance, for GPT-3 2.7B when the order of two training examples is reversed.Source: Table 2 · p. 11, A. Additional Results on Variance and… · p. 11
- The choice of content-free input affects accuracy, but many good choices exist.Table 3 examines 1-shot SST-2 and 0-shot AGNews. The experiments ensemble over N/A, [MASK], and the empty string.Source: A. Additional Results on Variance and… · p. 11, Table 3 · p. 11
- Figure 9 compares GPT-3 accuracy across LAMA prompt formats with and without calibration; Table 4 examines calibration’s effect on GPT-2.Source: A. Additional Results on Variance and… · p. 11
B. Prompt Formats Used
The section documents default prompts for text classification and generation, plus 15 SST-2 formats used to study prompt-format effects.
B. Prompt Formats Used
- 15 prompt formats are used to study the effect of prompt format on SST-2.Table 7 illustrates the formats with one training example.Source: B. Prompt Formats Used · p. 11, Table 7 · p. 15
- Text-classification predictions use the language model’s probabilities for the specified label-name tokens.Table 5 illustrates each task’s prompt with one training example.Source: Table 5 · p. 13
- Default generation-task prompts are documented in Table 6, with one training example per task for illustration.Together, Tables 5 and 6 provide the default prompt formats used across all tasks.Source: B. Prompt Formats Used · p. 11, Table 6 · p. 14
Related papers
This paper cites
Cited by
- Rethinking Neural Thickets Without Weight Perturbations2026
- From Leniency to Suspicion: How an Open Post-Training Recipe Changes Whom LLM Fact-Checkers Believe2026
- Precedent or Intent? What Coding Agents Follow When Evolving Existing Code2026
- Understanding Jev-Style System One Models: Does Structure Reduce Selection Bias?2026
- Counterfactual Test-Time Augmentation for Shortcut Removal in Language Models2026
- From Noisy Retrieval to Decision Evidence: Silver Evidence Demonstrations for In-Context Learning2026