# Most explanations of LLMs stop at "it predicts the next word." Here is what a...
Canonical: https://social-archive.org/richeddy/clcOqiKYHq
Original URL: https://www.facebook.com/permalink.php?story_fbid=pfbid02hdwztHdNtb6EZ6aCs9nSAr1MunTiccDwzMTXRn81qxfUCsRJk4gGokKG3taWHtZsl&id=61587140477975
Author: Codewithbrij
Platform: facebook
Share mode: full
## Content
Most explanations of LLMs stop at "it predicts the next word." Here is what actually happens inside the model. 1. Tokenizer: "What is gravity?" is split into subword tokens and mapped to integer IDs. 2. Embeddings: each ID looks up a learned vector. In Llama 3 8B, that vector has 4,096 numbers. 3. Transformer blocks: multi-head self-attention computes softmax(QKᵀ/√d)·V, so every token weighs every earlier token. A feed-forward network (SwiGLU in Llama) transforms the result. This repeats across N layers, 32 in Llama 3 8B. 4. LM head: the final vector is projected onto the whole vocabulary (about 128K tokens in Llama 3) and turned into probabilities. 5. Sampling: greedy, top-k, top-p and temperature decide which token is picked. 6. Speculative decoding: a small draft model proposes several tokens, and the large model verifies them all in one pass. Why some models feel fast and others slow: Prefill processes your whole prompt in parallel and is compute-bound. Decode generates one token per step and is memory-bandwidth-bound. The KV cache grows with every token, and is often the real bottleneck. FlashAttention and INT8/INT4 quantization exist to fight exactly these limits. Save this one. It is the mental model behind every inference optimization you will read about. #LLM #DeepLearning #AIEngineering
## Media
1. image: https://social-archiver-api.social-archive.org/media/archives/richeddy/vTwOOxn9Ms/00-image.jpg
