liveBook · Manning

Variance

As explained in Build Python Web Apps with Streamlit

Variability is the degree to which a model produces different outputs for the same or similar inputs.

Variance describes how much an AI model’s responses can differ when given the same or similar input. Regular code tends to repeat the same result; a large language model produces probabilistic outputs instead. That variability can help or hurt, depending on the task. section 9.6.1

Choose the desired level of variance according to the application:

  • Favor higher variance for creative tasks such as generating poetry. section 9.6.1
  • Favor lower variance when evaluating a mathematical equation, where predictable responses matter more. section 9.6.1
  • For generated questions, increase variety while preventing repeated questions within and across games. section 9.6.1
Figure 9.10 How temperature and top_p affect the creativity and predictability of an LLM’s output.

Compare how temperature and top_p affect the creativity and predictability of a model’s output. section 9.6.1

Model vendors expose controls for managing variance, but prompt engineering is also needed to encourage the desired behavior. Greater variance does not guarantee better answers: probabilistic generation can produce plausible but incorrect or fabricated information. section 9.6.1

How Build Python Web Apps with Streamlit covers it

How deep it goes
Defines probabilistic variability and discusses controls, but stops short of detailed control implementation.
Examples
Uses poetry, mathematical evaluation, and repeated trivia questions to contrast creative and predictable outputs.
What you can do after
Apply it via model variability controls and prompt engineering to shape creative or predictable responses.
How it connects
Connects variance with large language models, prompt engineering, temperature, top_p, and hallucinations.

Also explained in

Compare how 19 books explain variance →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.