Applied AI Engineering
From Tokens to Agents with Python and Local Models
Follow one project, an assistant for Bella's Pizza, from a first question to a local model to an agent that checks orders and answers from the shop's documents. Every program runs on your own computer through Ollama.
What you will learn
- Explain what happens between typing a question and an AI agent acting on it.
- Call a local language model from plain Python, and read exactly what is sent and returned.
- Explain tokens, embeddings, attention and temperature in plain words, with working code.
- Ground an answer in documents, and check it, knowing that a fluent answer proves nothing by itself.
- Give a model tools and an agent loop, and measure the result with a small evaluation.
In preparation.
Requirements
Section titled “Requirements”You need a computer that runs Python and Ollama. The book’s code uses only the Python standard library, so there are no packages to install for the examples. The tests need pytest.
- Python 3.10 or newer. The book uses Python 3.13.
- Ollama, the local model runtime, running on your computer.
qwen3:8b, the default chat model. It is about 5.2 GB and runs on a laptop with 16 GB of memory.qwen3:1.7b, an optional smaller chat model, about 1.4 GB, for a computer with 8 GB of memory. Every example still runs with it.nomic-embed-text, the embedding model used from Chapter 3 onward, about 274 MB.- pytest, for the tests only.
Setting up these tools is covered in Running the examples and in the Setup and Reproducibility appendix of the book.
Chapters
Reading online is not available yet.
Book text © 2026 Ravi Pal. All rights reserved. Code examples are licensed under the MIT License.