Capstone: an end-to-end RAG agent with a trained reranker, multimodal input, red-teaming and deployment

Build an AI system that combines a model you trained or adapted with the machinery around it, then evaluate it honestly. Pick a domain you know well enough to judge answers. The system has seven required parts, from the trained model and retrieval to the agent loop, evaluation, deployment and a technical report.

In Daveth Pro (AI Engineering)

What this page answers

What should an AI engineering capstone project include?

A model you trained or adapted, retrieval, an agent loop, a multimodal channel, evaluation and red-teaming, deployment and a technical report, each with a minimum bar and evidence a reviewer can check. Read it in “The brief”

How do you choose a domain for an AI project?

Pick one you know well enough to judge answers, such as your own notes, a hobby, a set of manuals or a codebase. Knowing the domain matters more than its size, because you write the test questions. Read it in “The brief”

The brief

Build an AI system that combines a model you trained or adapted with the machinery around it, then evaluate it honestly. Pick a domain you care about and know well enough to judge answers: your own notes, a hobby, a set of manuals, a codebase, a game. Knowing the domain matters more than its size, because you'll be writing the test questions and deciding which answers are right.

The system has seven required parts. The table says what each part must do at minimum and what you hand in to show it. How to read it: the middle column is the bar for “done”; the right column is the evidence a reviewer will look at. Numbers beat adjectives in every row.

PartMinimum barEvidence
C1 · A model you trained or adaptedTrain or fine-tune at least one model that the system depends on: continued pre-training of your mini-GPT, a LoRA fine-tune of an open model, or a smaller task model such as a reranker or classifierTraining curve, held-out score against a baseline without it
C2 · Domain retrievalYour own index over your domain corpus, hybrid or dense, with chunking you chose deliberatelyRetrieval recall at k on your own question set, before and after one improvement
C3 · Agent loopAt least two tools and some memory, in a loop you wrote yourself (no agent framework)Transcripts, tool-call success rate, a step budget and what happens when it runs out
C4 · One multimodal channelVoice in and/or out, or image input, wired into the same systemA measured error rate on your own samples (word error rate, captioning accuracy)
C5 · Evaluation and red-teamA test suite of at least 50 in-scope and 20 out-of-scope cases, plus prompt-injection attacksA results table with intervals, and a written list of failure cases with causes
C6 · Optimized deploymentServed behind an API, with at least two of: quantization, caching, batching, streamingLatency p50 and p95, memory, cost per 1,000 requests, before and after optimizing
C7 · Technical reportWhat you built, what you measured, what you'd changeA 4 to 8 page report with every claim backed by a number or a transcript

Two alternative tracks exist for people who'd rather go deep than wide. Research track: a careful comparison of a Transformer and a state-space or linear-attention model at matched size and compute, on a task where long context matters, with a scaling plot and an honest discussion (Chapters 10 and 15 are your toolkit). Coding-agent track: an autonomous agent that fixes failing tests in small repositories, evaluated with hidden tests and a cost-per-fix figure (Chapter 13). Both still need C5 and C7.

A reference build: “Ask the course”

To show what “integrated” means, I built a small version myself, entirely from parts of this course: a tutor that answers questions about the course's own lessons. It isn't a full capstone (it has no multimodal channel, and its “language model” is deliberately simple), but every other part is here, working, and measured. How to read the answer: the panel shows what the system decided at each stage, the answer with its source, and how long each stage took on your machine.

Drawing: Live: every stage runs in your browser. Retrieval, the reranker, the answerability check and the injection guard use the course index from Chapter 13; arithmetic questions are routed to the tool-using agent trained in Chapter 13.

Here's how a question flows through it. How to read the diagram: left to right is the order of operations; each box names the chapter its technique comes from; dashed boxes are the parts I trained for this build.

Drawing: Architecture of the reference build.

C1 · A model you trained: the reranker and the abstainer

I trained two small models for this build, and they illustrate the most important habit of the capstone: a model only counts if you can show it helps on data it didn't see.

The first is a reranker. Hybrid search gives 20 candidate passages; the reranker re-sorts them using nine features of each candidate (its keyword score, its dense similarity, its rank in each list, how many of the question's words and rare words it contains, whether the question's words appear in its section heading). It's logistic regression, the simplest possible learned model, trained on my 48 questions. With only 48 questions, I can't hold out a big test set, so I used 4-fold cross-validation: split the questions into four groups, train on three, score the fourth, and rotate, so every question is scored by a model that never saw it.

Drawing: Reranker feature weights.

The reranker moved the right passage into the top 3 for 50% of held-out questions, up from 42%, and lifted the mean reciprocal rank from 0.36 to 0.40. It's a real gain, and a modest one, which is what a nine-feature linear model trained on 36 questions at a time can honestly deliver. Its biggest weight is on “1 / bm25 rank”. Notice the ceiling: the right passage is among the 20 candidates for only 73% of questions, so no reranker could do better than that. If I were extending this build, retrieval recall is where I'd spend the next effort, not the reranker.

The second model decides whether to answer at all. My first attempt used the reranker's best score as a confidence, and it failed badly: off-topic questions such as “Who won the football world cup in 2018?” scored as high as real ones, because the reranker's features are all relative to the other candidates, and some passage is always the best of a bad bunch. The fix was a separate answerability model using absolute signals, the most useful being simple: what share of the question's words appear anywhere in the course? I wrote 30 out-of-scope questions, some deliberately sharing course vocabulary (“How do neural pathways in the human brain form?”, “What does a tokenizer do in a parking garage?”), and evaluated with leave-one-out. How to read the chart: each dot is one question, placed by the model's score; blue dots are course questions, red ones off-topic; questions right of the dashed line get answered, left of it the system says it can't help.

Drawing: Answerability scores for in-scope and out-of-scope questions.

The answerability model answers 94% of course questions and refuses 97% of off-topic ones. The off-topic question it still answered: “How do I train my dog to sit?”, which shares the word “train” with half the course. The course questions it wrongly refused: “Why do we add gradients with += instead of overwriting them?”, “What is LoRA and why is it cheap?”, “What is specification gaming?”. A wrong refusal is annoying; a confident answer to a question the course doesn't cover is worse, so I'd rather err this way.

In your capstone, C1 will usually be more ambitious: a LoRA fine-tune that makes an open model write in your domain's style, or continued pre-training of your mini-GPT on your corpus. The habit is the same: a baseline without your model, a held-out evaluation, and an honest number.

C2 · Retrieval

The reference build uses the Chapter 13 index unchanged: 478 passages of about 600 characters, BM25 plus LSA, merged with reciprocal rank fusion. Two lessons from building on it. First, measure retrieval on its own, before anything downstream: in my build, the right passage is in the top 20 candidates for 73% of questions, which caps everything after it. No reranker or answer extractor can recover a passage that wasn't retrieved. Second, write your questions the way users would, not by copying sentences from your documents, or your recall numbers will flatter you.