Skip to main content

What is few-shot prompting?

The Harvard Chan AI Glossary

In our classes, we often pause to explain the ideas behind AI and the language used to describe it. These posts grew out of those conversations. They’re for anyone who would like to understand AI better, with no technical background assumed.

Few-shot prompting means showing an AI system based on a Large Language Model (LLM) a small number of examples of the task you want it to perform. A prompt is the instruction and information you give the system. “Few-shot” means that the prompt includes a few demonstrations, rather than only a description of the task.

Suppose you want to sort customer messages into three categories: delivery, payment and other. You could show “Where is my parcel?” followed by “Delivery,” and “I was charged twice” followed by “Payment.” You then supply a new message and ask for its category. The examples demonstrate both the decision and the format of the answer.

This can be more effective than an abstract instruction alone. “Use a warm but concise tone” leaves room for interpretation. Showing a short reply that has the tone you want makes the request more concrete. Examples are especially useful when your organization uses an unusual format, specific wording or categories whose boundaries are not obvious.

The examples work through the information available in the current interaction. They do not normally change the model’s learned internal settings. A model is the part of the AI system that has learned patterns from earlier examples; changing those settings through additional training is a different process, called fine-tuning. Few-shot prompting instead supplies demonstrations for the task at hand.

Researchers also call this in-context learning. Here, context means the material available to the model while it prepares its answer. The word “learning” can be misleading: the system may adapt its response without permanently learning a new skill. A later conversation will not necessarily retain the examples unless the application supplies them again. In short, the underlying AI model is not being permanently modified.

For a clinic’s administrative inbox, a few fictional examples could show the difference between rescheduling an appointment, questioning a co-pay and reporting a new symptom that requires clinical escalation. Include ambiguous and mixed messages rather than only tidy examples. Then test on held-out messages, checking both the proposed routing and what happens when the system is uncertain. Demonstrating an administrative category is not enough to establish safe clinical triage.

Sources: Brown and colleagues — Language Models Are Few-Shot Learners; Min and colleagues — Rethinking the Role of Demonstrations.

If you would like to find out more about AI and improve your leadership skills, consider the AI in Health Care Certificate of Specialization from the Advanced Learning Academy at Harvard T.H. Chan School of Public Health. You can take an individual course or work toward the full certificate.


AI is a fast-moving field. This explanation reflects our class discussions and related material at the time of writing. Terminology, capabilities and tools may change.

For suggested additions or corrections, please email me at tpanch@hsph.harvard.edu.

Dr. Trishan Panch
Program Director, AI in Health Care
Harvard T.H. Chan School of Public Health — Advanced Learning Academy