Stage 4
Stage 4: LLMs & Generative AI
Goal: Understand how large language models work, then build real applications with the Claude API. Time: ~3 weeks at 30–60 minutes a day.
By the end of this stage you can:
- Explain tokens, next-token prediction, sampling and context windows
- Call the Claude API correctly: system prompts, structured output, errors
- Design prompts and measure them with evals
- Build vector search, RAG and tool-using agents
About the API examples
Lessons marked mock were executed against a local placeholder server (tools/mock_claude.py), so every line of SDK code is tested without an API key — but the printed replies are placeholder text, not real Claude answers, and each lesson says so where they appear. Set ANTHROPIC_API_KEY and run the same files to get real responses. Everything else (retrieval, evals, BPE, tool dispatch) runs fully offline with real output.
Parts
| Part | Area | You will build | Time |
|---|---|---|---|
| 13 | How LLMs work | A tiny language model sampled at three temperatures | ~2.5 h |
| 14 | Using LLM APIs | Ticket triage into a validated Pydantic schema | ~3 h |
| 15 | Prompt engineering | A prompt A/B test scored on labelled tickets | ~2.5 h |
| 16 | Embeddings and vector search | Help-centre search, with its measured failure cases | ~2.5 h |
| 17 | Retrieval-augmented generation | A support bot with citations and a retrieval eval | ~3 h |
| 18 | Tool use and agents | An order assistant with step limits and error-safe tools | ~3 h |
Stage project
Customer support assistant — RAG over the help centre with citations and an order-lookup tool, behind one answer() function with an eval.
The practice data
Stage 4 runs on tools/ailab.py's help centre: 8 support documents (returns, shipping, warranty, …) plus 8 labelled questions for measuring retrieval. The set is small on purpose, so every failure is inspectable by eye.