esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

What Are Logits and What Does Softmax Do?

What logits are, how softmax turns them into probabilities, and how a language model picks its next token, explained for your AI interview.

In short

Logits are the raw scores a model gives each possible output, before anything is scaled. Softmax turns those scores into positive numbers that add up to 1, so the top score gets the biggest share.

11 min readIntermediateCommon · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

Logits are the raw scores a model gives each possible answer. They can be any number, positive or negative, so they are hard to read on their own. Softmax turns them into probabilities: each one becomes a positive share, and all the shares add up to one. A language model does this for every token it knows, then picks the next token from those shares. Here is a small example with three decisions.

What are logits and softmax, in plain words?

A language model writes one piece of text at a time, called a token. At each step it has to score every token it knows. Each score is a logit: a raw number that can be big, small or negative, and that means little to a person until it is changed.

Softmax is the change. It takes the list of logits and turns it into probabilities, one per token, so that they add up to 1 (or 100%). A probability of 0.7 is a 70% share of the whole, which a team can read at a glance.

Think of a hospital triage board. A nurse gives each patient a raw urgency score, but the board needs a clear order and a share of attention for each case. Raw scores do the first job badly. Shares of the whole do the second well.

Now the AI version. A claims triage model scores the three decisions it could take on an incoming motor claim. Those three raw scores are its logits, and softmax turns them into shares the queue can act on.

Key words

Logit
A raw score a model gives each possible output. It can be any number, positive or negative.
Softmax
A function that turns a list of logits into probabilities that add up to 1.
Token
A piece of text the model reads and writes, often part of a word.
Vocabulary
The full list of tokens a language model can output at each step.
Probability distribution
The full set of shares across all the options, adding up to 100%.
  • “The vector of raw (non-normalized) predictions that a classification model generates, which is ordinarily then passed to a normalization function.”

    Google Machine Learning Glossary, logits

  • “A function that determines probabilities for each possible class in a multi-class classification model. The probabilities add up to exactly 1.0.”

    Google Machine Learning Glossary, softmax

How does softmax turn logits into probabilities?

  1. 1

    Make every score positive

    Raise the number e (about 2.718, a fixed maths constant) to the power of each logit. Big scores become much bigger numbers, and negative scores become small positive ones.

  2. 2

    Add them up

    Add all those positive numbers into one total.

  3. 3

    Share the total

    Divide each number by the total. Each result sits between 0 and 1, and all of them add up to exactly 1.

The PyTorch documentation describes the function the same way: it re-scales the values "so that the elements lie in the range [0, 1] and sum to 1". The example below is made up, and the code runs for real.

From raw scores to shares

Claim notes

Text from a motor claim form

Claims model

Writes one raw score per decision

Raw scores (logits)

Pay out

logit 2.1, made-up

Send to officer

logit 0.4, made-up

Reject

logit -1.3, made-up

Softmax

Makes shares that add to 100%

82% pay out

The top share leads the queue

  1. 1The claim notes go into the model as plain text.
  2. 2The model writes one raw score for each decision it could take.
  3. 3Softmax turns the three scores into shares that add up to 100%.
  4. 4The biggest share is the one the queue acts on.
A claim note goes into a made-up claims model, which writes one raw score per decision. Softmax turns the three scores into shares of 100%. The top share is the one the queue acts on.

Here it is in plain Python, with the three made-up logits. Lines 9 to 13 hold the softmax itself. The temperature in the second run is a setting that divides the logits before softmax, and a lower value sharpens the shares.

Python
# A claims triage model scores three decisions. Its raw scores are logits.
import math

LABELS = ["pay out", "send to a claims officer", "reject"]
logits = [2.1, 0.4, -1.3]


def softmax(scores, temperature=1.0):
    scaled = [s / temperature for s in scores]
    top = max(scaled)  # subtract the top score first, so exp() never gets huge
    exps = [math.exp(s - top) for s in scaled]
    total = sum(exps)
    return [e / total for e in exps]


def show(probs):
    for label, p in zip(LABELS, probs):
        print(f"{label:<26}{p:7.1%}")
    print(f"{'total':<26}{sum(probs):7.1%}")


print("Raw logits:", logits)
print("Softmax, temperature 1.0:")
show(softmax(logits))
print("Softmax, temperature 0.5 (sharper):")
show(softmax(logits, temperature=0.5))

Output

