Series

How Large Language Models Works

From Tokens to Transformers — Building an LLM from Scratch

Large language models generate fluent text, answer questions, and write code — but how do they actually work? This series starts with how text becomes numbers and builds up through embeddings, attention, the transformer architecture, training, and alignment.

Each article includes interactive demos so you can see the mechanisms in action. By the end, you'll understand every layer of a modern LLM — from raw bytes to RLHF.

How to read this series: Start from the top. Each article introduces ideas that later articles build on. By the end you'll have a complete mental model of how LLMs work — from tokenization to alignment.
  1. 001
    Beginner Tokenization & BPE

    How text becomes numbers

    13 min
  2. 002
    Beginner Embeddings & Vector Spaces

    How meaning lives in geometry

    13 min
  3. 003
    Intermediate The Attention Mechanism

    How models learn what to focus on

    16 min
  4. 004
    Intermediate Multi-Head Attention

    Why one attention head isn't enough

    9 min
  5. 005
    Intermediate The Transformer Block

    The building block of modern AI

    13 min
  6. 006
    Intermediate The GPT Architecture

    Decoder-only transformers and next-token prediction

    13 min

Training & Beyond

How LLMs learn from data, generate text, and get aligned with human preferences.

  1. 007
    Intermediate Training: Loss & Backpropagation

    How models learn from mistakes

    12 min
  2. 008
    Advanced Training in Practice

    From theory to GPU clusters

    10 min
  3. 009
    Intermediate Sampling & Generation

    From probabilities to prose

    12 min
  4. 010
    Advanced RLHF & Alignment

    Making models helpful, harmless, and honest

    13 min