At what point in the forward pass are positional embeddings combined with token representations?

Last updated 22 November 2026

It depends on the scheme. Absolute encodings are added once, right after the token embedding lookup and before the first Transformer block. Relative schemes inject position inside every attention layer instead.

  • Absolute (sinusoidal or learned):

    1. Look up token embeddings.

    2. In the original Transformer, scale them by sqrt(d_model).

    3. Add the position embeddings element-wise (summed, not concatenated, so the dimension stays d_model).

    4. Apply dropout, then feed the first block. BERT also adds segment embeddings and applies LayerNorm here.

  • After that, position lives only implicitly in the residual stream: Deeper layers must preserve it themselves.

  • RoPE:

    • Applied in every attention layer, after the W_q and W_k projections and before QK^T.

    • Nothing is added at the input.

  • ALiBi and T5 bias:

    • Added to the attention logits after QK^T / sqrt(d) and before softmax.

    • Applied in every layer for ALiBi. T5 computes its bias in the first layer of each stack and shares it across all layers.

  • https://magazine.sebastianraschka.com/p/understanding-positional-embeddings
  • https://medium.com/@bishalsharma406365/interview-questions-on-the-topic-of-positional-encoding-in-transformers-42af83bdcb31
  • https://loganthomson.com/RoPE/
All Transformers interview questions