Full Model & Output Logits
Project final 64D hidden states into vocabulary logits via tied projection matrix W_u = W_e, followed by Softmax.
Now we connect the whole pipeline: token embeddings + position embeddings → 4 stacked transformer blocks → final LayerNorm → linear projection head. The output is an unnormalized score (logit) for each word in the vocabulary. Softmax turns these into probabilities.
Our bilingual model has ~185K parameters with 4 layers and d_model=64. GPT-2 Small has 117M (same architecture, 12 layers, 768D). GPT-3 has 175B. The architectural pipeline is identical - only width and depth scale.
GPT Forward Pass
Model Specifications (Shakespeare + Hafez Bilingual LM)
Next-Token Probability Distribution (Prompt: "To be or not to...")
- The full GPT pipeline: Embed -> Position -> 4x Block -> Final LayerNorm -> Output Linear Head.
- Weight tying shares the 256x64 matrix between token embedding and the output projection head.
- Temperature tau scales logits prior to softmax: tau -> 0 chooses top token deterministically, tau -> inf yields uniform random guessing.
- The output logits array represents unnormalized energy scores across all 256 vocabulary subwords.
Slide temperature down to 0.1 and notice how probability concentrates on 'be' (98%+), then slide up to 1.8 to see entropy flatten.