ML//neural network//softmax
Softmax is a normalization function that converts a vector of raw scores (logits) into positive weights that sum to 1, and it is used wherever a network has to turn scores into a probability distribution or a weighted average. It exponentiates each entry and divides by the total, giving entry \(i\) the weight \(e^{x_i} / \sum_j e^{x_j}\); because its output is a distribution over the whole vector, it is a different thing from an activation function. Scores of 2, 1 and 0 become 0.67, 0.24 and 0.09.
Softmax is a normalization function that converts a vector of raw scores (logits) into positive weights that sum to 1, and it is used wherever a network has to turn scores into a probability distribution or a weighted average. It exponentiates each entry and divides by the total, giving entry iii the weight exi/∑jexje^{x_i} / \sum_j e^{x_j}exi/∑jexj; because its output is a distribution over the whole vector, it is a different thing from an activation function. Scores of 2, 1 and 0 become 0.67, 0.24 and 0.09.
In attention it is applied to each row of the QKTQK^{\mathsf T}QKT scores (one row per query), and it gives how much each token attends to every other; dividing the scores by d\sqrt dd first keeps it from saturating as the dimension grows.
At the output of a transformer it is applied to the logits (the raw pre-normalization scores) over the vocabulary, and it gives the probability of each possible next token: after I left the keys by the front, perhaps door 0.65, gate 0.20, step 0.10 and every other token together 0.05.
Temperature controls its sharpness: T<1T<1T<1 makes the distribution peakier (more confident), T>1T>1T>1 flattens it (more random).
Positive and summing to 1 is not yet a probability.
A softmax output means right that often only once it has been calibrated and checked on validation data (probability calibration), and on an out-of-distribution input it means nothing even when calibrated. Real uncertainty needs several networks trained from different seeds, an out-of-distribution detector, or a simpler model that gives it by construction.
A defect classifier that reports 0.99 on a part photographed under new lighting is the typical failure: large modern networks tend to be overconfident, and a single parameter fitted on validation (temperature scaling) corrects only part of it. Without that step, a decision threshold built on costs has no meaning.