Rubric
Contents — domains, guide and mocks

LLM fundamentals

CCDV-F 5.114 min read · checked 21 September 2026

Task statementLLM Fundamentals (5.2%) — tokens, context windows, sampling, non-determinism, next-token generation, model options including extended and adaptive thinking, and zero-, single- and multi-shot prompting

Next-token generation

  1. Read the contextsystem prompt, messages, tools, text so far
  2. Score next tokensa probability for every candidate
  3. Sample onechoose from that distribution
  4. Append itit becomes part of the context

repeat until a stop condition — then report stop_reason

Each new token is chosen with everything before it in view, then becomes part of what the next choice sees. Nothing is planned in advance and nothing is revised.

Tokens are the unit everything is measured in

A token is a fragment of text — commonly a short word, part of a longer word, or a piece of punctuation. The model never sees characters or words directly; it reads and writes tokens. That matters to you for three practical reasons: tokens are what you are billed for, tokens are what rate limits count, and tokens are what the context window is measured in. Every response reports the count in its usage field, so you never have to guess after the fact.

Do not estimate token counts from character counts in production code. Text in other languages, code, JSON and base64-encoded images all tokenise at very different rates. The API exposes a token-counting endpoint for measuring a request before you send it — that, and usage on the response, are covered in 5.4.

The context window is a budget, not a memory

The context window is the total text the model can reference while generating a response — including the response. The documentation is explicit about what counts toward it: the system prompt, every message in messages including tool results, images and documents, your tool definitions, and the output Claude generates, extended thinking included. Cached content counts too; caching changes what you pay, not what fits.

What fills the context window

all of this shares one budget

  1. System promptinstructions, persona, policy
  2. Tool definitionsevery schema you attached, on every call
  3. Conversation historyall previous turns, kept in full
  4. Current messagethe user's turn, documents, images
  5. The model's outputtext and thinking tokens
Every layer competes for the same budget. Tool definitions and accumulated history are the two that grow without anyone deciding to grow them.

There is no memory between requests. A conversation feels continuous only because your code resends the whole history every time, so a long chat costs more per turn than a short one even though the user typed the same amount. Each turn's output becomes part of the next turn's input.

FailureWhat the API doesWhat to do
Input alone exceeds the window400 invalid_request_error — “prompt is too long”Trim history or documents before sending
Input plus max_tokens exceeds itOn recent models the request is accepted; generation stops with stop_reason model_context_window_exceededTreat the reply as truncated, not finished
Output hits your own max_tokensstop_reason of max_tokensRaise the limit or continue the turn

Sampling and non-determinism

Having scored every candidate for the next token, the model has to choose one. Choosing the highest-scoring token every time makes output repetitive; choosing from the distribution makes it varied. The classic controls are temperature — flattening or sharpening the distribution — and the nucleus and top-k cutoffs top_p and top_k, which limit how far down the ranked list a choice can come from. The documented advice for temperature is to sit closer to 0.0 for analytical work and closer to 1.0 for creative work, and to adjust one of temperature or top_p, not both at once.

The critical sentence is in the API reference: results are not fully deterministic even at temperature 0.0. Low temperature narrows variation; it does not remove it. Anything in your system that requires an exact repeat of a previous answer — a test that asserts on an exact string, a cache keyed on output, a workflow that assumes the same category name twice — is built on a promise the model does not make.

Designing for a non-deterministic component

Assumes determinism

  • A test asserting the exact output string
  • Parsing a fixed phrase out of prose
  • One run treated as proof a prompt works
  • A cache keyed on the model's answer

Designs for variation

  • Assert on structure and required fields
  • Constrain the output shape, then validate it
  • Evaluate a prompt over a set of runs
  • Cache the input; re-derive the output
Notice that none of the right-hand column is prompt work. Non-determinism is handled in the code around the model.

Thinking: extended and adaptive

Thinking lets the model produce reasoning tokens before its answer. Those tokens appear as thinking blocks, count toward max_tokens, and are billed as output. There are two modes, and the exam cares about which one a given model takes.

