AI Engineering in Practice: From Calling an LLM to Writing Your Own GPT
A free AI course for developers. First build things that work with large language models, then implement neural networks and a Transformer from scratch to see why they work.
Code and program output are shown exactly as they ran, so comments and printed output are in Chinese.
This course comes in two halves.
The first half teaches you to use large language models: calling APIs, writing prompts, answering questions over your own documents, building agents, and finally evaluating the result and putting it online. By the end you can build an AI application that real people use, on your own.
The second half teaches you to understand them: gradient descent and backpropagation written by hand in numpy, a small GPT built from scratch in PyTorch and trained to write classical Chinese poems, and a LoRA fine-tune done yourself. After that, words like "attention", "KV cache" and "quantization" will bring concrete code to mind instead of fog.
The halves can be taken separately. If you only want to build applications, the first part is enough. If you already build them and want the theory underneath, you can start straight at the second part.
One project runs through the course
Most of the first part builds a single thing: a Q&A assistant for the open-source library httpx, which we call RepoBot.
It starts as a command-line chat program, then learns to answer questions from the project's documentation, then to search the docs and read the source code by itself, and finally gets an evaluation set, logging and guardrails and becomes a web service. Each module adds one piece, so you watch an AI application grow step by step.
Part 1: Building with LLMs
API calls, prompting, RAG, agents, evaluation and deployment, around one real Q&A assistant project.
Pick your route through the course, set up Python, get an API key for a large language model, and make your first call.
3 lessonsModule 01What an LLM actually isWith no math at all, work out the basic facts about large language models by experiment: tokens, next-token prediction, temperature, context and cost, embeddings, and how to choose a model.
6 lessonsModule 02PromptingComparison experiments that make clear how a prompt is structured, few-shot examples, thinking before answering and JSON output, ending with a small tool for testing prompts in bulk.
5 lessonsModule 03Building apps on the APIFrom a single call to a real program: multi-turn chat, streaming, tool calling, error retries and cost tracking, ending with the first version of the running project, RepoBot.
5 lessonsModule 04RAG, letting the model read your materialBuild a retrieval-augmented generation system from scratch: chunking documents, vector search, keyword search, query rewriting, reranking, answers with citations and evaluation, and finally teach RepoBot the httpx documentation.
7 lessonsModule 05AgentsFirst decide whether you need an agent at all, then write one from scratch: tool design, planning and self-checking, memory, multiple agents, MCP and security, and finally teach RepoBot to read the source on its own.
9 lessonsModule 06Evaluation and going liveBuild an evaluation set, use a model as a judge and calibrate it, log every step, cut cost and latency, add input and output guardrails, and finally deploy RepoBot as a web service.
6 lessonsModule 07Writing code with AIThe forms AI coding tools take and what each suits; how to use a project instructions file so it understands your project; and a dependable workflow: set acceptance criteria first, change things in small steps, and judge whether it's done by tests rather than by the AI's own account.
3 lessonsPart 2: Understanding LLMs from scratch
Backpropagation by hand, a small GPT built and trained from scratch, then LoRA fine-tuning and local deployment.
Start from a straight line, write gradient descent and backpropagation by hand, train a first small network, then switch to PyTorch to recognise handwritten digits, and see overfitting and the ways to fight it with your own eyes.
6 lessonsModule 09Implementing a Transformer from scratchWrite a tokenizer and attention by hand, build a complete small GPT, train it on over thirty thousand Tang poems until it can write poetry, then cover generation, the KV cache, and what's still missing between a small GPT and a real LLM.
7 lessonsModule 10Fine-tuning and local deploymentFirst work out when fine-tuning is the right call, then write LoRA by hand, fine-tune a small open-source model with peft, estimate memory, write quantisation by hand, run a model on your own computer with Ollama, and finally understand what serving frameworks like vLLM solve.
5 lessonsModule 11Capstone projectUse everything from the course to build an AI project on a topic of your own choosing, start to finish on your own: set what done looks like, build something usable, show how good it is with evaluation, and finally write it up clearly for others.
1 lessonsWhat you need to know first
- Basic Python: functions, lists, dictionaries, classes, and installing packages with
piporuv. - Basic command line:
cdand running a script. - Math: none at all for the first part. The derivatives and matrix multiplication in the second part are explained from the beginning; high-school math is enough.
No GPU is needed. The first part only calls APIs. Every experiment in the second part runs on an ordinary laptop CPU: training the small GPT takes about 7 minutes, and fine-tuning a 500-million-parameter open model takes a dozen seconds. Only the last lesson of module 10, on vLLM, needs a server with an NVIDIA GPU, and it says so.
What it costs
The first part calls an LLM API, DeepSeek by default. Running every example and exercise in the first part usually costs less than 10 CNY, about US$1.40 (at September 2026 prices). You can swap in any service with an OpenAI-compatible API, or run models locally with Ollama for free, with somewhat weaker results. The second part calls no API and costs nothing.
Where the code is
Each lesson's code is in the matching module directory under code/, and the four versions of RepoBot are under projects/repobot/. Every output shown in a lesson came from a real run while the lesson was written, and each lesson notes the date, model or software versions of that run at the top. Code that doesn't call an API uses fixed random seeds, so you should get the same numbers or very close ones.
How to get the most out of it
Type every lesson's code yourself, or at the very least run it yourself. Then do the exercises, especially the ones that say "change one thing and see what happens". Reading without doing throws away most of what this course has to offer.