VISUAL LESSON · 12 PICTURES

Temperature Scaling, Top-k & Nucleus (Top-p) Sampling

How do temperature scaling, top-k filtering, and nucleus (top-p) sampling mathematically reshape probability distributions to eliminate repetitive loops and hallucinated tail tokens?

Progress stays on this device · no login
BEFORE THE FIRST PICTURE

How this lesson unfolds.

Begin with How do thermodynamic temperature scaling and cumulative probability thresholds balance creative diversity with factual stability?. Follow the visual diagrams to build an intuitive, mathematically grounded mental model of temperature scaling, top-k & nucleus sampling.

Picture 1 of 12 · tap to inspect in full resolution
01

How does temperature scaling physics sampling operate mathematically within the overall Temperature Scaling, Top-K & Nucleus Sampling?

INTUITION

Imagine heating up water molecules in a pot. At near absolute zero (Temperature -> 0), the water freezes solid into ice (pure deterministic greedy choice). As you turn up the burner (Temperature = 1.0), molecules move freely with creative fluidity. Turn the stove to 5.0, and the water boils violently into chaotic vapor.

MATHEMATICAL STATEMENT
  1. $$\mathbf{y} = f(\mathbf{X} \mathbf{W} + \mathbf{b})$$
✦ More context & mechanics
Conceptual Mechanics & Logic

Temperature scaling divides unnormalized logits by scalar T > 0 before computing softmax:

P(wᵢ) = (exp(zᵢ / T)) / (∑ⱼ exp(zⱼ / T))

  • As T → 0, P(w_(max)) → 1.0 (recovering greedy argmax).
  • At T = 1.0, standard model probabilities are preserved unchanged.
  • As T → ∞, P(wᵢ) → 1/V (converging to a uniform distribution).
Real-World Usage

Used in all conversational LLM APIs (OpenAI, Anthropic, Google Gemini). Default temperature is typically 0.7 for conversational chat, 0.2 for coding and reasoning, and 1.0 for creative brainstorming.

History & Origin Story

Borrowed directly from statistical thermodynamics, specifically Ludwig Boltzmann's 1877 Boltzmann distribution Pᵢ ∝ e^(−Eᵢ / k_B T) relating particle states to thermal temperature.

How to Memorize & Golden Words

Temperature does not change logit ranking; it only changes the sharpness of the probability peaks.

Picture 2 of 12 · tap to inspect in full resolution
02

How does bridge temperature scaling physics operate mathematically within the overall Temperature Scaling, Top-K & Nucleus Sampling?

INTUITION

In physics, high temperature gives low-energy particles enough kinetic energy to jump out of deep potential wells. In language models, high temperature gives low-probability words enough probability to jump out from behind the obvious dominant word.

MATHEMATICAL STATEMENT
  1. $$\mathbf{y} = f(\mathbf{X} \mathbf{W} + \mathbf{b})$$
✦ More context & mechanics
Conceptual Mechanics & Logic

The relative probability ratio between two candidate tokens i and j is given by:

(P(wᵢ)) / (P(wⱼ)) = exp((zᵢ - zⱼ) / (T))

When T = 0.5, a logit difference of 2.0 becomes an effective gap of 4.0 (e⁴ ≈ 54.6× preference). When T = 2.0, that same gap shrinks to 1.0 (e¹ ≈ 2.7× preference).

Real-World Usage

Foundational in simulated annealing algorithms, diffusion model score scaling, and temperature-scheduled fine-tuning regimes.

History & Origin Story

Formulated by Kirkpatrick, Gelatt, and Vecchi (1983) in 'Optimization by Simulated Annealing', linking statistical mechanics to discrete optimization.

How to Memorize & Golden Words

Higher temperatures flatten energy landscapes; lower temperatures freeze parameters into the deepest local minimum.

Picture 3 of 12 · tap to inspect in full resolution
03

How does top k truncation filtering probability tail operate mathematically within the overall Temperature Scaling, Top-K & Nucleus Sampling?

INTUITION

Imagine a casting director choosing actors for a role. Instead of considering all 50,000 applicants (including toddlers and pets), the director immediately discards everyone except the top 40 best candidates, and samples among those 40.

