# Softmax Function

> Turns raw scores into chances that add up to 100%.

**Field:** Artificial Intelligence  
**Category:** Machine Learning  
**Also known as:** Softmax, Softmax Activation, Normalized Exponential

## Think of it like

It is like cutting one pizza for three friends. The most hungry gets the big slice.

## Definition

Softmax turns a list of raw scores into chances that add up to 100%. A network's last layer gives one score for each possible answer. The scores can be any size, even below zero. Softmax makes each one positive and scales them so they sum to 1. A big lead in score becomes a big lead in chance. A language model uses it to choose its next token.

## Example

A photo model scores cat 4, dog 2 and fox 1. Softmax turns those into about 84% cat, 11% dog and 4% fox.

## Example code

```python
import torch
torch.softmax(torch.tensor([4.0, 2.0, 1.0]), dim=0)
# tensor([0.8438, 0.1142, 0.0420])
```

Three raw scores in, three chances out. Together they add up to 1.

## Why it matters

It lets a network say how sure it is of each answer. Temperature works by changing the scores first.

## Common mistake

Reading its output as true confidence. A model can give 99% and still be wrong.

## Three principles

- **Scores in.** One raw score per answer.
- **Chances out.** All positive, summing to 1.
- **Big gaps grow.** A lead in score becomes a bigger lead.

## Related terms

- [Activation Function](https://learn.benibix.com/term/ai/activation-function)
- [Classification (Machine Learning)](https://learn.benibix.com/term/ai/classification)
- [LLM Temperature](https://learn.benibix.com/term/ai/temperature)
- [Layer (Neural Network)](https://learn.benibix.com/term/ai/neural-network-layer)
- [Logistic Regression](https://learn.benibix.com/term/ai/logistic-regression)

## Taught in

- [Neural Network Basics](https://learn.benibix.com/learn/ai-machine-learning/neural-network-basics): Machine Learning, 13/18

![Three raw scores, cat 4, dog 2 and fox 1, pass through a box marked softmax. Out come three bars of chance: cat 84%, dog 11% and fox 4%, which together fill one whole.](https://learn.benibix.com/diagrams/ai3-softmax.svg)

---

Source: https://learn.benibix.com/term/ai/softmax
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
