TRANSFORMER INTERNALS · LESSON 140 OF 278

Temperature, Top-k, and Top-p

Control randomness and candidate selection without confusing decoding settings with model knowledge.

What you will learn

Control randomness and candidate selection without confusing decoding settings with model knowledge.

In simple words

Temperature rescales logits before softmax. Lower values emphasize high-probability tokens; top-k and top-p restrict which candidates may be sampled. These controls change output diversity, not the underlying learned facts.

Visual explanation: Temperature, Top-k, and Top-p

Trace how Token scores becomes Chosen token through sampling controls.

WATCH THE IDEA

Temperature, Top-k, and Top-p

Playing
Token scoresSampling controlsChosen token
  1. 1Observe: Token scores
  2. 2Transformation: Sampling controls
  3. 3Outcome: Chosen token

Observe: Token scores. Trace how Token scores becomes Chosen token through sampling controls.

The diagram highlights Token scores, Sampling controls, Chosen token. Use the labels to trace the main relationship from left to right.

Real-world example: Operational AI decision

A team applies temperature, top-k, and top-p to a real business workflow.

What the team decides: Sampling settings control variability, not truthfulness.

Risk to avoid: A strong technical concept still needs measurement, safeguards, and ownership in production.

Technical explanation

Temperature rescales logits before softmax. Lower values emphasize high-probability tokens; top-k and top-p restrict which candidates may be sampled. These controls change output diversity, not the underlying learned facts.

Common misconception

This concept is not a guarantee of a correct outcome by itself. Its value depends on suitable evidence, careful implementation, and evaluation against the real task.

QUICK QUIZ

What does lowering temperature generally do?

Practical application

Sampling settings control variability, not truthfulness.

Key takeaway

Sampling settings control variability, not truthfulness.

Next concept

Continue with KV Cache and Fast Generation.

Engineering view

Sampling settings control variability, not truthfulness.

Internals view

Control randomness and candidate selection without confusing decoding settings with model knowledge. Temperature rescales logits before softmax. Lower values emphasize high-probability tokens; top-k and top-p restrict which candidates may be sampled. These controls change output diversity, not the underlying learned facts.

Architecture view

Consider the Token scores → Sampling controls → Chosen token flow, and make the system's inputs, checks, and outcomes explicit.

Was this lesson helpful?

Lesson discussion

Comments are reviewed before publication. Keep discussion focused on learning and do not post private information.

Loading discussion…

Your quiz answer and current lesson are saved on this device. Sign in to explore account-backed learning features.

Content version 1 · Last reviewed 2026-10-16