The transformer architecture from the 2017 "Attention Is All You Need" paper is not what's running inside modern LLMs. Llama, Mistral, and GPT-era models all use a modified version with 4 key upgrades. Here's what changed and why it matters: 1. RMS Norm instead of Layer Norm Layer Norm did 4 operations — calculate mean, center around zero, calculate variance, normalize. Researchers found that centering around zero wasn't actually doing anything useful. What matters is just keeping numbers in bounds. So they removed it. RMS Norm does 2 operations instead of 4. Since normalization runs after every single layer in a deep model, this compounds into a significant efficiency gain. They also moved normalization to run before each layer rather than after — giving the model cleaner inputs from step one. 2. SwiGLU instead of ReLU ReLU has a hard cutoff at zero — negative values get zeroed out completely. The problem is small negative values often carry meaningful information. SwiGLU introduces a learned gating mechanism — one path decides what information matters, another carries the raw signal, and they're multiplied together. The gate is trained alongside the model, so it gets progressively better at filtering signal from noise. Every major frontier model uses this today. 3. RoPE instead of Sinusoidal Positional Embeddings Original positional embeddings were purely absolute — each token only knew its own position number. This meant the same phrase appearing at different positions in a sequence was treated as completely different information, forcing the model to re-learn it each time. RoPE encodes relative distance instead. By rotating Query and Key vectors based on position, the angle between any two tokens reflects how far apart they are — regardless of where they appear in absolute terms. This is why the clock analogy works: 12 and 2 have a 60 degree gap. 7 and 9 have the same 60 degree gap. Relative distance preserved. 4. Group Query Attention instead of Multi-Head Attention Standard multi-head attention stores separate Key and Value vectors for every head — memory scales linearly with heads and sequence length. Multi-Query Attention tried collapsing all heads to share one K and V pair — too much compression, performance degraded. Group Query Attention found the middle ground: group heads in pairs, each pair shares one K and V. Memory reduced by half. Performance nearly identical to full multi-head. This is the standard in production-scale models today. These four changes — faster normalization, smarter activation, relative position encoding, and memory-efficient attention — are what made the transformer actually viable at scale. #MachineLearning #DeepLearning #ArtificialIntelligence #LLM #Transformers #AIEngineering #GenerativeAI #BuildInPublic #LearnInPublic #DataScience

To view or add a comment, sign in

Explore content categories