Understand large language models,from first principles to the frontier

Follow a learning path from Transformers to training, inference, and agents. Check the math in runnable Python labs and trace each method back to its sources in the paper explainers.

Attention in one sentence

it Attends most to cat 58%

can't see later words

Select or hover a word to see which earlier words it attends to. The weights are hand-set for illustration, not real model output.

Wiki contents

4 parts and 12 chapters, in learning order from foundations to frontier topics. Read it front to back, or jump straight to any chapter.

Part 1

Understand LLMs

What is an LLM, what is it made of, and why is each part designed the way it is?

  1. Getting Started New to large language models? Build an end-to-end picture first, then pick one of four study routes (weekend crash course, application development, engineering or research), and see how this wiki is organized and meant to be read. 4 pages · 81 min
  2. Foundations Language modeling, neural networks, information theory, tokens and embeddings, and optimizers: the lowest-level primitives of an LLM, and the reason behind almost every design decision that follows. 6 pages · about 2 h
  3. Model Architecture From the bottleneck of RNNs to attention, then the complete Transformer block, RoPE, GQA, MoE, long context, and the state space models and hybrids that trade the KV cache for a fixed-size state: the structure of modern LLMs and the reasoning behind each choice. 9 pages · about 4.5 h

Part 2

Train LLMs

How do you train a model on a finite budget of compute and data, then teach it to follow instructions and reason?

  1. Compute and Systems GPU compute and bandwidth, the roofline model, numerical precision and collective communication. The same algorithm can differ tenfold in speed with another implementation, batch size or precision, so the hardware limits have to be understood first. 5 pages · about 2.5 h
  2. Pre-training The training pipeline, data engineering (filtering, deduplication, mixing), scaling laws, the compute and memory ledger and distributed parallelism: the engineering and scientific decisions that turn raw text into usable weights for a base model. 5 pages · about 3 h
  3. Post-training and Alignment SFT, LoRA, reward models, reinforcement learning basics (policy gradients, advantages, PPO), preference optimization (RLHF and DPO) and reinforcement learning for reasoning: how a base model is shaped into something useful and controllable that learns to solve problems deliberately. 7 pages · about 5 h

Part 3

Deploy and apply

How do you run a model fast and cheaply, and turn it into a reliable application?

  1. Inference and Serving Decoding and sampling, the KV cache, quantization, inference serving, continuous batching and speculative decoding: how to run LLMs fast and cheaply, and how to see the trade-offs between latency, throughput and memory. 8 pages · about 3 h
  2. Applications Prompt engineering, structured outputs and function calling, RAG, agents, and MCP and the tool ecosystem: the engineering methods that turn a model that can talk into a product that is reliable, measurable and easy to iterate on. 8 pages · about 5.5 h
  3. Multimodal How vision and language are aligned, and how images are generated: from CLIP, LLaVA and the token cost of an image to how diffusion and flow matching build images, robot actions and text from noise, the core structures and limits of multimodal models. 3 pages · about 1.5 h

Part 4

Evaluate, secure, look ahead

How do you know whether a model is good and safe, and where is the technology heading?

  1. Evaluation How to show that a model got stronger: what benchmarks measure, the statistics of evaluation (pass@k, confidence intervals, sample size), LLM-as-a-Judge, building an evaluation set with reliable labels, and how benchmark contamination arises and is detected. 6 pages · about 2.5 h
  2. Safety and Alignment Risks LLMs make up plausible content, get hijacked by prompt injection, are talked past guardrails by jailbreaks, and repeat training-data secrets. This chapter sorts these risks into reproducible categories with threat models, measurements and defenses; most defenses are system design. 3 pages · about 2.5 h
  3. Frontier The fastest-moving directions in LLMs and the lasting questions behind each. For now: test-time compute (how inference compute buys accuracy), synthetic data (when model-made data helps or collapses) and mechanistic interpretability (finding features and circuits inside the network). 3 pages · about 2 h

Paper breakdowns and engineering notes

Close readings of important papers, and the real trade-offs from training and deployment.

DeepSeek-V4.1-Flash: Getting the Global KV Cache Down to 890 Bytes per Token

DeepSeek-V4.1-Flash cuts the global KV cache to 890 bytes per token, about 1/4 of V4-Flash and 1/437 of DeepSeek-V1, with a causal encoder-decoder, cross-layer sharing in CSA2 and an FP4 main KV. This post explains the paper and rebuilds its numbers from the public configs.

Paper notes arXiv 2026

GDPO: Why Multi-Reward RL Should Normalize Each Reward on Its Own

GDPO is NVIDIA's January 2026 fix for multi-reward RL. GRPO sums the rewards before normalizing, which can collapse different reward combinations into one advantage; GDPO normalizes each reward first. This post re-enumerates the paper's counts and flags claims that do not check out.

Paper notes arXiv 2026

mHC: Keeping a Wider Residual Stream Stable With Doubly Stochastic Mixing

mHC (Manifold-Constrained Hyper-Connections) is DeepSeek's fix for hyper-connections: Sinkhorn-Knopp turns the residual mixing matrix into a doubly stochastic one, keeping multi-layer gain bounded, for a reported 6.7% extra training time. This post reviews it and checks the math in code.

Paper notes arXiv 2025

All posts

How we write

  • Answer first

    Each page opens with a short answer to what it is and why it matters, then goes into derivations and detail.

  • Math explained, code runnable

    Every symbol in a formula is defined, and code is kept small enough to run as-is.

  • Sources you can check

    Key claims link to the paper or official docs. Pages show their update date, and errors can be reported on GitHub.

  • Learn in six languages

    Read in Chinese, English, Spanish, French, Japanese or Hindi, and switch directly between available translations.