MATHEMATICAL STATEMENT
  1. $$\mathbf{y} = f(\mathbf{X} \mathbf{W} + \mathbf{b})$$
✦ More context & mechanics
Conceptual Mechanics & Logic

Top-k filtering sorts logits in descending order, identifies the k-th highest value z^((k)), and sets all logits strictly below this threshold to -∞:

z'ᵢ = zᵢ & if zᵢ ≥ z^((k)) \ -∞ & otherwise

When softmax is computed over z', values with -∞ evaluate to e^(−∞) = 0, completely eliminating the bottom V - k tokens.

Real-World Usage

Standard setting in open-source inference engines (e.g. `topₖ = 40` or `topₖ = 50`), ensuring zero probability is allocated to gibberish tokens.

History & Origin Story

Popularized by Fan, Lewis, and Dauphin (2018) in 'Hierarchical Neural Story Generation', dramatically reducing story degradation.

How to Memorize & Golden Words

Cut the tail with top-k to banish bizarre, catastrophic hallucinations.

Picture 4 of 12 · tap to inspect in full resolution
04

How does nucleus top p sampling cumulative probability threshold operate mathematically within the overall Temperature Scaling, Top-K & Nucleus Sampling?

INTUITION

Instead of always picking a rigid count like 40 people, an elevator captain looks at weight: 'I will keep letting people in until the total weight reaches 90% of capacity, then close the door.' If a sumo wrestler enters (high-probability word), the door closes immediately. If children enter, many can fit.

MATHEMATICAL STATEMENT
  1. $$\mathbf{y} = f(\mathbf{X} \mathbf{W} + \mathbf{b})$$
✦ More context & mechanics
Conceptual Mechanics & Logic

Nucleus (top-p) sampling sorts probabilities in descending order p_((1)) ≥ p_((2)) ≥ ṡ ≥ p_((V)) and finds the minimal subset whose cumulative mass exceeds threshold p ∈ (0, 1):

∑_(i=1)^(k^*) p_((i)) ≥ p

All tokens with rank index > k^ have their logits set to -∞. The set size k^ expands dynamically when the model is uncertain, and contracts to 1 when confident.

Real-World Usage

The gold-standard decoding strategy used across modern AI models (ChatGPT, Claude, LLaMA-3), typically configured with `top_p = 0.9` or `0.95`.

History & Origin Story

Introduced by Ari Holtzman et al. (2019) in 'The Curious Case of Neural Text Degeneration', demonstrating that human text does not follow fixed-k distributions.

How to Memorize & Golden Words

Top-p expands when uncertain and contracts when sure: dynamic probability mass keeps sampling natural.

Picture 5 of 12 · tap to inspect in full resolution
05

How does unified autoregressive generation pipeline operate mathematically within the overall Temperature Scaling, Top-K & Nucleus Sampling?

INTUITION

The complete, polished gearbox of modern text generation: raw logits enter, temperature scales the steepness, top-k trims the distant tail, top-p trims the cumulative fringe, softmax samples the winner, and repetition penalties keep the voice fresh.

MATHEMATICAL STATEMENT
  1. $$\mathbf{y} = f(\mathbf{X} \mathbf{W} + \mathbf{b})$$
✦ More context & mechanics
Conceptual Mechanics & Logic

The complete generation sampling pipeline applies transformations in strict order:

  1. Repetition penalty: zᵢ arrow zᵢ / θ for tokens already in context
  2. Temperature scaling: z arrow z / T
  3. Top-k truncation: mask tokens beyond rank k
  4. Top-p nucleus masking: mask tokens beyond cumulative mass p
  5. Categorical sampling: w_(next) ~ Categorical(softmax(z))
  6. Append and repeat until `<eos>` or max length.
Real-World Usage

Core decoding algorithm embedded in production inference servers such as vLLM, HuggingFace TGI, and llama.cpp.

History & Origin Story

Synthesized through years of open-source community experimentation, merging thermodynamic scaling, statistical filtering, and penalty heuristics.

How to Memorize & Golden Words

Penalty → Temperature → Top-k → Top-p → Softmax → Sample.

Picture 6 of 12 · tap to inspect in full resolution
06

