PythiloLesson 3 of 8 · progress kept in this browser

Causal Attention Mask

An autoregressive position may read its prefix, including itself, but never later tokens. Mask before softmax and normalize each allowed row.

row = 1
print([column <= row for column in range(3)])
Your task

causal_weights(scores) takes a square nonempty score matrix and returns row softmax with columns j > i set to probability zero. Use stable exponentials over the unmasked prefix.