14/25
Part 3 of 6 · The maskLearn
Masking after the softmax leaves rows that sum to less than 1
Here are the numbers for that shortcut, on the same scores.
# softmax first, then zero the future
late = softmax(scores) * allowed
print(late.round(2))
print(late.sum(axis=-1).round(2))
[[0.09 0. 0. ]
[0.09 0.24 0. ]
[0.09 0.24 0.67]]
[0.09 0.33 1. ]
Each row is the softmax of all three scores, with the future cut off afterwards. The weight the future took is simply gone.
| Query | Kept weights | Row sum | Lost |
|---|---|---|---|
| q1 | 0.09 | 0.09 | 0.24 + 0.67 |
| q2 | 0.09, 0.24 | 0.33 | 0.67 |
| q3 | 0.09, 0.24, 0.67 | 1.00 | nothing |