How does temperature scaling simulate physical thermodynamic phase transitions between crystalline order and gas chaos?

INTUITION

Imagine water in a flask. At freezing temperatures (0^∘C, T = 0.05), water molecules lock into a rigid, perfectly ordered ice crystal: there is zero freedom to move, and the lowest energy state is locked in (argmax deterministic generation). At room temperature (20^∘C, T = 0.7), it is a fluid liquid that flows gracefully while maintaining coherence. At boiling heat (100^∘C, T = 3.0), water turns into frantic steam gas: molecules fly randomly in all directions, crashing chaotically into walls (pure random gibberish).

MATHEMATICAL STATEMENT
  1. $$Scale logits by inverse temperature beta = 1/T, proving that T -> 0 freezes into zero-entropy crystalline ground states while T -> inf boils into high-entropy gas states.$$
  • Learning goalDerive the thermodynamic limits of the softmax distribution as T -> 0 and T -> infinity.
  • Helpful foundationsBoltzmann distribution · Limits of exponential functions · A Learning Algorithm for Boltzmann Machines (Ackley, Hinton, Sejnowski, 1985)
  • Common trapSetting T = 0.0 in software directly; evaluating z / 0 produces division-by-zero crashes, so production engines implement T = 0 by switching to an explicit `torch.argmax()` kernel.
  • Next connectionLet's trace this temperature math step-by-step with small toy numbers to see exactly how the decimal probabilities change.
✦ More context & mechanics
Conceptual Mechanics & Logic

In statistical physics, the probability of a particle occupying state with energy Eᵢ at temperature T is governed by the Boltzmann distribution:

Pᵢ = (e^(−Eᵢ / (k_B T))) / (Z)

In language models, logits act as negative energy levels (zᵢ = -Eᵢ / k_B):

qᵢ(T) = (e^(zᵢ / T)) / (∑ⱼ e^(zⱼ / T))

We analyze the thermodynamic limits:

  1. Freezing Regime (T → 0, Absolute Zero):

lim_(T → 0) qᵢ(T) = 1/M & if zᵢ = maxⱼ zⱼ (M-fold degenerate ground state) \ 0 & if zᵢ < maxⱼ zⱼ

Entropy collapses to H → 0. The model selects the argmax token deterministically.

  1. Boiling Regime (T → ∞, Infinite Thermal Energy):

lim_(T → ∞) zᵢ/T = 0 ⟹ e^(zᵢ / T) → 1 ⟹ qᵢ(T) = 1/K

Entropy reaches maximum H → log K. Every word in the 50,000-token dictionary becomes equally likely, producing unreadable noise.

Real-World Usage

LLM serving runtimes (Ollama, vLLM, HuggingFace) expose temperature `T` directly to users: T = 0.0 for SQL query generation, T = 0.7 for assistant chat, T = 1.2 for creative poetry.

History & Origin Story

Ludwig Boltzmann established statistical thermodynamics in 1877. Geoffrey Hinton applied simulated annealing and temperature to Boltzmann Machines in 1985.

How to Memorize & Golden Words
  • Cold (T -> 0) freezes into ice (argmax).
  • Hot (T -> inf) boils into steam (uniform noise).
Picture 7 of 12 · tap to inspect in full resolution
07

How do probability distributions shift across T = 0.5, T = 1.0, and T = 2.0 on a concrete three-logit toy example?

INTUITION

Let's put aside abstract formulas and do elementary arithmetic. Suppose your model outputs three candidate words: 'dog' (logit 2.0), 'cat' (logit 1.0), and 'fish' (logit 0.0). At normal temperature (T = 1), 'dog' gets 66% of the probability pie, 'cat' gets 24%, and 'fish' gets 9%. If you cool it down to T = 0.5, 'dog' surges to a crushing 84% monopoly. If you heat it up to T = 2.0, 'dog' drops to 47%, while 'fish' climbs from 9% to 17%. Watching the numbers move demystifies temperature completely.

  • Learning goalCalculate exact multi-decimal probability vectors across cold, neutral, and hot temperature scaling factors.
  • Helpful foundationsHigh-school exponential calculations · Softmax formula · Statistical Mechanics of Learning (Watkin, Rau, Biehl, 1993)
  • Common trapBelieving temperature changes the rank order of tokens; the argmax token at T=0.5, T=1.0, and T=2.0 is ALWAYS token A, as scaling by positive T strictly preserves order.
  • Next connectionEven with temperature tuned, wild outliers in the long tail can ruin generation. How do we truncate the tail? We compare Top-K vs Nucleus (Top-p) sampling.
