Softmax
A function that converts a set of arbitrary numbers into a probability distribution: all outputs lie between 0 and 1, and their sum equals 1.
Formula
softmax(xᵢ) = eˣⁱ / Σ eˣʲ
Each number is raised to the exponent, and then divided by the sum of all exponents. Thus, raw estimates are converted into percentages.
Where It Is Used
- last layer of language models — selection of the next token;
- classification — probability of belonging to each class;
- attention — distribution of 'attention' between words.
Why It Works
The exponent makes large values even larger and small values even smaller, amplifying the difference. After normalization, the strongest candidate receives the highest probability.
Relation to Other Concepts
At the output, Softmax compares the predicted distribution with the correct one through Cross-Entropy — this is the basis for training classifiers and language models.