Review

Review reordering and causal-mask boundaries, absolute and relative position equations, RoPE geometry, ALiBi score bias, mechanism locations, context claims, and a ten-step audit order.

Begin with the Attention Setting

For unmasked content-only self-attention and a row permutation PP,

Attention(PX)=PAttention(X).\operatorname{Attention}(PX)=P\operatorname{Attention}(X).

This is permutation equivariance, not invariance. The output records follow the reordered input records.

A fixed causal mask is tied to index order. In general,

P(S+M)PTPSPT+M.P(S+M)P^T\ne PSP^T+M.

Causal visibility can therefore provide implicit position information. This qualifies claims about Transformers without explicit position methods; it does not make all explicit methods unnecessary.

Absolute Position Methods

A learned absolute table uses

xi=E[ti]+P[i],P:Lmax×dmodel.x_i=E[t_i]+P[i],\qquad P:L_{max}\times d_{model}.

It adds LmaxdmodelL_{max}d_{model} trainable entries and requires a policy beyond the available table rows.

The original sinusoidal method uses fixed pairs:

PE(pos,2k)=sin(pos100002k/dmodel),PE(pos,2k)=\sin\left(\frac{pos}{10000^{2k/d_{model}}}\right), PE(pos,2k+1)=cos(pos100002k/dmodel).PE(pos,2k+1)=\cos\left(\frac{pos}{10000^{2k/d_{model}}}\right).

Each pair uses a different frequency. A fixed offset acts as a frequency-specific 2D rotation. The formula can compute a new index, but that does not guarantee that a trained model generalizes to the corresponding sequence length.

Relative Interaction Methods

One Shaw-style relative score is

eij=qiT(kj+ajiK)dk.e_{ij}=\frac{q_i^T(k_j+a^K_{j-i})}{\sqrt{d_k}}.

The signed offset convention and any clipping or bucketing rule are part of the model definition.

RoPE rotates query and key coordinate pairs. Under this chapter's column-vector convention,

(R(mθ)q)T(R(nθ)k)=qTR((nm)θ)k.(R(m\theta)q)^T(R(n\theta)k) =q^TR((n-m)\theta)k.

Absolute indices select rotations, while the pairwise dot product has a relative-offset form. Pair layout, sign, index origin, frequencies, scaling, rotated fraction, and numerical precision must agree across implementations.

ALiBi adds a finite distance penalty to allowed scores:

eij(r)=qi(r)kj(r)dkmr(ij).e^{(r)}_{ij} =\frac{q_i^{(r)\top}k_j^{(r)}}{\sqrt{d_k}}-m_r(i-j).

It is a recency bias, not a causal mask and not a hard attention window.

Compare the Operation Location

MethodChanged object
Learned absoluteinput representation
Sinusoidalinput representation
Shaw-style relativepairwise score and optionally value
RoPEprojected query and key pairs
ALiBiattention score before softmax

Methods that produce the same final tensor shape can still implement different functions.

Audit Order

  1. Record token IDs, padding, special tokens, and position IDs.
  2. State index origin and signed-offset convention.
  3. Keep causal and padding masks separate from finite score biases.
  4. Verify absolute additions, if used.
  5. Verify selected Q/K rotations or relation lookups, if used.
  6. Record content scores and position contributions separately.
  7. Check combined scores, softmax axis, row sums, and forbidden zeros.
  8. Compare changed, zeroed, shifted, or swapped position interventions.
  9. Compare cached and uncached position assignments and logits.
  10. Report training and evaluation lengths before making generalization claims.

Check Yourself

  • Can you distinguish permutation invariance from equivariance?
  • Can you explain why a fixed causal mask changes the reordering proof?
  • Can you calculate and count learned absolute position vectors?
  • Can you calculate four sinusoidal coordinates without memorizing a table?
  • Can you state a relative-offset sign convention and follow it consistently?
  • Can you rotate one RoPE pair and derive the relative-dot-product identity?
  • Can you separate an ALiBi bias from a causal mask?
  • Can you distinguish a computable index from demonstrated length generalization?
  • Can you locate a position bug that preserves every tensor shape?

Position information now reaches the attention calculation through a declared mechanism. Chapter 4 will place that attention update inside a complete Transformer block with residual paths, normalization, and an MLP.

References

Pause and reflect

What can you now explain without looking back, and what should you revisit? The note stays with this review.

Review

Not marked done.