AI-ENGINEERING
    beginner

    Sampling & Decoding Parameters

    AI Engineer path · lesson 58 of 124
    The idea
    The model hands you a weighted lottery wheel over possible next tokens. Temperature reshapes the wedge sizes, top-k/top-p saw off the tiny wedges, and decoding is just spinning the wheel — once per token.
    How to use
    Drag the temperature slider and watch the bars morph, then cut the tail and press Sample to feel the variance.
    Next token after:
    T = 1.00
    Paris
    73.1%
    the
    9.9%
    located
    6.0%
    Lyon
    4.4%
    a
    3.6%
    Marseille
    3.0%
    73%
    top token
    1.43
    entropy (bits)
    p ∝ e^(z/T)
    softmax

    Key insight

    Temperature divides the logits before softmax. T < 1 sharpens the distribution toward the top token (T → 0 is greedy argmax); T > 1 flattens it, pushing probability into the tail. It changes the distribution, not the model’s knowledge — high T on a factual prompt literally inflates the probability of wrong answers like “Lyon”.

    What each decoding knob actually does

    Sort

    Sort each parameter by how it changes the next-token choice.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    Reshapes the probabilities

    Drop items here

    Cuts candidates out

    Drop items here
    6 pieces left to place

    Test your knowledge

    20 questions
    Question 1 of 20
    Score: 0

    Where does temperature apply in the decoding pipeline?

    Interview Questions

    OpenAI
    Anthropic
    Stripe
    Google
    Meta
    Anthropic
    Databricks
    Google
    Meta
    Google
    Databricks

    Love this visualization?

    Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.

    100% free • No credit card required