Skip to content

    Causal Masking

    AI fundamentals & modelsCausal Attention MaskAutoregressive maskLook-Ahead Mask
    Reading time: 2 min.Editorially reviewed on:

    Definition

    Attention mask that prevents a model from accessing future positions of the sequence when predicting a token.

    In the case of causal masking, a position may take into account only itself and previous positions. Transformer decoders block the attention to later tokens. Together with correctly shifted inputs by one position, this prevents later outputs from being used in the autoregressive prediction.

    Simply explained

    If the model is to predict the next word, it must not secretly see the later words.

    Why it matters in practice

    Basic mechanism of autoregressive language models and important for understanding training, decoding and data leakage within a sequence.

    Example from business

    Example scenario: When training a text generator, access to the tokens is masked for position 5 at position 6 and later.

    Limits and pitfalls

    • Confuse causal mask with padding mask; let future tokens be visible in training; assume any Transformer architecture uses causal masking.

    Origin & history

    The 2017 Transformer paper describes in the decoder the masking of subsequent positions, so that predictions depend only on already known outputs.

    Use in mid-sized companies

    • In the case of own autoregressive models, separately test masking, padding and position logic; in the case of finished APIs, this is usually an internal architectural mechanism.

    Frequently asked questions

    Is Causal Masking the same as Padding Masking?

    No.

    Why is masking applied?

    So that future tokens do not influence the current prediction.

    Do encoders like BERT use the same mask?

    Not in the classic bidirectional BERT.

    Sources

    Sources checked: 10/09/2026. Definition and documented classification verified; examples describe possible applications.

    Editorially reviewed on:

    On this page

    Next step

    Put knowledge into practice