Few-Shot Prompting

Few-shot prompting guides a language model with a few solved examples of a task in the prompt, as in AI-assisted data extraction for evidence reviews.

Status
Published, version 1.0.0
Last reviewed
10 Nov 2026, by Dr Darrin Baines
Report a problem
Tell us if something is wrong or out of date

Concept Architecture

Few-Shot Prompting in AI-Assisted Evidence Review

Few-shot prompting places a small number of solved examples of a task inside the prompt to a large language model, then gives it a new case to complete in the same way. The model's weights do not change, so the examples work as instructions by demonstration, showing what input to expect and what shape the answer should take. Brown and colleagues defined and tested the approach with GPT-3 in 2020, setting it beside zero-shot prompting, where only a written instruction is given, and fine-tuning, where a pre-trained model is further trained on labelled data. For a health economist or HTA analyst it matters most in data extraction for a systematic review or an economic model, where NICE ECD20 (2026), the NICE framework on AI methods for evidence, reports that extraction accuracy tends to rise when examples are added. The same examples can mislead, because errors, imbalance or a poor ordering in them carry through to the outputs.

Demonstrations in place of retraining

Brown and colleagues placed few-shot prompting on a spectrum defined by how much task-specific data a method needs. Fine-tuning updates the weights of a pre-trained model on typically thousands to hundreds of thousands of labelled examples. Few-shot prompting gives K demonstrations, each a context with its desired completion, then one final context for the model to complete, and no weights are updated. One-shot prompting allows a single demonstration with a description of the task, and zero-shot prompting gives the instruction alone. Radford and colleagues had earlier used zero-shot in a broader sense for GPT-2, meaning no change to its parameters or architecture, even where example pairs were placed in the context.

Brown and colleagues called this behaviour in-context learning. K could be any number between zero and what the context window could hold, which for GPT-3 was 2,048 tokens and typically fitted 10 to 100 examples. They found larger K usually, but not always, better, and where a separate development set existed they tried a few values of K on it before running the best on the test set. They left open whether the model learns a new task from the examples or recognises one met in training. The token limit that caps K is the subject of Context Window, and Prompt Engineering covers the wider practice to which few-shot prompting belongs.

What the examples teach and why results vary

Experiments on classification tasks suggest that examples mainly teach the form of a task. Min and colleagues replaced the correct labels in demonstrations with random ones and found that performance on classification and multiple-choice tasks barely fell, consistently across 12 models including GPT-3. They concluded that demonstrations help chiefly by showing the possible answers, the kind of input text and the layout of the sequence. For extraction this suggests that a few-shot prompt fixes the output layout well, but a correct answer in an example need not pass on the judgement behind it.

Results can also be unstable. Zhao and colleagues showed that the prompt format, the choice of examples and even their order could leave GPT-3's accuracy anywhere between near chance and near the best published results. They traced much of this to majority label bias, a pull toward answers frequent among the examples, and recency bias, a pull toward answers near the end of the prompt. Lu and colleagues found that some orderings of the same examples performed close to the best results and others no better than random guessing, across model sizes, and that a good order for one model did not carry over to another.

For screening, a prompt whose examples are mostly exclusions risks tilting the model toward excluding. Schmidt and colleagues describe wrongly excluding relevant evidence as the costliest error in their field, and one that may well go undetected. Since ECD20 makes sensitivity the primary screening measure, the balance and order of the examples belong in the method report.

Few-shot prompting in NICE ECD20

NICE ECD20 (2026) lists few-shot prompting in its glossary as a prompt engineering technique, notes that the number of examples usually has to be tuned because too many can harm performance, and treats zero-shot prompting as the case where K equals zero. Its chapter on AI methods for evidence synthesis finds that prompting method strongly affects extraction accuracy and that few-shot prompting "generally improves performance". A clear example of the required layout can also make the output more accurate and more consistent. It accepts AI support and semi-automation of extraction only when each returned value is checked against the original study, and advises against AI-only extraction for now.

