liveBook · Manning

Temperature

As explained in Spring AI in Action

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

Temperature scales token probabilities during generation. Lower values make responses more deterministic; higher values make token probabilities more even and responses more random. section 3.4.1

Configuring temperature

Set temperature globally with spring.ai.openai.chat.options.temperature=0.7, or configure ChatOptions programmatically with .temperature(0.7). section 3.4.1

ChatOptions chatOptions = ChatOptions.builder()
    .temperature(0.7)
    .build();

Use the ChatOptions listing to apply temperature when constructing generation options. section 3.4.1

How Spring AI in Action covers it

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.
How it connects
Connects token probabilities with Top-P, Top-K, ChatOptions, ChatClient, and application properties.

Also explained in

Compare how 17 books explain temperature →

Related concepts

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