liveBook · Manning

Temperature

A temperature parameter controls the spread of a probability distribution or the likelihood of selecting less-favored alternatives in stochastic sampling or search.

How 20 Manning books explain it

Optimization Algorithms: AI techniques for design, planning, and control problems

A simulated-annealing control value that influences the likelihood of accepting worsening state transitions.

How it is used
Controls acceptance of worsening moves to balance exploration and exploitation in simulated annealing.
How deep it goes
Explains the acceptance calculation, initial-temperature heuristic, cooling parameters, and adaptive reheating.
Examples
Works through a bounded quadratic minimization with a rejected move and geometric cooling, then configures a Python implementation.
What you can do after
Operate/configure simulated annealing by selecting temperatures and a cooling schedule, and evaluate whether worsening moves are accepted.

Read how Optimization Algorithms: AI techniques for design, planning, and control problems explains temperature →

Natural Language Processing in Action, Second Edition

Temperature is a decoding parameter that rescales token scores to control the randomness of a generated distribution.

How it is used
Controls randomness during token generation and supports repeated trials of chatbot responses.
How deep it goes
Explains temperature through ranked token choices and configuration, without deriving the score-rescaling formula.
Examples
Uses ranked next-token choices, a GPT-2 generation example, and a math-tutor chatbot configuration.
What you can do after
Apply it via LangChain and Replicate to vary chatbot responses, then evaluate repeated outputs against project goals.

Read how Natural Language Processing in Action, Second Edition explains temperature →

Build a Reasoning Model (From Scratch)

A token sampling method that draws from a probability distribution after temperature rescaling to control randomness.

How it is used
Prepares next-token probabilities for inference-time top-p filtering.
How deep it goes
Demonstrates scaling at temperature 1.0 and softmax, then shifts to top-p filtering rather than detailing temperature choices.
Examples
Uses ten-entry toy logits, a probability bar plot, and a temperature-1.0 PyTorch pipeline.
What you can do after
Apply it via PyTorch by scaling next-token logits and converting them to probabilities before filtering.

Read how Build a Reasoning Model (From Scratch) explains temperature →

Build a DeepSeek Model (From Scratch)

Temperature is a scalar parameter that controls the sharpness of a probability distribution produced from model logits.

How it is used
Softens teacher and student outputs in classical knowledge distillation to expose relationships among alternative classes.
How deep it goes
Works through scaled softmax numerically and implements the combined distillation loss with gradient compensation.
Examples
Compares four animal-class logits at T=1, T=3, and T=10.
What you can do after
Apply it via PyTorch to construct temperature-scaled teacher and student targets in a distillation loss.

Read how Build a DeepSeek Model (From Scratch) explains temperature →

Build Python Web Apps with Streamlit

Temperature is a language-model sampling parameter that controls how broadly probability is spread across possible next tokens.

How it is used
Uses temperature to encourage varied questions in a multi-question trivia application.
How deep it goes
Explains token-probability effects and implements optional API arguments without deriving the sampling mathematics.
Examples
Demonstrates temperature=0.7 and top_p=0.9 alongside a time-based seed and prior questions in a trivia game.
What you can do after
Apply it via the OpenAI Python library to influence response variability when the selected model supports the setting.

Read how Build Python Web Apps with Streamlit explains temperature →

Generative AI in Action

Temperature is a model-generation setting that controls the degree of randomness in the model's output distribution.

How it is used
Uses temperature to balance output variety and predictability across enterprise generation tasks.
How deep it goes
Defines randomness control and compares settings through repeated completions without a mathematical derivation.
Examples
Compares pet-salon name suggestions at temperatures 0.2, 0.8, and 1.8 using a completions API call.
What you can do after
Operate/configure temperature per API call and compare multiple responses for a chosen use case.

Read how Generative AI in Action explains temperature →

Data Analysis with LLMs

Temperature is a model-generation setting that controls the degree of stochastic variation in selecting output tokens from their probability distribution.

How it is used
Controls output variation in chat completions, from creative stories to repeatable sentiment classification.
How deep it goes
Explains the effect on token selection, the 0–2 range, and practical trade-offs without deriving model internals.
Examples
Uses a GPT-4o story call at 1.5 and a GPT-3.5 Turbo review classifier at 0.
What you can do after
Apply it via OpenAI’s Python library to increase story variation or minimize randomness in classification.