ECD20's introduction warns that benchmark bias, where the reference standard itself contains errors, can overlap with context bias when few-shot examples contain mistakes. Its evidence synthesis chapter asks for prompt templates to be tuned on set-aside development records. For a health economic model, ECD20 allows AI only as an aid under close human control, for example proposing parameter estimates an analyst checks before use. A few-shot prompt suits that role when suggestions must follow a fixed layout, such as parameter, value and source page, that can be checked line by line.

Choosing the examples and the number K

The examples are data. Schmidt and colleagues, testing GPT-4 for extraction in systematic reviews, stressed keeping prompt-design records and evaluation records separate. Picking examples and judging accuracy on the same records inflates the measured performance, much as overfitting flatters a predictive model judged on its own training data. Examples also need checking as carefully as a reference standard, and a deliberate mix of answers, for example enough inclusions in a screening prompt that the model is not pulled toward excluding.

Each added example also uses tokens, so K trades possible accuracy against prompt length and cost. The input length per record is

T=T0+K×Te+TrT = T_0 + K \times T_e + T_r

where TT is the number of input tokens sent for one record, T0T_0 is the number of tokens in the fixed instruction, KK is the number of examples, TeT_e is the average number of tokens in one example including its answer, and TrT_r is the number of tokens in the record being processed.

Worked example with extraction of trial inputs

All numbers in this example are illustrative. A team building a cost-effectiveness model asks a language model to extract six items from each trial abstract, including the number randomised in each arm. It writes the examples from trials outside both sets, compares K equal to 0, 3 and 8 on 40 development abstracts, then tests the chosen prompt on 50 held-out abstracts.

1. Prompt length. With T0=300T_0 = 300, Te=450T_e = 450 and Tr=400T_r = 400, the zero-shot prompt is 300 + 400 = 700 tokens. Three examples give 300 + 3 × 450 + 400 = 2,050 tokens, and eight give 300 + 8 × 450 + 400 = 4,300 tokens.

2. Development results. The 40 abstracts hold 40 × 6 = 240 items. The zero-shot prompt extracts 192 correctly, a proportion of 192 / 240 = 0.80. Three examples give 216 / 240 = 0.90 and eight give 213 / 240 = 0.8875. The team keeps K equal to 3, since five more examples added length without adding accuracy.

3. Token cost. At an illustrative GBP 2 per million input tokens, 1,000 abstracts cost 2,050 × 1,000 × 2 / 1,000,000 = GBP 4.10 with three examples and 4,300 × 1,000 × 2 / 1,000,000 = GBP 8.60 with eight. Both are small beside the cost of human checking, so K equal to 8 is rejected for its lack of gain in accuracy.

4. Held-out test. The 50 test abstracts give 50 × 6 = 300 item slots, of which 260 are reported and 40 are not. The prompt extracts 234 reported items correctly, so 260 − 234 = 26 are missed or wrong. It returns a value for 6 unreported items, leaving 40 − 6 = 34 correctly marked as not reported. Following the error definitions in ECD20, the two measures are

Sensitivity=TPTP+FN,PPV=TPTP+FP\text{Sensitivity} = \frac{TP}{TP + FN}, \qquad \text{PPV} = \frac{TP}{TP + FP}

where TPTP is the number of reported items extracted correctly, FNFN is the number of reported items missed or extracted wrongly, FPFP is the number of values returned for unreported items, and PPV is the positive predictive value. Sensitivity is 234 / 260 = 0.90 and PPV is 234 / 240 = 0.975. Because ECD20 counts a wrong value for a reported item as a false negative, this PPV is not the share of all returned values that are correct. ECD20's primary measure for extraction, overall concordance, counting the 34 correct not-reported answers as concordant, is (234 + 34) / 300 = 0.89.

