Test the Model
Running entirely in your browser using ONNX Runtime WebGL/WASM
Advanced Generation Settings
Tokenizer Playground
See how the Byte-Pair Encoding (BPE) algorithm splits text into subwords.
Architecture & Math
Explore the mathematical foundations of the Transformer architecture through interactive data flow.
1. Token Embedding
Each token ID acts as an index to look up a dense continuous vector from the embedding matrix. This vector represents the semantic meaning of the token.
2. Rotary Positional Embedding (RoPE)
RoPE injects positional information by rotating the Query and Key vectors in a 2D plane based on their position in the sequence.
3. Root Mean Square Normalization (RMSNorm)
Unlike LayerNorm, RMSNorm doesn't center the mean to zero, it simply scales the vector by its Root Mean Square. Adjust the input variance below to see the bars normalize!
4. Causal Self-Attention
Words attend to previous words to build context. Future tokens are masked out (grayed out). Hover or click a token to see its attention fan!
5. SwiGLU FFN
The Feed-Forward Network splits the input into two branches. One branch applies the non-linear SiLU activation to act as a "gate", controlling how much of the other branch's linear projection passes through via a Hadamard (element-wise) product.
6. Output Head
The final vector is projected back to the vocabulary size (1978 tokens). We apply Temperature scaling and Softmax to get a probability distribution, then sample the next token!
Reference: Consolidated Mathematical Equations
Training Pipeline
How the model learns from raw data.
Source Reference
Explore the actual codebase implementation.