✦ More context & mechanics
Conceptual Mechanics & Logic

Consider logits z = [2.0, 1.0, 0.0] for classes [A, B, C].

1. Neutral Temperature (T = 1.0):

  • Scaled logits: z / 1.0 = [2.0, 1.0, 0.0]
  • Exponentials: e^(2.0) ≈ 7.3891, e^(1.0) ≈ 2.7183, e^(0.0) = 1.0000
  • Partition sum: Z = 7.3891 + 2.7183 + 1.0000 = 11.1074
  • Probabilities:
  • P(A) = 7.3891 / 11.1074 = 0.6652 (66.5\%)
  • P(B) = 2.7183 / 11.1074 = 0.2447 (24.5\%)
  • P(C) = 1.0000 / 11.1074 = 0.0900 (9.0\%)

2. Cold Temperature (T = 0.5 — Freezing):

  • Scaled logits: z / 0.5 = [4.0, 2.0, 0.0]
  • Exponentials: e^(4.0) ≈ 54.5982, e^(2.0) ≈ 7.3891, e^(0.0) = 1.0000
  • Partition sum: Z = 54.5982 + 7.3891 + 1.0000 = 62.9873
  • Probabilities:
  • P(A) = 54.5982 / 62.9873 = 0.8668 (86.7\% — dominant peak!)
  • P(B) = 7.3891 / 62.9873 = 0.1173 (11.7\%)
  • P(C) = 1.0000 / 62.9873 = 0.0159 (1.6\% — crushed!)

3. Hot Temperature (T = 2.0 — Boiling):

  • Scaled logits: z / 2.0 = [1.0, 0.5, 0.0]
  • Exponentials: e^(1.0) ≈ 2.7183, e^(0.5) ≈ 1.6487, e^(0.0) = 1.0000
  • Partition sum: Z = 2.7183 + 1.6487 + 1.0000 = 5.3670
  • Probabilities:
  • P(A) = 2.7183 / 5.3670 = 0.5065 (50.7\%)
  • P(B) = 1.6487 / 5.3670 = 0.3072 (30.7\%)
  • P(C) = 1.0000 / 5.3670 = 0.1863 (18.6\% — flattened toward uniform!)
Real-World Usage

This exact arithmetic trace is calculated for every token across 50,000 vocabulary logits on GPU hardware during model inference.

History & Origin Story

This four-decimal worked example serves as the canonical diagnostic check used in unit testing LLM sampling pipelines in PyTorch and Hugging Face Transformers.

How to Memorize & Golden Words
  • Halving temperature squares the odds ratio.
  • Doubling temperature pulls everyone toward a flat 33/33/33 draw.
Picture 8 of 12 · tap to inspect in full resolution
08

How does Nucleus (Top-p) sampling dynamically adapt its truncation pool compared to rigid fixed-size Top-K filtering?

INTUITION

Imagine dining at a buffet with 1,000 dishes. In Top-K sampling with K = 5, the waiter forces you to pick strictly among the top 5 most popular dishes, regardless of what they are. If today's top dish is 99% fresh pizza, the waiter still forces you to consider 4 other dishes you don't want! In Nucleus (Top-p) sampling with p = 0.90, the waiter asks: 'How many dishes does it take to reach 90% of quality?' When the pizza is great (99%), the pool shrinks to 1 single dish. When 20 dishes are all equally good, the pool dynamically expands to 20 dishes. Nucleus sampling breathes with the model's confidence.