5. Interpretation. About one reported value in ten would be missing or wrong without a human check, and 6 values would be returned for unreported items. Since ECD20 expects every AI-extracted item to be verified, the prompt can make checking quicker and more uniform but cannot replace it. The team would also rerun the test with the examples reordered, given the order effects Lu and colleagues found, and repeat runs to check the response stability that ECD20 asks for.

Neighbouring techniques and common misreadings

Zero-shot prompting is the limiting case, and the GPT-4 extraction study by Schmidt and colleagues was zero-shot. Chain-of-Thought Prompting in its original form, from Wei and colleagues, is few-shot prompting in which each example also shows intermediate reasoning steps. Fine-Tuning changes the model's weights, whereas few-shot examples must be sent with every call and leave the model unchanged. Retrieval-augmented generation supplies source text to answer from, while few-shot prompting supplies solved examples of the task.

A frequent error is to assume that more examples always help, which Brown and colleagues did not find and ECD20 cautions against. Another is to read a good result on one review as general, when ECD20 warns that accuracy on one extraction task or review may not hold for another. An ordering that worked for one model may fail for its successor, so a change of model or prompt calls for the re-validation that ECD20 asks for after substantive changes. Hallucination (AI) covers false content that a well-formatted answer can still contain.

Sources

  • Brown TB, Mann B, Ryder N, Subbiah M, Kaplan J, Dhariwal P, et al. Language models are few-shot learners. Advances in Neural Information Processing Systems 33 (NeurIPS 2020). 2020. https://arxiv.org/abs/2005.14165
  • Lu Y, Bartolo M, Moore A, Riedel S, Stenetorp P. Fantastically ordered prompts and where to find them: overcoming few-shot prompt order sensitivity. Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (ACL 2022). 2022. https://arxiv.org/abs/2104.08786
  • Min S, Lyu X, Holtzman A, Artetxe M, Lewis M, Hajishirzi H, Zettlemoyer L. Rethinking the role of demonstrations: what makes in-context learning work? Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing (EMNLP 2022). 2022. https://arxiv.org/abs/2202.12837
  • National Institute for Health and Care Excellence. AI methods for evidence framework (ECD20). NICE; published 9 November 2026. Chapters on introduction to AI in NICE decision making, principles for using AI in evidence activities, AI methods for evidence synthesis and AI methods for health economic evaluation, and Appendix A glossary. https://www.nice.org.uk/corporate/ecd20
  • Radford A, Wu J, Child R, Luan D, Amodei D, Sutskever I. Language models are unsupervised multitask learners. OpenAI technical report. 2019. https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf
  • Schmidt L, Hair K, Graziosi S, Campbell F, Kapp C, Khanteymoori A, et al. Exploring the use of a large language model for data extraction in systematic reviews: a rapid feasibility study. 3rd Workshop on Augmented Intelligence for Technology-Assisted Review Systems (ALTARS 2024). 2024. https://arxiv.org/abs/2405.14445
  • Wei J, Wang X, Schuurmans D, Bosma M, Ichter B, Xia F, et al. Chain-of-thought prompting elicits reasoning in large language models. Advances in Neural Information Processing Systems 35 (NeurIPS 2022). 2022. https://arxiv.org/abs/2201.11903
  • Zhao TZ, Wallace E, Feng S, Klein D, Singh S. Calibrate before use: improving few-shot performance of language models. Proceedings of the 38th International Conference on Machine Learning (ICML 2021). 2021. https://arxiv.org/abs/2102.09690

Library

Publications

2
  • Journal article

    MSR59 Evaluating Systematic Literature Review Screening Performance of Seven Large Language Models in Response to Different Prompting Strategies — Janoudi G, Rada (Uzun) M, Richter T, et al, Vol. 27, No. 12, p. S449 ed., 2024 (Value in Health)

    Compares seven LLMs and several prompting strategies for review screening, in a conference poster abstract.

  • Journal article

    MSR63 Prompt Engineering for the Use of Generative Artificial Intelligence (AI) in Health Economic Modeling: Findings From a Targeted Literature Review — O'Grady M, Adair N, Arguello R, et al, Vol. 27, No. 12, p. S450 ed., 2024 (Value in Health)

    Targeted review of prompt engineering approaches for generative AI in economic modelling, published as a poster abstract.

