Notes
All notes

What is an AI Engineer? (AI Engg #1)

You are hired as an “AI Engineer” at a 200-person SaaS company. Day one, the CTO says: “Customers want to ask questions over their own docs, draft replies, and auto-triage tickets. Make it shippable in six weeks.” Nobody hands you GPUs. Nobody asks you to train a Transformer. They hand you an OpenAI key, a Postgres dump, and a Slack channel full of feature requests.

That is AI engineering. Not inventing intelligence — productizing it.

This chapter explains what the role actually is, how it differs from ML engineering and prompt hacking, what systems you own end to end, and the mental model this whole course runs on. By the end you will be able to draw the stack from memory, explain why context and evals beat model size, and scope a real feature into shippable parts.

The definition, precisely

AI engineering is the discipline of building production software whose core logic is performed by frozen foundation models (LLMs, embedding models, vision/audio models), composed with retrieval, tools, memory, and evaluation.

Unpack every word:

If you remember one formula from this course, make it this one:

\[ \text{shipped value} = \text{model capability} \times \text{context quality} \times \text{eval coverage} \]

It is multiplicative. A state-of-the-art model with garbage context and zero evals ships zero value — confidently wrong answers, uncaught. A mid-tier model with excellent retrieval and 200 golden test cases ships real revenue. Your job, across all 18 chapters, is the two multipliers on the right.

\begin{tikzpicture}[font=\rmfamily, >=stealth,
  b/.style={draw, thick, rounded corners=4pt, minimum width=2.6cm, minimum height=0.8cm, align=center},
  a/.style={->, thick}]
  \node[b, fill=blue!10] (u) at (0,0.5) {user + product};
  \node[b, fill=orange!25] (e) at (0,-1.0) {AI engineer: glue + guardrails};
  \node[b, fill=green!10] (m) at (-3,-2.6) {LLM API};
  \node[b, fill=green!10] (r) at (0,-2.6) {retrieval};
  \node[b, fill=green!10] (t) at (3,-2.6) {tools / MCP};
  \node[b, fill=gray!10] (v) at (0,-4.0) {evals + traces + cost};
  \draw[a] (u) -- (e);
  \draw[a] (e) -- (m); \draw[a] (e) -- (r); \draw[a] (e) -- (t);
  \draw[a, dashed] (m) -- (v); \draw[a, dashed] (r) -- (v); \draw[a, dashed] (t) -- (v);
  \node[font=\rmfamily\small, text=black!65] at (0,-4.7) {everything wrapped in measurement};
\end{tikzpicture}

Read the diagram bottom-up: models, documents, and tools are interchangeable parts. The durable asset — the thing that survives a model swap from GPT-4o to Claude to Qwen — is the box at the bottom: your evals, traces, and cost dashboards.

AI Engineer vs ML Engineer vs Prompt Engineer

Titles are muddy, so let us fix them with a table and then with a story.

Role Trains models? Main artifact Typical stack Hired when
ML Engineer yes — trains/fine-tunes, runs GPUs weights + training pipelines PyTorch, CUDA, Ray, feature stores you have data moats and need custom models
AI Engineer no — composes frozen models prompts + retrieval + agents + evals OpenAI/Anthropic APIs, vector DBs, LangChain, MCP you need LLM features in the product now
Prompt Engineer (narrow) no wording tricks playground never as a full-time role — it is a skill inside AI engineering

Story: a support-ticket classifier.

Notice what the AI engineer did not do: no training loop, no GPU cluster. And what they did do that the prompt hacker skipped: schemas, retrieval, confidence routing, logging, evals. That gap — between demo and production — is the entire profession.

A word on “prompt engineering” as a job title: it is dissolving. By 2025–26 every roadmap (including roadmap.sh, which this course follows) demoted it from role to skill and promoted context engineering — curating everything the model sees — to the real work. Chapter 4 is devoted to it.

What you actually own: the full loop

Every AI feature you ship will walk the same loop. Learn it now; each chapter zooms into one box.

request → context assembly → model call → parse/validate → act → log → evaluate

Request. Who asked, with what permissions, under what tenant? You will attach end_user_id, tenant filters, and redaction before anything touches the model. Chapter 13 shows why: logs without scoping become leaks, and tools without scoping become privilege escalation.

Context assembly. The highest-leverage step. You gather system instructions, retrieved chunks, memory, tool schemas, conversation history — then fit them into a token budget (Chapters 3–4). Empirical law from Anthropic’s 2025 context-engineering guide and 2026 follow-ups: small context with the right tokens beats a 1M-token window stuffed with noise. You will learn retrieve → filter → compact → fit as a reflex.

Model call. Choosing open vs closed, cheap vs flagship, temperature and format (Chapters 2, 3, 5, 6). You will pin versions (gpt-4o-2026-05-01, not gpt-4o), set timeouts and retries, stream for UX, and cache static prefixes.

Parse and validate. Never trust raw text. Demand JSON Schema / function calls, re-try on schema failure, fall back deterministically. A one-line summary of this course could be: never eval() the model’s imagination.

Act. Write to the ticket system, send the draft, file the refund — through narrow, auditable tools (Chapters 11–12 on agents and MCP). Reads are free; writes need confirmation, idempotency keys, and dry-run modes.

Log and evaluate. Every run emits a trace: prompt hash, context IDs, model version, tokens, cost, latency, tool calls, score. Nightly evals compare against goldens; regressions page you like a 500 error (Chapter 13).

\begin{tikzpicture}[font=\rmfamily, >=stealth,
  b/.style={draw, thick, rounded corners=4pt, minimum width=2.1cm, minimum height=0.7cm, align=center, font=\rmfamily\small},
  a/.style={->, thick}]
  \node[b] (q) at (-4.2,0) {request};
  \node[b, fill=orange!20] (c) at (-2.1,0) {context};
  \node[b, fill=blue!10] (m) at (0,0) {model};
  \node[b, fill=green!10] (p) at (2.1,0) {parse};
  \node[b] (ac) at (4.2,0) {act};
  \node[b, fill=gray!10] (e) at (4.2,-1.5) {log + eval};
  \draw[a] (q) -- (c); \draw[a] (c) -- (m); \draw[a] (m) -- (p); \draw[a] (p) -- (ac);
  \draw[a, dashed] (ac) -- (e); \draw[a, dashed] (e) to[bend left=30] (c);
  \node[font=\rmfamily\small, text=black!60] at (0,-1.5) {evals feed back into context};
\end{tikzpicture}

The dashed arrow matters most: evals rewrite context (better chunks, tighter prompts, new filters). Teams that close this loop weekly improve; teams that stare at dashboards do not.

The vocabulary you need on day one

You will meet these in every chapter. A first-pass definition now, depth later:

\begin{tikzpicture}[font=\rmfamily, >=stealth,
  c/.style={draw, thick, circle, minimum size=1.15cm, font=\rmfamily\small, align=center},
  a/.style={->, thick, black!60}]
  \node[c, fill=blue!10] (t) at (0,2) {tokens};
  \node[c, fill=blue!10] (e) at (-2.4,0.4) {embed};
  \node[c, fill=blue!10] (r) at (2.4,0.4) {RAG};
  \node[c, fill=orange!20] (a2) at (-1.2,-1.6) {agent};
  \node[c, fill=orange!20] (m) at (1.2,-1.6) {MCP};
  \draw[a] (t) -- (e); \draw[a] (t) -- (r); \draw[a] (e) -- (r);
  \draw[a] (r) -- (a2); \draw[a] (r) -- (m); \draw[a] (a2) -- (m);
\end{tikzpicture}

Open vs closed vs self-hosted: the decision you will revisit

The mature pattern is a router: cheap/small handles 80% (triage, drafts), flagship handles the uncertain 20%, with OpenRouter or your own gateway providing one API and fallbacks. Chapter 5 turns this into numbers; Chapter 6 gives you the local stack commands.

There is also a compliance axis people learn late: some contracts forbid customer text leaving your cloud. Know your data policy before you pick the model. Self-hosted open weights exist precisely for that row in the spreadsheet.

Your first ten lines (and what they hide)

Run this today. It is the seed every later chapter grows:

# day-one prototype: swap base_url/model to go local later (Chapter 6)
from openai import OpenAI

client = OpenAI()  # or: OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")

resp = client.chat.completions.create(
    model="gpt-4o-mini",
    temperature=0.2,      # low = factual; see Chapter 2
    max_tokens=200,
    messages=[
        {"role": "system", "content": "You triage support tickets. Reply in 3 bullets."},
        {"role": "user", "content": "Ticket #42: invoice is wrong, need fix before Friday!"},
    ],
)
print(resp.choices[0].message.content)
print(resp.usage)  # tokens in/out — your bill starts here

What the snippet hides — your roadmap for the course:

  1. Where did the ticket’s history and plan come from? (Chapters 4, 9.)
  2. How do you guarantee 3 bullets as JSON, not prose? (Chapter 3.)
  3. What if the invoice number needs a database lookup? (Chapters 11–12.)
  4. How do you know Friday’s model update did not break it? (Chapter 13.)
  5. What did it cost × 100K tickets, and could Qwen-7B do it cheaper? (Chapters 5–7.)

How this course is organized

Eighteen chapters, one spine (mirrors roadmap.sh/ai-engineer.json, 279 nodes, plus the serving layer every production system needs):

  1. You are here — role, loop, vocabulary.
  2. How LLMs work — tokens, sampling, windows, fine-tuning.
  3. Prompt engineering — structure that controls output.
  4. Context engineering — the multiplier.
  5. Types of models — open/closed/self-hosted, routers.
  6. The open stack — Hugging Face, Ollama, LM Studio, OpenRouter.
  7. Serving at scale — prefill vs decode, KV cache, quantization, batching, prefix caching. 8–10. Embeddings → Vector DBs → RAG — the knowledge path. 11–12. Agents → MCP — the action path.
  8. Safety, observability, evals — the seatbelts.
  9. Multimodal — vision, audio, image.
  10. Dev tools + capstone — ship a graded project.
  11. System One models — typed, calibrated answers that cannot hallucinate.
  12. PageIndex — vectorless RAG: a document tree the model reasons over.
  13. DeepSeek — the papers, and what open weights changed about cost.

Each chapter ends with pitfalls (ways teams actually fail) and points forward. Exercises marked Try it need only Python + an API key or a laptop with Ollama.

Pitfalls (learned the hard way)

QQuestionSelf-check (answer aloud before continuing)

What is the AI engineer’s loop? Why is the value equation multiplicative? When would you choose a self-hosted 7B model over GPT-5?

ASolution

Request → context → model → parse → act → log/evaluate, with evals feeding back into context. Multiplicative because any zero (no context, no evals) zeroes the product regardless of model. Choose small/self-hosted when data cannot leave VPC, latency or marginal cost dominates, or the task is narrow enough that your goldens pass on 7B.

Next: How LLMs Work (AI Engg #2) — tokens, probabilities, and why temperature is not creativity juice.