# Softmax

> Canonical: https://skillalmanac.com/glossary/softmax | Last verified: 2026-11-24 | Index status: index-eligible

Softmax exponentiates and normalizes real-valued scores into nonnegative values summing to one along a specified dimension. It can produce a class or token distribution, but normalized scores alone do not establish calibrated probabilities.

Also called: softmax function, softmax activation, softmax layer, softmax classifier, softmax output.

## In plain language

A classifier can assign scores to cat, dog and rabbit. Softmax converts that score vector into shares summing to one; higher scores get larger shares. For a batch, normalization may apply separately to each row. The output is not proof that the selected category is correct or that the model is well calibrated, especially on unfamiliar inputs.

## Technical definition

For scores z_i in a chosen slice, softmax returns exp(z_i) divided by the sum of exp(z_j) in that slice. A tensor implementation specifies a normalization dimension. Softmax is also used inside attention, not only at classifier outputs. Temperature can scale logits before normalization; truncation and sampling are separate decoding choices.

## How it shows up when you use agents

In a common autoregressive [large language model](/glossary/large-language-model), vocabulary scores are normalized to a distribution over possible next [tokens](/glossary/token), then a decoding rule chooses a continuation. Settings such as temperature and top-p reshape or trim that distribution before the choice, which is why the same prompt can give different answers on different runs.

Softmax also appears wherever an agent depends on a classifier: a model that labels an email as spam, a request as safe or unsafe, or an image by category. Those systems usually report a score, and that score is often a softmax output.

What breaks when it is misunderstood: people read the number as certainty. A softmax output must add up to 1 across the classes it knows about, so an explicit none-of-the-above class or an external rejection rule is needed if the application requires that option. If a classifier gates an agent action, treat the score as a ranking signal, check it against labelled examples, and keep a human approval step for actions that are hard to undo. The [LLM eval test sets](/skills/skill-almanac/llm-eval-test-sets) skill is one way to build those labelled examples.

## Worked example (illustrative)

Apply softmax separately to the rows [0, ln(3)] and [0, 0]. Their outputs are [0.25, 0.75] and [0.5, 0.5]. Each row sums to one, while the two-row tensor sums to two. This calculated example shows why the normalization dimension matters; the values are not measured classification probabilities or calibration results.

## Common confusions

- **Softmax versus a probability of being correct.** The outputs form a probability distribution over the classes, but a high value does not mean the model is right. It means the model ranks that class above the others.
- **Softmax versus an activation function in a hidden layer.** Softmax normalizes a group of values together and is also used in attention. Element-wise [activation functions](/glossary/activation-function) act on individual values; their roles differ.
- **Softmax versus cross-entropy loss.** Softmax makes the probabilities. Cross-entropy is the [loss function](/glossary/loss-function) that compares them with the true class during training. CS231n pairs them in the softmax classifier.
- **Softmax versus sampling.** Softmax produces the distribution. Sampling settings such as temperature and top-p decide how the next token is drawn from it.

## Worked examples in this catalogue

### [What Is an LLM? The Facts Agent Users Need](https://skillalmanac.com/learn/what-is-an-llm-for-agent-users)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: An explanation of what a large language model is for people who run agents, written for users rather than for machine-learning engineers.

Why it exercises the concept: In common autoregressive language generation, a model predicts a distribution over next tokens, often using softmax. The guide covers the model rather than deriving this function.

### [llm-eval-test-sets](https://skillalmanac.com/skills/skill-almanac/llm-eval-test-sets)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Builds and validates an eval dataset for any LLM feature, with a checker for duplicates, missing graders, imbalance and leakage.

Why it exercises the concept: The linked skill helps define evaluation cases for model outputs. It does not calculate softmax or establish calibration; it is an adjacent evaluation tool.

### [split-leakage-check](https://skillalmanac.com/skills/skill-almanac/split-leakage-check)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Checks train, validation and test files for duplicates, shared groups, time and label leakage; prints JSON.

Why it exercises the concept: A classifier that ends in softmax is judged on held-out data. This skill checks that the held-out files are clean. It does not compute softmax.

### [Claude Code](https://skillalmanac.com/tools/claude-code)

```
/model
```

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Claude Code lets you switch the model mid-session with /model.

Why it exercises the concept: An agent can write code that explicitly applies softmax. A common autoregressive decoder also uses vocabulary normalization, but this is not a claim about every possible model or decoding implementation.

## Related terms

- [Neural network](https://skillalmanac.com/glossary/neural-network.md)
- [Large language model (LLM)](https://skillalmanac.com/glossary/large-language-model.md)
- [Token](https://skillalmanac.com/glossary/token.md)
- [Loss function](https://skillalmanac.com/glossary/loss-function.md)
- [Activation function](https://skillalmanac.com/glossary/activation-function.md)
- [Classification](https://skillalmanac.com/glossary/classification.md)

## Sources

- [Neural networks: Multi-class classification](https://developers.google.com/machine-learning/crash-course/neural-networks/multi-class), Google for Developers (Machine Learning Crash Course) (accessed 2026-11-24)
- [CS231n Deep Learning for Computer Vision: Linear classification](https://cs231n.github.io/linear-classify/), Stanford University (accessed 2026-11-24)
- [Softmax (torch.nn.Softmax)](https://docs.pytorch.org/docs/2.15/generated/torch.nn.Softmax.html), PyTorch documentation (accessed 2026-11-24)
- [Attention Is All You Need, sections 3.2.1 and 3.4](https://arxiv.org/html/1706.03762v7), Vaswani et al. (accessed 2026-11-24)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-24. [Glossary index](https://skillalmanac.com/glossary.md).
