liveBook · Manning

Few-shot learning

As explained in Enterprise RAG

Few-shot learning is adaptation of a model's behavior from a small number of examples provided as part of an input.

Few-shot learning adapts a model’s behavior by placing a small number of examples inside the prompt. In production, it helps correct answers that use the right retrieved data but still violate user requirements. section 6.12

Use few-shot examples during prompt-tuning when:

  • A user complaint exposes a missing requirement, such as returning weights in metric units. section 6.12
  • The required instruction exists but is buried under too many instructions; shorten the prompt or pass concise retrieved-record summaries. section 6.12
  • Real conversations provide recurring failures that can be folded back into the prompt to reduce future errors. section 6.12

Format requirement as an example

Instruction: Answer weight questions in metric units only. Example — User: How much does ProductXYZ weigh? Assistant: ProductXYZ weighs 2 kg. section 6.12

Figure 6.8 Check the prompt and see if it is detailed enough. You can modify the prompt and add the user’s complaint to the prompt as an example. If the instructions you need are already there, the model may be hallucinating because the prompt is too long and complex.

Use the prompt-diagnosis workflow to distinguish missing instructions from hallucination caused by an overly long prompt. section 6.12

How Enterprise RAG covers it

How deep it goes
Explains example placement, prompt shortening, and feedback reuse, but stops short of model-training internals.
Examples
Demonstrates a metric-units requirement with a user question and an assistant answer about product weight.
What it assumes
Assumes prompts, system messages, retrieval results, and model responses; teaches example-based behavior correction from that workflow.
What you can do after
Apply it via prompt tuning by converting recurring user complaints into concise input-output examples.
How it connects
Connects few-shot learning with prompt tuning, retrieval-augmented generation, user feedback, and hallucination diagnosis.

Also explained in

Compare how 24 books explain few-shot learning →

Related concepts

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