liveBook · Manning

Few-shot prompt context

As explained in Prompt Engineering in Practice

Few-shot prompting is a prompting technique that provides a small number of input-output examples to guide a model's response.

Few-shot prompt context adds a small number of input–output examples to a request. The examples demonstrate a pattern for the model to extend to the target input. This is in-context learning: it shapes one response at inference time without retraining or updating model weights. section 7.1 section 7.3

Design the prompt as a reusable engineering artifact:

  • Start with an instruction-only, zero-shot baseline. Add examples when results drift, miss domain conventions, or fail to follow a required structure. section 7.3 section 7.4
  • Define labels or required fields explicitly. Use examples to show how those definitions apply, rather than relying on examples to define the task alone. section 7.3
  • Begin with one example for format; add a contrasting or boundary example if needed. Keep their formatting consistent, and test broader coverage separately instead of accumulating a long static list. section 7.3 section 7.4

CI failure handoff prompt

Role: You are a build triage assistant. Instructions: Review the reference example for structure, detail, and triage priority. Write a concise handoff for the target failure. Output format: Stage; Likely cause; Owner; Next step. Reference input: Integration tests timed out waiting for a Redis fixture in the checkout suite. Reference output: Stage: Integration tests; Likely cause: Redis fixture startup instability, not application logic; Owner: QA; Next step: Reset the test environment and rerun integration tests. Target input: The checkout-service build and unit tests passed, but its Argo rollout failed readiness checks: GET /healthz returned 503 for 10 minutes, followed by smoke-test failures on /api/checkout/quote. Acceptance check: The response uses the four named fields and bases its triage on the target failure, not the reference failure. section 7.3.1

Compare zero-shot and few-shot versions on the same task inputs. Check field consistency, label coverage, and ambiguous cases; try a representative example paired with a boundary example. Estimate input and output tokens before keeping the longer prompt in production. Few-shot prompting is especially useful for classification, structured extraction, format conversion, and domain-specific labeling; open-ended generation usually benefits less. section 7.3.5 section 7.3

How Prompt Engineering in Practice covers it

How deep it goes
Explains request-scoped pattern learning and develops example-count, formatting, coverage, and token-cost decisions without teaching model retraining.
Examples
Demonstrates a four-field CI/CD failure handoff and proposes classification stress tests using incident severity or pull-request comment triage.
What it assumes
Assumes familiarity with prompt roles and instructions; introduces in-context learning without requiring model retraining.
What you can do after
Build it from scratch by upgrading a zero-shot prompt with representative examples, then testing format, edge cases, and token cost.
How it connects
Connects in-context learning to zero-shot prompting, fine-tuning, system prompts, and user prompts.

Related concepts

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