Extended thinkingAdaptive thinking
Request fieldthinking: {type: "enabled", budget_tokens: N}thinking: {type: "adaptive"}
Depth controlbudget_tokens, minimum 1,024output_config: {effort: …}
Thinks on every request?YesNo — it may skip easy inputs
Where it appliesClaude 4.5 and earlierClaude 4.6 and newer models
Both modes, side by sidepython
# Extended thinking: you set a fixed budget, in tokens.
resp = client.messages.create(
    model=MODEL, max_tokens=16000,
    thinking={"type": "enabled", "budget_tokens": 10000},  # min 1024, < max_tokens
    messages=messages,
)

# Adaptive thinking: Claude decides how much to think; you set the effort level.
resp = client.messages.create(
    model=MODEL, max_tokens=16000,
    thinking={"type": "adaptive"},
    output_config={"effort": "high"},   # low | medium | high (and higher levels)
    messages=messages,
)

# Either way, reasoning arrives as its own block type.
for block in resp.content:
    if block.type == "thinking":
        pass                                    # internal reasoning
    elif block.type == "text":
        print(block.text)                       # the answer you show the user
print(resp.usage.output_tokens_details.thinking_tokens)

Two behaviours catch people out. Under adaptive thinking, a request may come back with no thinking block at all — that is the mode working, not a failure, and code that expects a thinking block first will break on it. And whether earlier turns' thinking stays in context depends on the model: newer models keep previous thinking blocks, where they are billed as input on later requests, while others strip them automatically. Your token budget therefore depends on the model, not only on your prompt.

Zero-, single- and multi-shot prompting

Since every token is chosen in the light of everything before it, examples in the prompt are an unusually direct lever: they show the model the shape of the answer instead of describing it. Zero-shot gives instructions alone. Single-shot adds one worked example. Multi-shot — few-shot — adds several, and the documentation recommends three to five for best results, wrapped in <example> tags inside an <examples> block so the model can tell them apart from instructions.

Zero-shot versus multi-shot on the same task

Zero-shot — shape left to chancetext

Categorise this support email by
urgency and topic.

"My card was declined twice and
I have a flight tomorrow."

Multi-shot — shape demonstratedtext

Categorise support email by urgency
and topic.
<examples>
<example>
Email: Password reset link expired.
Output: {"urgency":"low",
 "topic":"account"}
</example>
<example>
Email: Charged twice for one order.
Output: {"urgency":"high",
 "topic":"billing"}
</example>
</examples>
The instruction is identical in both. The examples do the work of a schema, a tone guide and an edge-case rule at once.

Good examples are relevant — they mirror the real inputs — and diverse, so the model does not generalise a pattern you never intended. If every example you supply happens to be a billing complaint, expect billing to be over-predicted. Deliberately include the edge cases you care about; an example is the cheapest way to state a rule you would otherwise have to write three sentences about.

Traps the wrong answers are built from

Tempting but wrongDo this instead
Expecting identical output from identical inputAssert on structure, and evaluate prompts over several runs.
Estimating tokens from character countsCount tokens with the API and read usage on every response.
Treating a truncated reply as a finished answerCheck stop_reason for max_tokens or model_context_window_exceeded.
Raising budget_tokens without raising max_tokensThinking comes out of the output budget; raise both together.
Supplying examples that are all the same kind of inputUse three to five relevant, deliberately diverse examples.

You should now be able to

  • Explain next-token generation and say which application behaviours follow from it.
  • Account for everything that consumes the context window, and diagnose a “prompt is too long” failure.
  • Describe what temperature, top_p and top_k do, and why output is never fully deterministic.
  • Choose between extended and adaptive thinking, and configure budget_tokens or effort correctly.
  • Decide when zero-, single- or multi-shot prompting is appropriate and structure examples well.

Practice questions

