Understanding Self-Attention – Part 1

LLM Architecture Series – Lesson 7 of 20. So far each position has a clean, normalised embedding. Now the model needs a way for each position to look at other positions.

Self attention lets every token decide which other tokens are important for predicting the next output.

(more…)

Layer Normalization in Transformers

LLM Architecture Series – Lesson 6 of 20. At this point each position has a combined embedding. Before attention or feed forward layers, the model often applies layer normalisation.

Layer normalisation rescales activations so that the following layers behave in a stable and predictable way.

(more…)

The Combined Input Embedding

LLM Architecture Series – Lesson 5 of 20. You have seen token embeddings and position embeddings. Now we put them together into the actual input that flows into the transformer.

This combined embedding is what every later layer sees for each position in the sequence.

(more…)

Position Embeddings – Encoding Word Order

LLM Architecture Series – Lesson 4 of 20. So far we know the meaning of each token. Now we teach the model where each token sits in the sequence.

Position embeddings make it possible for the model to tell the difference between subject and object, start and end, and repeated words at different places.

(more…)

Introduction to Large Language Models

LLM Architecture Series – Lesson 1 of 20. This article gives you the big picture of a modern language model before we zoom into each part.

You can think of a large language model as a very advanced auto complete engine that predicts the next token based on everything it has seen so far.

(more…)

LLM Architecture Series – Complete Guide

LLM Architecture Overview - Annotated

Visualisation from bbycroft.net/llm – Annotated with Nano Banana

Welcome to the LLM Architecture Series

This comprehensive 20-part series takes you from the fundamentals to advanced concepts in Large Language Model architecture. Using interactive visualisations from Brendan Bycroft’s excellent LLM Visualisation, we explore every component of a GPT-style transformer.

Series Overview

Part 1: Foundations (Articles 1-5)

  1. Introduction to Large Language Models – What LLMs are and how they work
  2. Tokenization Basics – Converting text to tokens
  3. Token Embeddings – Converting tokens to vectors
  4. Position Embeddings – Encoding word order
  5. Combined Input Embedding – Putting it together

Part 2: The Transformer Block (Articles 6-14)

  1. Layer Normalisation – Stabilizing the network
  2. Self-Attention Part 1 – The core innovation
  3. Self-Attention Part 2 – Multi-head attention
  4. Query, Key, Value – The attention framework
  5. Causal Masking – Preventing future leakage
  6. Attention Softmax – Computing attention weights
  7. Projection Layer – Combining attention outputs
  8. Feed-Forward Networks – The MLP component
  9. Residual Connections – Skip connections for depth

Part 3: The Complete Model (Articles 15-20)

  1. Complete Transformer Block – All components together
  2. Stacking Layers – Building depth
  3. Output Layer – The language model head
  4. Output Softmax – From logits to probabilities
  5. Scaling LLMs – From nano-GPT to GPT-3
  6. Complete Pipeline – The full picture

About This Series

Each article includes:

  • Interactive visualisations from bbycroft.net/llm
  • Mathematical equations explaining each component
  • Intuitive explanations of why each part matters
  • Navigation links to previous and next articles

Start Learning

Begin with: Introduction to Large Language Models


Interactive visualisations courtesy of bbycroft.net/llm by Brendan Bycroft. Annotated images created with Nano Banana.

AI Inference Pipeline Explained

Inference

AI Inference: From Input to Output

Inference is when a trained model makes predictions on new data. While training happens once, inference runs millions of times in production. Understanding the inference pipeline is crucial for deploying AI systems that are fast, efficient, and reliable.

The pipeline involves preprocessing inputs (tokenizing text, resizing images, normalising values), running the forward pass through model layers, and postprocessing outputs (decoding tokens, formatting responses, applying thresholds). Each stage offers optimisation opportunities.

Common optimisations include quantization (reducing precision from FP32 to INT8), pruning (removing unimportant weights), distillation (training smaller models to mimic larger ones), and batching (processing multiple inputs together for GPU efficiency).

Latency considerations matter for user experience. First token latency determines perceived responsiveness. Tokens per second affects total generation time. For production systems, balance quality against speed based on your specific use case and user expectations.