Free courseBeginner to advanced
How to Build Claude from Scratch
Understand how modern AI assistants work and build your own Claude-like AI system from the ground up.
- 12modules
- 98lessons
- 27 h 21 minreading
- ~68 hwith exercises
The 12 modules
-
1 Understanding Claude and Modern AIThe map before the journey: what an AI assistant really is, how a message becomes an answer, and the vocabulary (tokens, context, embeddings) the rest of the course builds on.
- 1.1What is Claude?
- 1.2What is an LLM?
- 1.3How ChatGPT, Claude, Gemini and other AI assistants work
- 1.4AI, machine learning, deep learning, transformers and LLMs
- 1.5What happens when you send a message to an AI?
- 1.6Tokens, context windows and embeddings
-
2 Mathematics and FoundationsJust enough maths to read any transformer paper: every idea is shown as a picture first, then as an equation, then as a few lines of NumPy.
- 2.1Essential linear algebra
- 2.2Vectors, matrices and matrix multiplication
- 2.3Probability and statistics
- 2.4Softmax, gradients and loss functions
- 2.5Neural networks and backpropagation
- 2.6Practical Python demonstrations
-
3 Build a Neural Network from ScratchNo frameworks: we write every neuron, every derivative and every update by hand, then watch the network learn.
- 3.1Set up Python and NumPy
- 3.2Build neurons and layers
- 3.3Implement forward propagation
- 3.4Implement backpropagation
- 3.5Implement gradient descent
- 3.6Train a small neural network without PyTorch or TensorFlow
- 3.7Visualize training and loss
-
4 Understanding TransformersThe architecture behind every modern LLM, taken apart piece by piece, with attention you can poke at and a working transformer block in NumPy.
- 4.1Why traditional RNNs have limitations
- 4.2The transformer architecture
- 4.3Tokenization and embeddings
- 4.4Positional encoding
- 4.5Self-attention and multi-head attention
- 4.6Query, Key and Value explained visually
- 4.7Feed-forward networks
- 4.8Layer normalization and residual connections
- 4.9Implement a simplified transformer in NumPy
-
5 Build a GPT-like Language ModelWe put the pieces together into a real (tiny) language model, train it on a small text, generate with it, and look honestly at why it makes things up.
- 5.1Tokenizer implementation
- 5.2Vocabulary creation
- 5.3Dataset preparation
- 5.4Next-token prediction
- 5.5Building a decoder-only transformer
- 5.6Training a tiny language model
- 5.7Text generation and temperature
- 5.8Top-k and top-p sampling
- 5.9Understanding hallucinations and limitations
-
6 How Claude Is DifferentA pretrained model is not an assistant. This module covers the publicly documented techniques that turn one into a helpful, honest and harmless assistant, and is clear about what Anthropic has not published.
- 6.1Claude's architecture at a conceptual level
- 6.2Constitutional AI
- 6.3Supervised fine-tuning
- 6.4Reinforcement learning from human feedback
- 6.5Preference optimization
- 6.6Safety training and alignment
- 6.7System prompts and instruction following
- 6.8Long-context processing
- 6.9Tool use and agentic behavior
-
7 Build Your Own AI AssistantThe part users see. We design and build a chat interface with plain web technology, and handle the hard details: streaming, history that fits the context window, safe Markdown and failures.
- 7.1Design a Claude-like chat interface
- 7.2Conversation management
- 7.3System instructions
- 7.4Chat history and context management
- 7.5Streaming responses
- 7.6Markdown and code rendering
- 7.7Syntax highlighting
- 7.8Error handling
- 7.9File upload and document understanding concepts
- 7.10Building a frontend chatbot
-
8 Memory and RAGA model only knows its training data and what is in the prompt. This module teaches the two ways around that: memory and retrieval, built from scratch so nothing is magic.
- 8.1What is AI memory?
- 8.2Short-term vs long-term memory
- 8.3Embeddings and vector databases
- 8.4Semantic search
- 8.5Retrieval-Augmented Generation (RAG)
- 8.6Chunking and document retrieval
- 8.7Build a basic document Q&A system
- 8.8Context injection and source citations
-
9 Function Calling and AI AgentsA model that can only write text becomes an agent when it can ask your code to do things. We build the loop, the tools and, just as important, the limits.
- 9.1What is function calling?
- 9.2Tool definitions and JSON schemas
- 9.3Calling external tools
- 9.4Tool execution loops
- 9.5Search, calculator and other tools
- 9.6Multi-step reasoning and planning
- 9.7Agent architecture
- 9.8Safety restrictions and tool permissions
- 9.9Build a basic tool-using AI agent
-
10 Fine-Tuning and TrainingWhat it takes to change what a model knows or how it behaves, with honest numbers: what fits on your laptop, what needs a rented GPU, and what only a frontier lab can afford.
- 10.1Pretraining vs fine-tuning
- 10.2Dataset collection and cleaning
- 10.3Instruction datasets
- 10.4Fine-tuning concepts
- 10.5LoRA and QLoRA
- 10.6GPU and VRAM requirements
- 10.7Training costs and realistic hardware requirements
- 10.8Model evaluation and benchmarking
-
11 Deployment and ProductionFrom "it works in a notebook" to a service people can rely on: making inference fast and cheap, running open models locally, and operating an AI API safely.
- 11.1Model inference
- 11.2Quantization
- 11.3CPU vs GPU inference
- 11.4Running open-source LLMs locally
- 11.5Ollama and Hugging Face concepts
- 11.6API design
- 11.7Docker deployment
- 11.8Monitoring and logging
- 11.9Security, rate limiting and cost optimization
-
12 Final Capstone Project: Your Own Claude-like AssistantEverything comes together: a complete assistant that runs in the browser, talks to a model provider you choose (including a local open model), reads your documents, remembers and uses tools.
- 12.1Capstone overview and architecture
- 12.2The conversational UI
- 12.3Conversation history and system prompts
- 12.4Streaming output with Markdown and code
- 12.5Configurable model providers and error handling
- 12.6Document Q&A and memory
- 12.7Tool calling
- 12.8Testing, deployment and the capstone challenge
Pick up where you left off
★ Your bookmarks
What you will be able to do
- Explain how an AI assistant worksFrom the characters you type to tokens, embeddings, attention, probabilities and the reply, in plain words and in maths.
- Read the maths without fearVectors, matrix multiplication, softmax, cross-entropy, gradients and backpropagation, each shown as a picture first.
- Train a neural network by handForward pass, backward pass and gradient descent in NumPy only, no PyTorch, and watch the loss fall.
- Build a transformer and a tiny GPTTokenizer, embeddings, positional encoding, multi-head self-attention, a decoder-only model, training and sampling.
- Understand how Claude is trainedSFT, RLHF, preference optimisation and Constitutional AI as publicly described, and what remains proprietary.
- Ship a real assistantA chat UI with streaming, Markdown, history, documents (RAG), memory and tool calling, on a model provider you choose.
- Make sensible engineering callsWhen to prompt, retrieve, fine-tune with LoRA or quantise; how much GPU memory and money each one needs.
- Run it in productionLocal open models with Ollama, an API with streaming, Docker, monitoring, rate limits, security and cost control.
An honest note before you start
What "build Claude from scratch" means here
You will build every kind of part a Claude-like assistant has: the model architecture, training, sampling, the chat application, retrieval, memory and tools. Your model will be tiny, trained in seconds on a few kilobytes of text. It shows how the real thing works; it is not a replacement for it.
What this course does not claim
Claude is made by Anthropic. Its exact architecture, size, training data and training recipe are not public, and this course does not pretend to know them. Module 6 separates what Anthropic has published (for example Constitutional AI) from general industry practice and from what is unknown.
The scale of frontier models
Training a frontier model takes thousands of specialised GPUs running for months, trillions of tokens of data and budgets in the tens to hundreds of millions of dollars. The practical path for an individual is to use an existing model through an API or run an open-weight model locally, and to fine-tune small models with LoRA. Module 10 has the numbers.
How the course works
Who it is for
You can write basic code in any language (variables, loops, functions). You do not need a maths degree or any AI experience: each idea starts with an analogy and the intuition, then the equation, then the code. Lessons are marked Beginner, Intermediate or Advanced.
Every lesson has
Learning objectives, an explanation with an analogy and a deeper technical part, diagrams or an interactive demo, real code explained line by line with the output you should see, common mistakes, an exercise with hints, and a knowledge check.
Running the code
Python examples use only Python 3 and NumPy and were run before publishing. Many have a ▶ Run button that runs them in your browser with Pyodide (a Python runtime of about 15 MB, downloaded only if you press it). The expected output is always shown, so you can follow along without running anything.
Your progress
Mark lessons complete, bookmark the ones to revisit, search every lesson, and resume where you stopped. Progress is saved in this browser only (localStorage); there is no account and nothing is sent anywhere. You can delete it on the privacy page.
The capstone: your own assistant
Module 12 brings everything together into one application you can keep using: a responsive chat interface with conversation history, streaming replies, Markdown and highlighted code, editable system prompts, document question answering with citations, long-term memory, tool calling, clear error handling and a switch between model providers: a built-in offline demo model, an open model running on your own computer with Ollama, or any OpenAI-compatible endpoint you configure. It runs as static files with no server of its own.
See the capstone module →Frequently asked questions
Is this course really free?
Yes. There is no sign-up, no paywall and no paid API is required. The optional exercises that call a hosted model say so and offer a free local alternative (an open model with Ollama).
Will I have built Claude at the end?
No, and no course can give you that. You will have built a small working language model that shows every core idea, and a complete assistant application that can use a real open-weight model or an API. You will understand what makes frontier assistants different: scale, data, and the post-training that teaches them to be helpful, honest and harmless.
What do I need on my computer?
For modules 1 to 6: Python 3.10 or newer and NumPy (pip install numpy), or just your browser with the ▶ Run buttons. For modules 7 to 9 and 12: a text editor and a browser. Running local models (module 11) works best with 16 GB of RAM; a GPU helps but is not required for small models.
How long does it take?
The reading time is shown on every lesson. Doing the exercises and mini-projects roughly doubles or triples it; the overview's estimate assumes about two and a half times the reading time.
Do I need to do the modules in order?
Modules 1 to 5 build on each other. If you only want to build applications on top of existing models, you can read module 1, skim module 6 and jump to module 7.