Softmax

Experimental alpha. Expect breaking changes and major bugs. Your feedback is much appreciated.

Softmax

Turns each row of scores into weights that are positive and sum to one, along the last size.

softmax

Drag a score and every chance moves, since together they must stay one. Only the differences between the scores count: raise them all alike and nothing changes. A low temperature stretches those differences until the largest takes everything, and a high one flattens them, which is how a model is made to write boldly or wander.

Shapes

Any shape in, the same shape out.

Parameters

None.

In PyTorch

weights = F.softmax(scores, dim=-1)

Notes

Don't end a model with one. The Core applies its own softmax to the scores it receives, as PyTorch's cross-entropy loss does, and a second one squashes them so flat that the model can never be confident.

In an attention build, the Softmax's output picture is the attention pattern: one row per position.

Making it

The Fabricator makes it from a photomask of Softmax: verify the spec on a Bench, or find a salvaged mask in the ruins, which makes it unfused. See The Bench and the Fabricator.