MATHEMATICAL STATEMENT
  1. $$Compare rigid top-k thresholding with cumulative probability thresholding sum_{i=1}^V' p_i >= p, showing nucleus sampling expands and contracts dynamically with confidence.$$
  • Learning goalImplement Top-K and Nucleus (Top-p) truncation algorithms and evaluate pool size dynamics under varying distribution entropies.
  • Helpful foundationsCumulative distribution function · The Curious Case of Neural Text Degeneration (Holtzman et al., 2019)
  • Common trapThinking Top-K and Top-p cannot be combined; production engines often apply Top-K first (e.g. K=50) to clip extreme vocab tails, followed immediately by Top-p (p=0.9) for dynamic selection.
  • Next connectionWe have now explored the complete probabilistic foundations of loss functions, entropy, and decoding.
✦ More context & mechanics
Conceptual Mechanics & Logic

Let sorted probabilities be p₁ ≥ p₂ ≥ ṡ ≥ p_(|V|).

  1. Top-K Sampling (Fan et al., 2018):

Truncate the distribution to a fixed integer K:

V^((K)) = 1, 2, ṡ, K

Set all logits outside V^((K)) to -∞ and re-normalize:

qᵢ' = (pᵢ) / (∑_(j=1)^K pⱼ) & if i ≤ K \ 0 & if i > K

  • Flaw: When the distribution is flat, K=5 arbitrarily cuts off valid candidates. When the distribution is peaked, K=5 includes unwanted tail garbage.
  1. Nucleus (Top-p) Sampling (Holtzman et al., 2019):

Find the minimal set of top tokens whose cumulative probability exceeds threshold p ∈ (0, 1) (typically p = 0.90):

V^((p)) = 1, 2, ṡ, k^ where k^ = min k | ∑_(i=1)^k pᵢ ≥ p

  • Dynamic Adaptability:
  • High Confidence: p₁ = 0.95 ⟹ k^* = 1 (pool collapses to 1 token).
  • High Uncertainty: pᵢ = 0.05 ⟹ k^* = 18 (pool dynamically expands to 18 tokens).
Real-World Usage

Nucleus sampling (Top-p = 0.9) combined with mild temperature (T = 0.7) is the default decoding strategy in OpenAI ChatGPT, Anthropic Claude, and Meta LLaMA.

History & Origin Story

Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi introduced Nucleus Sampling at ICLR 2020 ('The Curious Case of Neural Text Degeneration'), proving it eliminated repetitive loops and incoherent tail hallucinations.

How to Memorize & Golden Words
  • Top-K is a rigid box of size K.
  • Top-p is a dynamic net that catches 90% of the probability mass.
Picture 9 of 12 · tap to inspect in full resolution
09

What is the mathematical foundation and geometric intuition of Temperature Scaling: Softening the Probability Simplex?

INTUITION

Understand Temperature Scaling: Softening the Probability Simplex visually: How temperature T transforms raw logits z = [2.0, 1.0, 0.0] into sampling distributions.. Every transformation preserves core structural invariants while mapping coordinate spaces.

MATHEMATICAL STATEMENT
  1. $$How temperature T transforms raw logits z = [2.0, 1.0, 0.0] into sampling distributions.$$
  • Learning goalMaster the algebraic and geometric derivation of Temperature Scaling: Softening the Probability Simplex.
  • Helpful foundationsLinear Algebra Fundamentals · Matrix Transformations · Vector Spaces
  • Common trapAssuming Temperature Scaling: Softening the Probability Simplex is merely a computational trick rather than an invariant spatial law.
  • Next connectionConnects to upstream spectral theory and downstream tensor operations.
✦ More context & mechanics
Conceptual Mechanics & Mathematical Rigor