Read how Data Analysis with LLMs explains temperature →

Effective Conversational AI

Temperature is a generation parameter that controls the degree of randomness in a language model's token selection.

How it is used
Uses temperature with sampling decoding to broaden chatbot intent examples and increase generated-response creativity.
How deep it goes
Defines temperature as a randomness and diversity control, but stops short of explaining its implementation or numerical scale.
Examples
Generates password synonyms, verb phrases, and transcript summaries while illustrating useful variation alongside oddities and hallucination risk.
What you can do after
Apply it via sampling-decoding settings to trade deterministic repetition for creative variation, then review outputs for relevance and hallucinations.

Read how Effective Conversational AI explains temperature →

Building Reliable AI Systems

Temperature is a language-model generation parameter that controls the randomness of token selection.

How it is used
Uses temperature to balance response predictability and variety in language-model applications.
How deep it goes
Explains next-token probability effects and API configuration, without deriving the sampling formula.
Examples
Contrasts iPhone specification responses at 0.3 and 0.8 and uses 0.2 in a health-care policy assistant.
What you can do after
Apply it via the Anthropic Python library, choosing a supported value for the desired response variability.

Read how Building Reliable AI Systems explains temperature →

Deep Learning with R, Third Edition

Temperature is a generation parameter that controls the concentration or spread of a model's next-token probability distribution.

How it is used
Controls diversity during autoregressive text generation by adjusting how broadly next-token sampling explores the model distribution.
How deep it goes
Explains logits, softmax concentration, generated-output effects, and combination with top-k, without deriving the probability transformation.
Examples
Uses generated text at temperatures 0.2, 0.8, and 2, plus combined top-k examples with k values of 5 and 20.
What you can do after
Apply it via a random sampling function and tune generation between repetitive low-temperature output and erratic high-temperature output.

Read how Deep Learning with R, Third Edition explains temperature →

Machine Learning Platform Engineering

Temperature is a generation setting that adjusts how strongly token selection favors high-probability alternatives.

How it is used
Controls response variability and informs testing strategy for production LLM applications.
How deep it goes
Defines zero and higher-temperature behavior, then stops short of guaranteeing reproducible outputs.
Examples
Compares 0.0, 0.7, and 1.5 settings and configures Gemini 2.5 Flash with zero temperature.
What you can do after
Configure Gemini through LangChain and evaluate variable responses without relying on exact string matches.

Read how Machine Learning Platform Engineering explains temperature →

Build a Large Language Model (From Scratch)

A decoding method that rescales next-token probabilities with a temperature to make sampling more or less random.

How it is used
Controls diversity during autoregressive text generation alongside optional top-k filtering.
How deep it goes
Implements logit scaling, softmax conversion, and multinomial sampling, while deferring systematic setting combinations to exercises.
Examples
Demonstrates a 15-token continuation using temperature 1.4 and top-k 25, contrasting it with a memorized passage.
What you can do after
Apply it via a modified generate function and compare outputs across temperature and top-k settings.

Read how Build a Large Language Model (From Scratch) explains temperature →

AI Agents in Action, Second Edition

How it is used
Tunes generation behavior to trade off creativity and consistency for an agent’s role.
How deep it goes
Explains temperature’s effect on token probabilities and sampling, gives role-based settings, and cautions that zero does not guarantee identical outputs.
Examples
Contrasts coder and creative-writer settings, then shows a temperature-zero research planner whose final task varies slightly across runs.
What you can do after
Configure agent temperature for more consistent or more varied generation, and assess repeatability across runs.

Read how AI Agents in Action, Second Edition explains temperature →

Spring AI in Action

Temperature is a language-model generation parameter from 0 to 2 that scales token probabilities to control response randomness.

How it is used
Controls randomness in language-model token selection during chat generation.
How deep it goes
Defines the 0-to-2 range and behavioral effect without deriving the probability-scaling mathematics.
Examples
Uses candidate words with decreasing probabilities and shows global or programmatic configuration at 0.7.
What you can do after
Apply it via ChatOptions or application.properties to tune generation randomness.

Read how Spring AI in Action explains temperature →

