Transformer Lab

Interactive Self-Attention & QKV Step-by-Step Explorer

Q: Query K: Key V: Value

1. Input Configuration

2. Active Query Token

Click any token above to treat it as Query ($q_i$) and observe how it directs attention across all Keys ($k_j$).

Attention Weights: "it"

d_k = 4, Scale = 1/√4 = 0.5

Mathematical Pipeline Calculation

Query Vector ($q_i = x_i W_Q$)
Context Representation ($z_i = \sum A_{ij} v_j$)