Skip to chapter content
navan✳THE BUILD LABAI ENGINEERING / GUIDE
0/21 read
CHAPTER 01 / 21 · FIRST PRINCIPLES

What AI engineering actually builds.

Begin with the user problem, the model, the surrounding software, and the promise an application makes.

BY NAVAN SAMILONG READTHEORY FIRST
01 / FROM THE BEGINNING

Start with the meaning.

An AI application is still an application. Someone gives it an input, expects an output, and may act on that output. A writing assistant might accept a rough note and return a draft. A support assistant might accept a question and return an answer grounded in company documents. The model creates some of the output, but the application also handles identity, data access, formatting, timing, errors, and user feedback. Those surrounding pieces are part of the product, not decoration around the model.

A foundation model is a model trained broadly enough to be adapted to many tasks. In AI engineering, a team often uses an existing model rather than training one from the beginning. The central engineering question becomes how to turn a general capability into a dependable service for a specific user and task. That requires deciding what information may enter the model, what it may produce, and how the result will be checked.

02 / THE SYSTEM

How the idea works.

Separate four layers. The user interface gathers a request and displays the response. Application logic assembles instructions and permitted context. A model service generates candidate content. Supporting systems store documents, record outcomes, and enforce access. A failure can happen in any layer: the model may invent a fact, retrieval may supply an outdated file, the application may expose another user's data, or the interface may make uncertain text look authoritative. Calling all of these “a model problem” hides the real cause.

Define the job before choosing a model. A useful job description names the user, the input, the allowed evidence, the expected output, and the cost of an error. “Answer every question” is too broad. “Summarise the approved policy document for an employee and cite the relevant section” gives a boundary you can evaluate. The best first version may be a narrow workflow that declines unsupported questions.

A model produces plausible output, not a guarantee that the output is true. The engineering goal is therefore a system whose behavior can be observed and corrected. Requirements should include latency, price, privacy, accessibility, and failure behavior alongside answer quality. A useful application can be slower or smaller than a demo if it is honest about its limits and fits the real workflow.

Consider a policy assistant that gives the correct answer to a question about paid leave. If it reached that answer using a document the user was not permitted to see, the application failed even though the sentence was accurate. If it used an outdated policy, it also failed. If it gave the answer without showing its source, the user may be unable to verify it. Quality therefore belongs to the whole path from request to evidence to presentation. The model's prose is only the most visible part of that path.

This is why system diagrams are more useful than a single box labelled “AI.” Draw the data sources, the user identity check, the model call, and the final decision. For each arrow, ask what type of information crosses it and who is allowed to make that transition. This habit turns a vague promise into smaller contracts that can be tested and owned by different parts of a team.

01User taskA bounded request02ApplicationRules and evidence03ModelCandidate output04ValidationCheck and present
A model is one stage. Application code controls evidence, permissions, and presentation.
03 / PYTHON, EXPLAINED

Follow the code.

what-ai-engineering-is.py
def answer_question(question, retrieve, generate):
    passages = retrieve(question)
    if not passages:
        return {"answer": "I could not find a supported answer.", "sources": []}
    prompt = {"question": question, "context": passages}
    draft = generate(prompt)
    return {"answer": draft, "sources": [p["id"] for p in passages]}

The function receives three inputs: a question and two callable dependencies. retrieve finds permitted passages; generate represents a model call. Passing those functions in makes the boundary visible and allows each step to be evaluated separately. The empty-result branch returns a useful limitation instead of asking the model to guess. The return value is a dictionary with both the answer and source identifiers; the interface can display these separately.

This small example is an architecture sketch, not a complete factuality check. A passage can be irrelevant, stale, or misread. Later chapters explain how to rank evidence, test generated claims, handle permissions, and monitor the system after release. The important first idea is that the model is one component in a chain of decisions.

04 / THE BOUNDARY

What the result does not say.

A polished demo often hides the hard cases. Real users ask incomplete questions, paste private information, switch languages, and expect the system to remember context. A production design must decide which of these cases it supports and what it says when it cannot help. Those decisions belong in product requirements and evaluations.

This course is a reading path. The code examples expose the shape of decisions; the separate cookbook presents complete local reference workflows. No account, model subscription, or practical exercise is required to follow the theory.

05 / KEEP THIS

One clear idea.

AI engineering turns a general model into a bounded, observable application for a real task.

THE CODE IN CONTEXT

The AI cookbook

Complete, explained local workflows sit alongside this reading course.

Browse the cookbook
Finished reading?
Built with curiosity. By Navan Sami. ↗AI engineering · From model calls to reliable systems.