Build an Advanced RAG Application (From Scratch)

Temperature is a decoding parameter that controls the sharpness of a language model's next-token probability distribution.

How it is used
Controls randomness and diversity when probabilistically decoding the next token from a language model.
How deep it goes
Defines log-probability scaling and directional effects, but stops short of implementation code or parameter-selection procedures.
Examples
Contrasts high-temperature creative output with low-temperature deterministic output and near-zero behavior approaching greedy decoding.
What you can do after
Apply it via decoder settings to trade predictable generation against creative diversity and output risk.

Read how Build an Advanced RAG Application (From Scratch) explains temperature →

Transformers in Action

Temperature sampling is a sampling strategy that adjusts the sharpness of a token probability distribution before selecting the next token.

How it is used
Controls randomness and output diversity during token selection for text generation.
How deep it goes
Explains logit adjustment, softmax sharpness, limiting behavior, and a Transformers implementation, without deriving the formula.
Examples
Uses a Transformers generate() listing with temperature 0.7, three returned sequences, and a generated AI-researcher continuation.
What you can do after
Apply it via Transformers to produce more focused or more diverse text continuations.

Read how Transformers in Action explains temperature →

The Complete Obsolete Guide to Generative AI

Temperature is a generation parameter that controls the randomness or diversity of a language model's output.

How it is used
Adjusts generation randomness to match a prompt’s desired creativity, focus, tone, verbosity, or cost.
How deep it goes
Defines the setting, gives its 0–2 range and default, and demonstrates contrasting outputs without explaining sampling internals.
Examples
Demonstrates restaurant recommendations at 1.3 and 0.2, plus a creative story prompt using 0.8.
What you can do after
Operate temperature through the OpenAI Playground and transfer tested settings into API code.

Read how The Complete Obsolete Guide to Generative AI explains temperature →

Build Applications with Local AI Models on a Mac

A language-model generation setting that controls the randomness of token selection.

How it is used
Controls response variation through a chatbot or voice-assistant slider.
How deep it goes
Explains next-token selection and compares temperature values, while reserving other generation parameters for finer tuning.
Examples
Compares sunset descriptions generated at 0.0, 0.7, and 1.5.
What you can do after
Operate/configure a Streamlit slider to send a chosen temperature with each Ollama chat request.

Read how Build Applications with Local AI Models on a Mac explains temperature →

Machine Learning Algorithms in Depth

A temperature parameter is a positive scaling value that controls the probability of accepting unfavorable transitions in simulated annealing.

How it is used
Controls acceptance of higher-energy transitions during simulated annealing.
How deep it goes
Explains acceptance behavior and cooling, but does not derive the transition-probability formula in the supplied description.
Examples
Uses an energy-minimization search with a cooling schedule that multiplies temperature by 0.9.
What you can do after
Apply it by controlling acceptance of higher-energy proposals and lowering temperature with a cooling schedule.

Read how Machine Learning Algorithms in Depth explains temperature →

Context Engineering

An inference parameter that controls the randomness of token selection during generation.

How it is used
Controls token-selection randomness during inference, making generated outputs more deterministic or diverse.
How deep it goes
Defines the scalar, typical provider-dependent ranges, and low-versus-high effects, but gives no tuning procedure.
What you can do after
Configure inference-time randomness by choosing lower settings for more deterministic output or higher settings for greater diversity.

Read how Context Engineering explains temperature →

Also covered in

What to know first

Related concepts

Questions about temperature

What is temperature?

A temperature parameter controls the spread of a probability distribution or the likelihood of selecting less-favored alternatives in stochastic sampling or search.

Which Manning books explain temperature?

Optimization Algorithms: AI techniques for design, planning, and control problems, Natural Language Processing in Action, Second Edition, Build a Reasoning Model (From Scratch), Build a DeepSeek Model (From Scratch), Build Python Web Apps with Streamlit, Generative AI in Action, Data Analysis with LLMs, Effective Conversational AI and 12 more.

What should I know before learning temperature?

Manning books that teach temperature usually introduce language model, prompt, probability distribution and token first.

What is temperature a kind of?

Temperature is a kind of hyperparameter. A hyperparameter is a setting chosen outside ordinary parameter learning that controls a model, algorithm, or learning procedure.

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.