liveBook · Manning

One-shot prompting

As explained in LLMs in Production

One-shot prompting is a prompting technique that supplies exactly one example or instruction to guide a language model's performance on a task.

One-shot prompting asks an LLM to perform a task from exactly one clear instruction or example. It is useful when additional examples would consume context space or increase token costs, but the single example must be chosen carefully. section 7.1.1 section 7.1.2

Use one-shot prompting with these trade-offs in mind:

  • Treat the example as a strong signal: the first example often delivers most of the benefit gained from additional few-shot examples. section 7.1.2
  • Avoid unbalanced demonstrations. A single positive sentiment example can bias classifications toward positive outputs, especially for unfamiliar tasks. section 7.1.2
  • Prefer it when context limits or per-token pricing make several long examples impractical. section 7.1.1

A single reasoning demonstration

A prompt can show one solved word problem, then ask the model to solve a similar problem: “Answer this question. Think it through step by step: How could it be possible?” The demonstration establishes the expected task and response pattern, while the model supplies the next answer using its broader pretrained language knowledge. section 7.1.2

Figure 7.2 One-shot prompting example
figure

Use the one-shot prompting figure to inspect how a single demonstration is structured before the target request. section 7.1.2

How LLMs in Production covers it

How deep it goes
Explains definition, diminishing returns, example bias, and pretrained-model rationale, but stops short of implementation code.
Examples
Uses sentiment classification and a father-and-son hospital riddle as demonstrations of bias and guided reasoning.
What it assumes
Distinguishes prompting from fine-tuning while relying on language knowledge acquired during large-scale pretraining.
What you can do after
Apply one-shot prompting by selecting a precise demonstration and checking whether it unintentionally biases the requested output.
How it connects
Connects one-shot prompting to few-shot prompting, zero-shot prompting, pretraining, and fine-tuning.

Also explained in

Compare how 3 books explain one-shot prompting →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of LLMs in Production. The section links point to the parts of the book it draws on.