A comparative decoding probability chart on natural warm linen (#f5f4e9) with a slate border.

Top section: Title in bold sans-serif: "Temperature Scaling: Softening the Probability Simplex". Subtitle: "How temperature T transforms raw logits z = [2.0, 1.0, 0.0] into sampling distributions."

Middle section: Three horizontal probability bar charts side-by-side:

  1. Cold Temperature (T = 0.5): Probabilities = [0.867, 0.117, 0.016]. Sharp, decisive peak at token 0; near-greedy argmax.
  2. Standard Baseline (T = 1.0): Probabilities = [0.665, 0.245, 0.090]. Balanced natural language distribution.
  3. Hot Temperature (T = 2.0): Probabilities = [0.468, 0.316, 0.216]. Flattened distribution; tokens compete evenly.

Show formula: P(wᵢ | z, T) = (exp(zᵢ / T)) / (∑ exp(zⱼ / T)).

Bottom section: Boundary Limits Container: "T → 0: P collapses to Dirac delta δ_(i, argmax(z)) (Hard argmax) | T → ∞: P collapses to Uniform 1/V (Maximum entropy white noise)."

Clear bar charts, generous whitespace, pristine lines.

Practical AI & Systems Usage

This principle is foundational across deep learning optimization, high-dimensional representation, and modern LLM architectures.

Golden Axiom

"Temperature Scaling: Softening the Probability Simplex: Invariance and structure determine stability under spatial and numerical transformations."

Picture 10 of 12 · tap to inspect in full resolution
10

What is the mathematical foundation and geometric intuition of The Entropy Monotonicity Theorem: Temperature as Uncertainty?

INTUITION

Understand The Entropy Monotonicity Theorem: Temperature as Uncertainty visually: Mathematical proof that Shannon entropy H(P_T) strictly increases with temperature.. Every transformation preserves core structural invariants while mapping coordinate spaces.

  • Learning goalMaster the algebraic and geometric derivation of The Entropy Monotonicity Theorem: Temperature as Uncertainty.
  • Helpful foundationsLinear Algebra Fundamentals · Matrix Transformations · Vector Spaces
  • Common trapAssuming The Entropy Monotonicity Theorem: Temperature as Uncertainty is merely a computational trick rather than an invariant spatial law.
  • Next connectionConnects to upstream spectral theory and downstream tensor operations.
✦ More context & mechanics
Conceptual Mechanics & Mathematical Rigor

A thermodynamic mathematical proof diagram on natural warm linen (#f5f4e9) with a slate border.

Top section: Title in bold sans-serif: "The Entropy Monotonicity Theorem: Temperature as Uncertainty". Subtitle: "Mathematical proof that Shannon entropy H(P_T) strictly increases with temperature."

Middle section: A clean 2D plot of Shannon entropy H in bits against temperature T ∈ [0, 3].

Mark the calculated points from Slide 085:

  • H(T = 0.5) = 0.640 bits (Low uncertainty).
  • H(T = 1.0) = 1.250 bits (Moderate uncertainty).
  • H(T = 2.0) = 1.512 bits (Approaching theoretical maximum log₂(3) = 1.585 bits).

Boxed Derivative Proof:

"(d H(P_T)) / (d T) = (1) / (T²) Var_(P_T)(z) ≥ 0".

Annotate: "Because variance is strictly non-negative (Var(z) ≥ 0), the derivative is unconditionally ≥ 0; temperature is guaranteed to be a monotonic entropy dial."

Bottom section: Card: "Increasing temperature NEVER reduces uncertainty; it is mathematically impossible for an LLM to become more confident as T rises."

Spacious curve layout, sharp mathematical typography, zero clutter.

Practical AI & Systems Usage

This principle is foundational across deep learning optimization, high-dimensional representation, and modern LLM architectures.

Golden Axiom

"The Entropy Monotonicity Theorem: Temperature as Uncertainty: Invariance and structure determine stability under spatial and numerical transformations."

Picture 11 of 12 · tap to inspect in full resolution
11

How does Temperature Scaling: Softening the Probability Simplex operate mathematically at scale?

INTUITION

Comparison of three probability distributions from identical logits z = [4.0, 2.0, 1.0]:

  • Learning goalMaster the algebraic and geometric derivation of Temperature Scaling: Softening the Probability Simplex.
  • Helpful foundationsFoundations of Build Llm From Scratch · Coordinate Invariance & Geometric Projections · Radford et al. (2019), Language Models are Unsupervised Multitask Learners, OpenAI
  • Common trapAssuming Temperature Scaling: Softening the Probability Simplex is an arbitrary computational trick rather than an invariant spatial law.
  • Next connectionConnects upstream foundational lemmas to modern high-dimensional computational systems.
✦ More context & mechanics
Conceptual Mechanics & Mathematical Rigor

A probability softening trace diagram in square 1:1 format on warm cream parchment (#fcf0db) with a sepia frame.

Top section: Title in navy serif: "Temperature Scaling: Softening the Simplex". Subtitle: "How dividing logits by scalar T controls generation entropy and diversity."

Middle section: Comparison of three probability distributions from identical logits z = [4.0, 2.0, 1.0]:

  1. Low Temperature (T = 0.2, Greed/Cold):

Scaled logits: [20.0, 10.0, 5.0].

Probabilities: [0.9999, 0.0001, 0.0000]. One-hot collapse; completely deterministic.

  1. Standard Temperature (T = 1.0, Base):

Scaled logits: [4.0, 2.0, 1.0].

Probabilities: [0.844, 0.114, 0.042]. Balanced selection reflecting raw training distribution.

  1. High Temperature (T = 2.0, Creative/Hot):

Scaled logits: [2.0, 1.0, 0.5].

Probabilities: [0.551, 0.276, 0.173]. Softened distribution; increases entropy and diversity.

Bottom section: Mathematical limit: "lim_(T → 0) Softmax(z/T) = argmax(z) (Argmax), lim_(T → ∞) Softmax(z/T) = Uniform(1/K)."

Clear bar charts for each temperature level, crisp numeric annotations, balanced square frame.

Invariance & Structural Proof

Every transformation preserves structural invariants while mapping coordinate spaces. When operating in high dimensions, numerical precision and computational efficiency require adhering strictly to canonical mathematical laws.

Canonical Literature Reference

Formal derivation and peer-reviewed analysis:

Radford et al. (2019), Language Models are Unsupervised Multitask Learners, OpenAI

Golden Axiom

"Temperature Scaling: Softening the Probability Simplex: Invariance, symmetry, and structure govern mathematical truth across continuous and discrete domains."

Picture 12 of 12 · tap to inspect in full resolution
12

How does The Entropy Monotonicity Theorem: Temperature as Uncertainty operate mathematically at scale?

INTUITION

The mathematical derivation:

  • Learning goalMaster the algebraic and geometric derivation of The Entropy Monotonicity Theorem: Temperature as Uncertainty.
  • Helpful foundationsFoundations of Build Llm From Scratch · Coordinate Invariance & Geometric Projections · Radford et al. (2019), Language Models are Unsupervised Multitask Learners, OpenAI
  • Common trapAssuming The Entropy Monotonicity Theorem: Temperature as Uncertainty is an arbitrary computational trick rather than an invariant spatial law.
  • Next connectionConnects upstream foundational lemmas to modern high-dimensional computational systems.
✦ More context & mechanics
Conceptual Mechanics & Mathematical Rigor

A mathematical theorem card in square 1:1 format on warm cream parchment (#fcf0db) with an 8px border.

Top section: Title in navy serif: "The Entropy Monotonicity Theorem". Subtitle: "Proof that Shannon entropy H(P_T) is a strictly increasing function of temperature T."

Middle section: The mathematical derivation:

  1. Define temperature-scaled probability: pᵢ(T) = (e^(zᵢ / T)) / (∑ⱼ e^(zⱼ / T)).
  2. Define Shannon entropy: H(T) = -∑ᵢ pᵢ(T) log pᵢ(T).
  3. Compute derivative with respect to temperature:

dH/dT = (1) / (T³) Var_(i ~ p)[zᵢ] = (1) / (T³) ( ∑ᵢ pᵢ zᵢ² - (∑ᵢ pᵢ zᵢ)² ).

  1. Variance of non-identical logits is strictly positive: Var[z] > 0.
  2. Therefore: dH/dT > 0 for all T > 0.

Bottom section: Thermodynamic parallel: "As temperature increases, entropy strictly increases. LLM temperature scaling directly mimics Boltzmann thermodynamic entropy."

Elegant LaTeX lines, clean positive variance highlight, balanced square styling.

Invariance & Structural Proof

Every transformation preserves structural invariants while mapping coordinate spaces. When operating in high dimensions, numerical precision and computational efficiency require adhering strictly to canonical mathematical laws.

Canonical Literature Reference

Formal derivation and peer-reviewed analysis:

Radford et al. (2019), Language Models are Unsupervised Multitask Learners, OpenAI

Golden Axiom

"The Entropy Monotonicity Theorem: Temperature as Uncertainty: Invariance, symmetry, and structure govern mathematical truth across continuous and discrete domains."