A GPT-style model is trained to predict each token from the tokens before it. During training every position is processed at once, so attention must be blocked from looking at the future. A causal mask does that.
Implement causal_mask(n), returning an n x n boolean matrix that allows attention only to current and earlier positions.
True means the attention is allowed.Use a lower-triangular matrix of ones, cast to boolean.
No results yet
Run your code to check it against the examples, or submit to run every test.