Skip to content
AgenticAIWiki
  1. Learn
  2. Part 1
  3. 6. Sampling
  4. 6.4

Lesson 6.4 · 4 of 5 · 4 min read · Reviewed 24 Nov 2026

Picking settings for extraction vs creative work

By the end, you can

  • Choose sampling settings for extraction and creative work.
  • Rely on prompts and validation more than settings.

Two task types

Extraction, classification, grading Creative writing, ideas
Sampling settings (on models that have them) Low temperature Near default
On current Claude models Leave sampling out; use effort and clear criteria Ask for several distinct options
Output format Tool use or structured outputs Free text
Candidates One Several, then pick or combine
Checks Schema validation, evals Human review, rubric grader

Beyond settings

Consistency mostly comes from:

  1. Clear criteria and label definitions (chapter 11)
  2. Examples of edge cases (chapter 12)
  3. Structured outputStructured outputs: Making a model return data that matches a defined schema, such as JSON with required fields and types. so the shape never varies (chapter 14)
  4. Validation with retry (chapter 14)
  5. EvalsEval: A repeatable test that measures how well an AI system performs on a set of cases with defined success criteria. to measure it (Part 3)

Generating variety on purpose

For brainstorming, ask for several distinct options in one call (“give 5 different taglines, each with a different angle”), or make several calls and pick the best with a graderGrader: The part of an eval that decides whether an output passes, using code, a model or a person.. Each call varies a little on its own.

Self-consistency

For hard reasoning, sample several answers and take the most common one (votingParallelization: A workflow pattern that runs several LLM calls at once, either on separate subtasks or as multiple votes on one task., chapter 41). This uses variation as a strength.

Key points

  • Extraction and classification: clear criteria, structured output, validation (and low temperature on models that offer it).
  • Creative work: higher temperature, maybe several candidates to choose from.
  • Settings are a small lever; clear prompts, examples and checks matter more.
Hands-on labRuns in the Playground

Measure label consistency across repeated runs

Turn 'it sometimes picks different labels' into a number, and compare a vague prompt with a clear one.

You will have: A consistency report: agreement rate per prompt version and the list of unstable tickets.

Steps

  1. Run the starter: it prints the raw labels from five runs of each ticket.
  2. Fill in agreement(): the share of runs that match the most common label for that ticket.
  3. Average it over tickets for prompt v1 (vague) and v2 (clear labels, examples, schema).
  4. List tickets where agreement is below 0.8.
  5. Decide which prompt to ship and write the reason in one line.

Done when

  • v1 agreement prints 0.64 and v2 prints 0.96.
  • Unstable tickets for v1 include t2, t3 and t5.
  • The script recommends v2.

Open in the Playground No API key needed.

Starter code (Python)
from collections import Counter
RUNS = {  # five recorded runs per ticket, for two prompt versions
    "v1": {"t1": ["billing"] * 5, "t2": ["billing", "account", "billing", "account", "other"],
           "t3": ["shipping", "returns", "shipping", "returns", "returns"], "t4": ["account"] * 4 + ["billing"],
           "t5": ["other", "account", "other", "billing", "account"]},
    "v2": {"t1": ["billing"] * 5, "t2": ["account"] * 5, "t3": ["returns"] * 4 + ["shipping"],
           "t4": ["account"] * 5, "t5": ["other"] * 5},
}

def agreement(labels):
    return 0.0  # TODO: count of the most common label divided by the number of runs

for version, tickets in RUNS.items():
    scores = {t: agreement(l) for t, l in tickets.items()}
    print(version, "mean agreement:", round(sum(scores.values()) / len(scores), 2))
    # TODO: print tickets with agreement below 0.8
# TODO: print which version to ship
Show a solution
from collections import Counter
RUNS = {
    "v1": {"t1": ["billing"] * 5, "t2": ["billing", "account", "billing", "account", "other"],
           "t3": ["shipping", "returns", "shipping", "returns", "returns"], "t4": ["account"] * 4 + ["billing"],
           "t5": ["other", "account", "other", "billing", "account"]},
    "v2": {"t1": ["billing"] * 5, "t2": ["account"] * 5, "t3": ["returns"] * 4 + ["shipping"],
           "t4": ["account"] * 5, "t5": ["other"] * 5},
}

def agreement(labels):
    return Counter(labels).most_common(1)[0][1] / len(labels)

means = {}
for version, tickets in RUNS.items():
    scores = {t: agreement(l) for t, l in tickets.items()}
    means[version] = sum(scores.values()) / len(scores)
    print(version, "mean agreement:", round(means[version], 2))
    print("  unstable:", sorted(t for t, s in scores.items() if s < 0.8))
best = max(means, key=means.get)
print(f"ship {best}: labels repeat on {means[best]:.0%} of runs")
Quick checkYour ticket classifier sometimes picks different labels for the same ticket. What's the best set of changes?
How sure are you?
Pick an answer and how sure you are