Original questions written for this lesson, in the exam’s style. Answer first, then open the reasoning — every option is explained, including why the wrong ones are tempting.

  1. Question 1

    A document-review tool is tested with temperature set to 0.0 so results can be compared between builds. The test suite asserts that a given contract always produces one exact summary string. It passes locally and fails intermittently in CI.

    What is the underlying problem?

    1. AThe CI environment is sending a different system prompt to the model.
    2. BOutput is never fully deterministic, even at temperature 0.0.
    3. Ctemperature must be paired with top_p set to 0.0 for determinism.
    4. DThe request needs a fixed random seed so generation can be repeated.
    Show answer and reasoning
    1. AIncorrect. Possible in principle, but the documented behaviour already explains the symptom without it.
    2. BCorrect. The API reference states this directly; low temperature narrows variation rather than removing it, so exact-match assertions are unsound.
    3. CIncorrect. Adjusting both together is explicitly discouraged, and no combination is documented as fully deterministic.
    4. DIncorrect. The documented request parameters do not include a seed for this purpose.
  2. Question 2

    A chat assistant works well for short sessions. After about forty turns, requests begin failing with a 400 error whose message says the prompt is too long. The user's messages are short throughout.

    Which two changes address the cause? (Select 2.)

    1. ASummarise or drop older turns before sending the request.
    2. BAttach only the tool definitions the session actually needs.
    3. CLower max_tokens so the response fits alongside the history.
    4. DRetry the request with exponential backoff.
    5. EEnable prompt caching for the system prompt and tool definitions.
    6. FSwitch to a lower effort level to shorten the reasoning.
    Show answer and reasoning
    1. ACorrect. History is resent in full on every call, so it is the term that grows; trimming it is the direct fix.
    2. BCorrect. Tool schemas count toward the window on every request whether or not a tool is used.
    3. CIncorrect. A smaller output budget does not help when the input alone already exceeds the window.
    4. DIncorrect. The same request will be the same length next time; this is not a transient failure.
    5. EIncorrect. Caching reduces cost and latency, but cached content still counts toward the context window.
    6. FIncorrect. It trims output tokens, not the oversized input that caused the error.
  3. Question 3

    A team migrates a summarisation service to a model that supports adaptive thinking. Their code reads response.content[0].thinking before formatting the answer. After the migration, some requests raise an attribute error.

    What explains the failures?

    1. AAdaptive thinking returns its reasoning in the usage object instead of a content block.
    2. BThe budget_tokens value is too low, so the thinking block is dropped.
    3. CUnder adaptive thinking Claude may skip thinking entirely, so no thinking block is returned.
    4. DThinking blocks from previous turns were stripped, removing the current one.
    Show answer and reasoning
    1. AIncorrect. usage reports the token count of reasoning, not its content.
    2. BIncorrect. budget_tokens belongs to extended thinking; under adaptive thinking depth is set by effort.
    3. CCorrect. Adaptive mode decides per request whether reasoning is warranted; code must handle its absence.
    4. DIncorrect. Stripping applies to earlier turns' blocks, not to the block generated in the current response.
  4. Question 4

    A retailer classifies product reviews into five sentiment-and-topic buckets. The prompt names the five buckets and describes each in a sentence. Output quality is inconsistent and new bucket names keep appearing.

    What is the most effective next step?

    1. AAdd three to five diverse worked examples in an <examples> block.
    2. BAdd one carefully chosen example covering the most common review type.
    3. CRewrite each bucket description at greater length and detail.
    4. DLower the temperature so the model picks the likeliest label.
    Show answer and reasoning
    1. ACorrect. Examples demonstrate the output shape and the edge-case rules that prose descriptions leave ambiguous; three to five is the documented recommendation.
    2. BIncorrect. Better than none, but a single example invites the model to generalise that one case.
    3. CIncorrect. More prose about categories does not constrain the output shape the way an example does.
    4. DIncorrect. It narrows variation slightly and is deprecated on current models; it does not teach the output format.

Sources

Drafted with AI assistance and checked against the sources above; expert review is in progress. Spotted an error? Tell us and it gets fixed, dated and listed on how this is written.