Transformer Linear Algebra Visualizer MATH.JS + D3

Exact matrix projections, scaled dot-product attention, and softmax computations

Step Control & Parameters
Q = X · W_Q | K = X · W_K | V = X · W_V
Scale by √d_k (Scale factor = 2.0)
Editable Weight Matrix W_Q
Editable Weight Matrix W_K
Editable Weight Matrix W_V
Linear Algebra Matrices & Heatmaps Status: Computed
Query Matrix (Q) [2 x 4]
Key Matrix (K) [2 x 4]
Value Matrix (V) [2 x 4]
Attention Weights (S) [2 x 2]
Contextual Output (O = S · V) [2 x 4]
Step 1: Linear Projections
Calculating Q = X · W_Q...
Tokens: Thinking, Machines
d_model: 4
Attention Score [0,1]: 0.5000
Output Row 0 Sum: 0.0000
Enjoy this tool? Build your own with Super