🛠️ Architecture Ingredients & Pre-Trained Weight Matrices
Below are all the static weight matrices and parameters assumed to be learned during model training. These exact values are referenced and multiplied throughout the interactive visualizations in this course:
1. Token Embedding Matrix (W E W_E W E )
Projects discrete token IDs into dense continuous embedding vectors (Vocab Size 5 × Model Dim 3 \text{Vocab Size } 5 \times \text{Model Dim } 3 Vocab Size 5 × Model Dim 3 ):
W E = [ 0.43 0.15 0.89 0.55 0.87 0.66 0.57 0.85 0.64 0.22 0.58 0.33 0.77 0.25 0.10 ] W_E = \begin{bmatrix} 0.43 & 0.15 & 0.89 \\ 0.55 & 0.87 & 0.66 \\ 0.57 & 0.85 & 0.64 \\ 0.22 & 0.58 & 0.33 \\ 0.77 & 0.25 & 0.10 \end{bmatrix} W E = 0.43 0.55 0.57 0.22 0.77 0.15 0.87 0.85 0.58 0.25 0.89 0.66 0.64 0.33 0.10
2. Positional Embedding Matrix (W P W_P W P )
Encodes spatial order information for sequence positions (Max Seq Len 5 × Model Dim 3 \text{Max Seq Len } 5 \times \text{Model Dim } 3 Max Seq Len 5 × Model Dim 3 ):
W P = [ 0.29 − 0.30 − 0.51 − 0.66 − 0.13 − 0.49 − 0.10 − 0.36 0.08 1.09 − 1.22 0.04 − 0.35 0.46 0.50 ] W_P = \begin{bmatrix} 0.29 & -0.30 & -0.51 \\ -0.66 & -0.13 & -0.49 \\ -0.10 & -0.36 & 0.08 \\ 1.09 & -1.22 & 0.04 \\ -0.35 & 0.46 & 0.50 \end{bmatrix} W P = 0.29 − 0.66 − 0.10 1.09 − 0.35 − 0.30 − 0.13 − 0.36 − 1.22 0.46 − 0.51 − 0.49 0.08 0.04 0.50
3. Query Weight Matrix (W Q W_Q W Q )
Projects input representations to Query vectors for Head 1 (Model Dim 3 × Head Dim 2 \text{Model Dim } 3 \times \text{Head Dim } 2 Model Dim 3 × Head Dim 2 ):
W Q = [ 0.5 − 0.2 0.1 0.8 − 0.4 0.3 ] W_Q = \begin{bmatrix} 0.5 & -0.2 \\ 0.1 & 0.8 \\ -0.4 & 0.3 \end{bmatrix} W Q = 0.5 0.1 − 0.4 − 0.2 0.8 0.3
4. Key Weight Matrix (W K W_K W K )
Projects input representations to Key vectors for Head 1 (Model Dim 3 × Head Dim 2 \text{Model Dim } 3 \times \text{Head Dim } 2 Model Dim 3 × Head Dim 2 ):
W K = [ − 0.3 0.6 0.7 − 0.1 0.2 0.5 ] W_K = \begin{bmatrix} -0.3 & 0.6 \\ 0.7 & -0.1 \\ 0.2 & 0.5 \end{bmatrix} W K = − 0.3 0.7 0.2 0.6 − 0.1 0.5
5. Value Weight Matrix (W V W_V W V )
Projects input representations to Value vectors for Head 1 (Model Dim 3 × Head Dim 2 \text{Model Dim } 3 \times \text{Head Dim } 2 Model Dim 3 × Head Dim 2 ):
W V = [ 0.4 − 0.3 0.1 0.8 − 0.5 0.2 ] W_V = \begin{bmatrix} 0.4 & -0.3 \\ 0.1 & 0.8 \\ -0.5 & 0.2 \end{bmatrix} W V = 0.4 0.1 − 0.5 − 0.3 0.8 0.2
6. Output Projection Matrix (W O W_O W O )
Projects multi-head concatenated outputs back to model dimensions (Concat Dim 6 × Model Dim 3 \text{Concat Dim } 6 \times \text{Model Dim } 3 Concat Dim 6 × Model Dim 3 ):
W O = [ 0.3 − 0.2 0.5 − 0.6 0.1 0.4 0.2 0.7 − 0.3 0.8 − 0.5 0.2 − 0.1 0.4 0.6 0.5 0.3 − 0.2 ] W_O = \begin{bmatrix} 0.3 & -0.2 & 0.5 \\ -0.6 & 0.1 & 0.4 \\ 0.2 & 0.7 & -0.3 \\ 0.8 & -0.5 & 0.2 \\ -0.1 & 0.4 & 0.6 \\ 0.5 & 0.3 & -0.2 \end{bmatrix} W O = 0.3 − 0.6 0.2 0.8 − 0.1 0.5 − 0.2 0.1 0.7 − 0.5 0.4 0.3 0.5 0.4 − 0.3 0.2 0.6 − 0.2
7. LayerNorm 1 Parameters (γ , β \gamma, \beta γ , β )
Learned element-wise scaling (γ \gamma γ ) and shifting (β \beta β ) parameters for 1st Layer Normalization:
γ = [ 1.0 1.0 1.0 ] , β = [ 0.0 0.0 0.0 ] \gamma = \begin{bmatrix} 1.0 & 1.0 & 1.0 \end{bmatrix}, \quad \beta = \begin{bmatrix} 0.0 & 0.0 & 0.0 \end{bmatrix} γ = [ 1.0 1.0 1.0 ] , β = [ 0.0 0.0 0.0 ]
8. FFN Linear Layer 1 Weight Matrix (W 1 W_1 W 1 ) (+ bias)
Expands feature space (Model Dim 3 × Hidden Dim 6 \text{Model Dim } 3 \times \text{Hidden Dim } 6 Model Dim 3 × Hidden Dim 6 ) with zero initial bias vector b 1 b_1 b 1 :
W 1 = [ 0.4 − 0.2 0.1 0.6 − 0.5 0.3 − 0.1 0.8 − 0.4 0.2 0.7 − 0.6 0.5 0.3 0.9 − 0.2 0.1 0.4 ] , b 1 = [ 0 0 0 0 0 0 ] W_1 = \begin{bmatrix} 0.4 & -0.2 & 0.1 & 0.6 & -0.5 & 0.3 \\ -0.1 & 0.8 & -0.4 & 0.2 & 0.7 & -0.6 \\ 0.5 & 0.3 & 0.9 & -0.2 & 0.1 & 0.4 \end{bmatrix}, \quad b_1 = \begin{bmatrix} 0 & 0 & 0 & 0 & 0 & 0 \end{bmatrix} W 1 = 0.4 − 0.1 0.5 − 0.2 0.8 0.3 0.1 − 0.4 0.9 0.6 0.2 − 0.2 − 0.5 0.7 0.1 0.3 − 0.6 0.4 , b 1 = [ 0 0 0 0 0 0 ]
9. FFN Linear Layer 2 Weight Matrix (W 2 W_2 W 2 ) (+ bias)
Projects back to model space (Hidden Dim 6 × Model Dim 3 \text{Hidden Dim } 6 \times \text{Model Dim } 3 Hidden Dim 6 × Model Dim 3 ) with zero initial bias vector b 2 b_2 b 2 :
W 2 = [ 0.2 − 0.4 0.5 − 0.3 0.6 0.1 0.7 − 0.2 − 0.5 0.1 0.3 0.8 − 0.6 0.5 0.2 0.4 − 0.1 0.3 ] , b 2 = [ 0 0 0 ] W_2 = \begin{bmatrix} 0.2 & -0.4 & 0.5 \\ -0.3 & 0.6 & 0.1 \\ 0.7 & -0.2 & -0.5 \\ 0.1 & 0.3 & 0.8 \\ -0.6 & 0.5 & 0.2 \\ 0.4 & -0.1 & 0.3 \end{bmatrix}, \quad b_2 = \begin{bmatrix} 0 & 0 & 0 \end{bmatrix} W 2 = 0.2 − 0.3 0.7 0.1 − 0.6 0.4 − 0.4 0.6 − 0.2 0.3 0.5 − 0.1 0.5 0.1 − 0.5 0.8 0.2 0.3 , b 2 = [ 0 0 0 ]
10. LayerNorm 2 Parameters (γ , β \gamma, \beta γ , β )
Learned element-wise scaling (γ \gamma γ ) and shifting (β \beta β ) parameters for 2nd Layer Normalization:
γ = [ 1.0 1.0 1.0 ] , β = [ 0.0 0.0 0.0 ] \gamma = \begin{bmatrix} 1.0 & 1.0 & 1.0 \end{bmatrix}, \quad \beta = \begin{bmatrix} 0.0 & 0.0 & 0.0 \end{bmatrix} γ = [ 1.0 1.0 1.0 ] , β = [ 0.0 0.0 0.0 ]
🎯 Post-Transformer Block (LM Head)
11. LM Head Matrix (W LM Head W_{\text{LM Head}} W LM Head )
Projects final hidden state to vocabulary logit scores (Model Dim 3 × Vocab Size 5 \text{Model Dim } 3 \times \text{Vocab Size } 5 Model Dim 3 × Vocab Size 5 ):
W LM Head = [ 0.3 − 0.2 0.7 0.1 − 0.4 − 0.5 0.8 − 0.1 0.6 0.2 0.4 0.3 − 0.6 0.5 − 0.7 ] W_{\text{LM Head}} = \begin{bmatrix} 0.3 & -0.2 & 0.7 & 0.1 & -0.4 \\ -0.5 & 0.8 & -0.1 & 0.6 & 0.2 \\ 0.4 & 0.3 & -0.6 & 0.5 & -0.7 \end{bmatrix} W LM Head = 0.3 − 0.5 0.4 − 0.2 0.8 0.3 0.7 − 0.1 − 0.6 0.1 0.6 0.5 − 0.4 0.2 − 0.7