Raw logits: [2.1, 0.4, -1.3]
Softmax, temperature 1.0:
pay out                     82.2%
send to a claims officer    15.0%
reject                       2.7%
total                      100.0%
Softmax, temperature 0.5 (sharper):
pay out                     96.7%
send to a claims officer     3.2%
reject                       0.1%
total                      100.0%

Two things to notice. The shares always add up to 100%, even though the raw scores don't. And the second run uses a temperature, a setting that divides the logits before softmax. A lower temperature sharpens the picture, so pay out moves from 82% to 97%.

The order never changes. Softmax keeps the scores in the same order, so the biggest logit always gets the biggest share. Softmax only changes the numbers you show. The option the model prefers stays the same.

What does a language model do with its logits?

At each step a language model gives a logit to every token in its vocabulary. Softmax turns that list into a probability distribution, and the model then picks one token from it. The picked token joins the text, and the whole process runs again for the next token.

  • Greedy

    Always the top share

    The model takes the token with the biggest share every time. It is simple and steady, and it is the default decoding strategy in Hugging Face's open-source library, but it can repeat itself.

  • Sampling

    A draw by share

    The model draws one token at random, weighted by its share. A token with a 15% share wins about 15 draws in 100, so answers vary from run to run.

How a language model picks the next token

Text so far

The prompt and the tokens written

Language model

Scores every token it knows

Softmax

Turns the scores into shares

Greedy

Take the top share

Same pick every time

Sampling

Draw by chance

Varied picks, weighted by share

Next token

Added to the text, then the loop runs again

  1. 1The text so far goes into the model.
  2. 2The model writes a score for every token it knows.
  3. 3The shares go to the greedy rule, which takes the top one.
  4. 4The same shares can go to sampling, which draws one by chance.
  5. 5The greedy pick becomes the next token.
  6. 6The sampled pick becomes the next token.
The text so far goes into a language model, which scores every token. Softmax makes the shares, then one rule takes the top share or draws by chance. The chosen token joins the text, and the loop runs again.

Some APIs let you see these numbers. OpenAI's chat API can return the log probability (the log of its chance) of an output token, but only when that token is one of the 20 most likely ones. Each strategy is only a rule for reading the same shares.

Where does softmax fall short?

  • “Softmax assumes that each example is a member of exactly one class.”

    Google Machine Learning Crash Course, multi-class

  • One right answer only

    A claim that is both a flood claim and a fraud review needs a separate yes or no score for each label. Google's course says that case needs several yes or no models instead.

  • Shares are the model's own score

    A 90% share shows how strongly the model leaned. It says nothing certain about accuracy, so measure accuracy on past cases before you quote a rate.

  • Cost grows with the number of options

    Scoring every token in a large vocabulary is heavy work at each step, and Google's course notes that full softmax gets expensive as the number of classes climbs.

Tip

Asked what softmax does, name the three steps first: raise to the power, add up, divide. Then say what the shares are for, and where they can mislead.

What does the interviewer want to hear?

A strong answer covers

  • Logits are raw scores, before any scaling.
  • Softmax makes positive numbers, adds them, then divides, so the shares add up to 1.
  • It keeps the order: the top logit gets the top share.
  • A language model scores every token, then picks one by the greedy rule or by sampling.
  • Limits: one right answer per example, and cost grows with many options.
  • Shares show how strongly a model leaned. Measure accuracy on past cases before you quote a rate.

Common traps

  • Trap"Logits are the probabilities."

    BetterLogits are raw scores. Softmax turns them into probabilities.

  • Trap"Softmax makes the model more accurate."

    BetterIt only reshapes the scores into shares. The order stays the same, so accuracy depends on the model itself.

  • Trap"A 95% share means it's right 95% of the time."

    BetterA share shows how strongly the model leaned. Measure accuracy on real past cases.

Can you spot the mistake?

Spot the mistake

A teammate explains a bank's fraud model to the risk committee. Which sentence is wrong?

Quick check

A claims model may tag one claim as both flood and fraud. Which change fits?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q002What does "predict the next token" mean?10 min
  2. Q038What are log-probabilities, and how can you use them?Coming soon
  3. Q039What are frequency and presence penalties?Coming soon
  4. Q023What is a hallucination, and why does it happen?11 min
  5. Q041What is a transformer?10 min
  6. Q029What do stop sequences and max tokens do?11 min

Learn it in depth

Last updated on 26 November 2026

Building an AI feature that picks from scores?

I design and build AI products and agents, the screens and the system behind them. Book a short call and tell me what your model has to decide.