liveBook · Manning

Chapter 8: Prompt sampling

What you will learn in chapter 8 of Prompt Engineering in Practice

The introduction explains why a strong prompt may still produce different answers across calls and why sampling multiple responses can make decisions more reliable.

After this chapter you will be able to

Section by section

Introduction

The introduction explains why a strong prompt may still produce different answers across calls and why sampling multiple responses can make decisions more reliable.

Key terms: prompt sampling, independent generations, aggregation, selection method

8.1 Sampling fundamentals

This section explains why a single response may be insufficient and defines prompt sampling as generating and combining multiple responses.

Key terms: single generation, sample, probability distribution, prompt sampling, independent responses, aggregates

8.1.1 Temperature and diversity

Explains how temperature affects the diversity and quality of outputs used in prompt sampling.

Key terms: temperature, output variability, aggregation, moderate temperature

8.1.2 Sample size

This subsection gives starting sample sizes for different tasks and explains when to use fewer or more generations.

Key terms: generations, categorical, convergence tasks, numerical smoothing, lower bound, upper bound

8.1.3 Sampling in practice

Shows how to sample responses without code and choose a technique based on the kind of output needed.

Key terms: sampling, independent chats, generations, mean, mode, self-consistency, best-of-N

8.2 Mean

This section explains when averaging multiple prompt outputs is useful and when another sampling method is a better fit.

Key terms: mean, numeric outputs, outlier, mode, best-of-N

8.2.1 Practical example: Runbook quality scoring

A runbook-scoring example shows how to average independent numerical ratings and use their spread when judging release readiness.

Key terms: scoring prompt, independent responses, arithmetic mean, operational score, mean, spread, ambiguity signal, mode

8.3 Mode

This section explains how mode selects a categorical label from multiple generated responses and when that choice is useful.

Key terms: mode, categorical outputs, majority voting, single label, vote distribution, confidence signal, mean, best-of-N

8.3.1 Practical example: Alert severity routing

This example shows how to route an alert by voting across independent severity classifications and how to interpret the vote split.

Key terms: mode, label-only classification prompt, majority label, vote split, clear majority, human review, single-label outputs, self-consistency

8.4 Self-consistency

This section explains when to use self-consistency to assess whether independently generated full responses reach the same substantive conclusion.

Key terms: self-consistency, independent generations, substantive conclusion, mode, mean

8.4.1 Practical example: Incident root-cause draft

This example shows how to compare multiple incident root-cause drafts for agreement while flagging causal claims the notes do not establish.

Key terms: self-consistency, independent drafts, shared comparison fields, trigger, impact, corrective action, causal framing, divergence, incident notes

8.4.2 Checking self-consistency

This section shows how to compare independent responses for self-consistency, assess their agreement, and decide what to do when they diverge.

Key terms: self-consistency, independent responses, structured comparison view, shared conclusion, divergences, confidence, best-of-N, predefined criteria

8.5 Best-of-N

Explains when to use best-of-N sampling, how to select a complete response, and why selection criteria should be set in advance.

Key terms: best-of-N, full candidates, rubric, mode, mean, criteria, anchor

8.5.1 Practical example: Deployment status update for executives

This section demonstrates how to use best-of-N sampling to choose an executive deployment update against criteria set in advance.

Key terms: best-of-N, candidates, criteria, rubric, auditability, clarity, leadership tone, concrete mitigation, update commitment, release safety framing

8.6 When to use sampling

This section explains when sampling is worth its added generation cost and why sampled outputs still need human review before operational use.

Key terms: sampling, high consequence classification or routing, numerical scoring, open-ended outputs, generation cost, signal reliability, human review, aggregated scores, majority labels, selected candidates

8.6.1 Hands-on practice

This hands-on section asks readers to apply prompt-sampling methods to software-engineering tasks and justify which method fits each type of output.

Key terms: mode, mean, severity-classification prompt, numeric scoring prompt, self-consistency, best-of-N, convergent conclusions, predefined criteria, sampling method, numeric

8.7 Summary

The section summarizes how prompt sampling improves reliability, how to choose a sampling technique, and when uncertain results call for more sampling or escalation.

Where this is used later

Concepts explained in this chapter

← Chapter 7: Contextual prompting Chapter 9: Advanced prompt patterns →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.