Frequently Asked Questions (6)

  • What is Few-Shot Prompting?

    Few-shot prompting guides a language model with a few solved examples of a task in the prompt, as in AI-assisted data extraction for evidence reviews.

    Source: Brown et al. 2020

  • How does few-shot prompting differ from zero-shot prompting and fine-tuning?

    Brown and colleagues placed these approaches on a spectrum defined by how much task-specific data each relies on. Fine-tuning further trains a pre-trained model on a labelled dataset, typically thousands to hundreds of thousands of examples, and so changes its weights. Few-shot prompting leaves the weights untouched and instead places a small number of solved examples, each an input with its desired answer, in the prompt before the new case. Zero-shot prompting gives only a written instruction, which is the case where the number of examples K equals zero. Because few-shot examples are not stored in the model, they have to be sent again with every call.

    Source: Brown et al. 2020

  • How does NICE ECD20 treat few-shot prompting for data extraction in a systematic review?

    The NICE ECD20 (2026) chapter on AI methods for evidence synthesis reports that the way a model is prompted has a strong effect on extraction accuracy, and that adding solved examples tends to improve it. It adds that showing the model a clear example of the required output layout can make extraction more accurate and more consistent. ECD20 advises against fully automated extraction at present and accepts AI support or semi-automation only when each extracted value is checked against the original study. A few-shot prompt can make that human checking quicker and more uniform, but it does not remove the need for it.

    Source: NICE ECD20 (2026)

  • Why do the choice and order of examples change the results of few-shot prompting?

    Zhao and colleagues showed that GPT-3's accuracy could range from near chance to close to the best published results depending on how the prompt was built, including which examples were chosen and the order in which they appeared. They traced much of this instability to majority label bias, a pull toward answers that appear often among the examples, and recency bias, a pull toward answers placed near the end of the prompt. When one class was more common in the prompt, the model leaned heavily toward predicting it. In title and abstract screening, a prompt whose examples are mostly exclusions therefore risks tilting the model toward excluding relevant records.

    Source: Zhao et al. 2021

  • How should the examples used in few-shot prompting be validated for an evidence review?

    NICE ECD20 (2026) notes that the number of examples usually has to be tuned, since too many can harm performance, and asks for prompt templates to be tuned on development records kept apart from the records used to judge accuracy. It also warns that errors in the examples can create context bias that overlaps with benchmark bias, so the examples need checking with the same care as a reference standard. Repeating the tasks under similar conditions shows whether responses are stable. ECD20 also expects re-validation after substantive changes to a model or prompt, so a few-shot prompt validated on one model version cannot simply be carried over to the next.

    Source: NICE ECD20 (2026)

  • What do the examples in few-shot prompting actually teach a language model?

    Min and colleagues replaced the correct labels in few-shot demonstrations with random ones and found that performance on classification and multiple-choice tasks barely fell, consistently across 12 models including GPT-3. They concluded that demonstrations help chiefly by showing the possible answers, the kind of input text and the overall layout of the sequence. For data extraction in an evidence review, this suggests that a few-shot prompt is good at fixing the output format, while a correct answer in an example need not pass on the judgement behind it. Accuracy on the real task therefore still has to be measured on records kept separate from the examples.

    Source: Min et al. 2022

Trust Record

Verified by Dr Darrin Baines

British health economist

Professional identity: darrinbaines.org

Verification date: 10 Nov 2026

Content version: 1.0.0

Canonical Identity

Term code
HS-HP-DH-081

Stable URI · Machine-readable · Resolvable · CC BY 4.0

This article is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).

Author: Dr Darrin Baines · Publisher: Intelligent Parameters Ltd · Identifier: https://healtheconomics.wiki/concept/few-shot-prompting