AI engineering
AI engineering: 12 hands-on labs
The code around a language model, one small function at a time: similarity, chunking, retrieval, context budgets, cited sources, tool policies, retries, evaluation and cost. No lab calls a model or needs an API key.
Model foundations
The numbers under a language model: vectors, similarity and probabilities, and how to check what a model sends back.
- Vector dot productA model cannot read words.
- Embedding similarityAn embedding is a vector that stands for the meaning of a piece of text.
- Stable token probabilitiesA language model does not pick the next word directly.
- Validate structured outputWhen your program asks a model for data, the reply is text.
Retrieval & context
How a document assistant finds the right text, fits it into a prompt, and keeps its sources honest.
- Overlapping document chunksA model can only read a limited amount of text at once, and a search works better on small pieces than on whole…
- Rank a retrieval baselineRetrieval means finding the few documents that can answer a question, out of many.
- Fit a context windowA model reads everything you send it in one piece, called the context window, and that window has a fixed size…
- Check cited sourcesA document assistant answers from retrieved documents and names its sources.
Safe tool use
What your own code must decide when a model asks to act: what may run, and how to retry without doing harm.
- Gate tool executionA model can ask your program to run a tool, such as searching documents or sending an email.
- Bound retry delaysCalls to a model or a tool sometimes fail for a moment: the service is busy, or the network drops.
Evaluation & shipping
Numbers that tell you whether a change helped, and what a request costs.
- Measure retrieval recallAfter changing a search, how do you know it got better?
- Measure token costA model that a company runs for you, a hosted model, is paid for by the token.