liveBook · Manning

Nondeterminism

As explained in Generative AI in Action

Nondeterminism is the property that repeated executions with the same apparent inputs can produce different outputs rather than a single fixed result.

Nondeterminism means that repeated executions with the same apparent inputs can produce different outputs. Generative models exhibit this behavior because randomness influences generation, especially at higher temperature settings. section 6.7 section 6.5

Manage nondeterministic generation according to the application:

  • Use lower temperature for predictable work such as invoice generation, proposals, and code generation. section 3.2.4
  • Use higher temperature when diverse or creative outputs matter, such as marketing content, stories, poems, lyrics, and jokes. section 3.2.4
  • Evaluate outputs critically, apply content filtering where appropriate, and check generated images for errors, artifacts, and sensitive implications. section 6.7 section 6.5

Varying completion temperature

A completion request can set temperature=0.8 and n=3 to obtain several creative responses in one call. Lowering temperature to 0.2 produces more similar responses, while 1.8 can produce increasingly incoherent or nonsensical text. section 3.2.4

response = client.completions.create(
    model="gpt-35-turbo",
    prompt=prompt_startphrase,
    temperature=0.8,
    max_tokens=100,
    n=3,
    stop=None)

Inspect the completion call that requests three responses while exposing the temperature setting controlling output variation. section 3.2.4

How Generative AI in Action covers it

How deep it goes
Defines repeated-run variation and demonstrates temperature effects, but does not derive the underlying generation mathematics.
Examples
Uses repeated text completions at temperatures 0.8, 0.2, and 1.8, plus image prompts producing varied generated images.
What it assumes
Assumes familiarity with generative-model prompting and API calls while defining nondeterminism through observable output variation.
What you can do after
Apply temperature and sampling-count settings, then evaluate generated text or images for consistency, quality, and risk.
How it connects
Connects nondeterminism to temperature, generative models, prompt engineering, content filtering, and image prompting.

Also explained in

Compare how 3 books explain nondeterminism →

Related concepts

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