Image generation shipped pixels. This capstone ships claims with sources. Vol. 21 research assistants defined the product category; Vol. 14 RAG gave you retrieve-then-generate. You now build the loop: query plan → retrieve (corpus or allowlisted web) → cite → synthesize—and fail the build if a citation is invented.
Sibling contrast: PDF chatbot answers over one ingest. A research assistant plans multi-query retrieval, attributes every material claim, and abstains. Vol. 19 hallucination tests and Vol. 11.4 hallucination are the eval spine. Next: meeting summarizer—same citation discipline on utterances, not papers.
Learning Objectives
By the end of this lesson, students should be able to:
- Ship an MVP research assistant: query plan → retrieve → cite → synthesis, with abstention.
- Reject invented, dangling, or unsupported citations in code—not “trust the model.”
- Split retrieval miss vs generation miss vs attribution miss (Vol. 14 + Vol. 19).
- Choose local corpus vs allowlisted web search, and wrap retrieved text as untrusted data.
- Write FastAPI acceptance tests: groundedness, citation coverage, gold retrieval hit.
- Place HITL before any “publish brief” action (Vol. 15 + Vol. 20).
An AI research assistant (this capstone) is a citation-first RAG product: given a question and a declared corpus (your files and/or an allowlisted search tool), it plans retrieval queries, fetches chunks, drafts a synthesis, and attaches resolvable citations to material claims. Never invent citations—a DOI, URL, or bracket ID that is not in the retrieved set is a product failure. The assistant may abstain when retrieval is weak. It is not a world oracle; faithfulness to a stale or wrong corpus is still a wrong brief.
Problem, MVP, and Stretch
Users want a brief they can check. Chat-without-sources invents papers. Your job is a pipeline with an evidence channel, not a smarter autocomplete.
| MVP (ship this) | Stretch (after eval is green) | |
|---|---|---|
| Corpus | Toy knowledge base you own (JSON/Markdown + embeddings) | Allowlisted web search + recency filters; ACL per tenant |
| Query plan | 1–3 sub-queries from the user question | Multi-hop; contradiction / “what would falsify” pass |
| Retrieve | Top-\(k\) chunks with id, title, url/path, text | Hybrid search + re-rank (Vol. 14) |
| Cite | Inline [id]; reject dangling IDs | Quote spans + page/offset; claim table support/contradict/neither |
| Output | Synthesis + source list + abstain reason | HITL author edit → export; version pin of index digest |
| Out of scope | Scraping paywalls; fake DOIs; “as of today” without a date stamp | Autonomous publish to a wiki without a human |
Research assistant
- Plans queries, then retrieves
- Every material claim is attributable
- Abstain is a valid success
- Eval: groundedness + attribution
PDF chatbot (earlier capstone)
- One ingest, conversational Q&A
- Citations helpful but often page-level
- Chat UX first
- Eval: retrieval hit + faithfulness
Bare chat (no RAG)
- No evidence channel
- Invented citations look fluent
- Cannot split retrieval vs generation blame
- Not acceptable for this lecture
Architecture
| Layer | MVP choice | Notes |
|---|---|---|
| UI | Question + draft + source rail (id, title, snippet) | Show abstain banner; never hide missing cites |
| API | Vol. 18 FastAPI POST /v1/research/query | Auth + tenant_id; rate limit (Vol. 13.4) |
| Plan | LLM returns JSON list of sub-queries | Vol. 13 structured output |
| Retrieve | Local embeddings + Chroma/FAISS or mock search tool | Vol. 14 retrieval; wrap hits as data |
| Generate | OpenAI-compatible or HF chat (Vol. 22 pick) | System: cite only retrieved ids; abstain if weak |
| Storage | SQLite: run_id, queries, chunk_ids, draft, eval scores | Pin index digest for replay |
| Eval | Dangling-cite = fail; groundedness heuristic + gold hit | Vol. 19; sample with human eval |
[id] citesCitation-first buys
- Auditable drafts; blame-splitting on failures
- CI gates when the index or prompt changes
- Clear ACL: cite only what the tenant may see
Chat-without-sources costs
- Fluent fake papers, DOIs, and quotes
- Stale corpus treated as current world-truth
- No way to know if retrieval even ran
FastAPI Sketch: Plan, Retrieve, Cite, Synthesize
Educational stub: a tiny in-memory corpus stands in for Vol. 14 indexing. Replace synthesize() with your SDK call. The product rule is the citation gate—not the model brand (Vol. 22 OpenAI, Anthropic, or local).
Acceptance Criteria (“Done When…”)
| # | Criterion | How you prove it |
|---|---|---|
| 1 | Query plan is visible | API returns the sub-queries used, not a hidden rewrite |
| 2 | Retrieval actually ran | Response lists chunk ids + titles/urls from the index or search tool |
| 3 | No invented citations | Any [id] / URL not in retrieved set → 422 or rewrite, never silent pass |
| 4 | Gold retrieval hit | On a labeled fixture, the gold chunk is in top-\(k\) |
| 5 | Abstain works | Empty/irrelevant corpus → explicit insufficient-sources, not a fake paper |
| 6 | Untrusted wrap | Retrieved text is not concatenated as system instructions |
| 7 | HITL before publish | Export/share requires a human ack (Vol. 15 HITL) |
Eval, HITL, and Safety
Reuse Vol. 19: groundedness / RAG faithfulness, attribution (cite id in set and chunk supports claim), contradiction, abstention. Keyword overlap is a heuristic—negations still match tokens; sample with humans. If the gold chunk was never retrieved, fix Vol. 14 before blaming the generator.
| Risk | Control |
|---|---|
| Invented DOI/URL | Resolve every citation against retrieved set; fail the run |
| Prompt injection via web/PDF text | Wrap-as-data (Vol. 20 prompt injection) |
| Cross-tenant leak | Corpus ACL by tenant_id (Vol. 20 privacy) |
| Stale “current” facts | “As of” date + recency metadata; abstain if expired |
| Publish without reading | HITL author gate; this is not a substitute for reading sources |
Vendor pick (Vol. 22) is a substrate, not the product: chat APIs, optional search-grounded platforms such as Perplexity—still run your citation gate. Do not invent dollar prices or vendor accuracy numbers.
Related Lectures
| Lecture | Role |
|---|---|
| PDF chatbot (RAG) | Simpler ingest Q&A sibling |
| Research assistants / AI search | Product pattern vs ranking UX |
| RAG / retrieval / chunking | Evidence channel |
| Hallucination tests | Groundedness / attribution gates |
| Hallucination (11.4) / guardrails | Why fluency lies; abstain |
| FastAPI / Vol. 22 chat vendors | API + model substrate |
| Meeting summarizer | Next: cite utterances, not papers |
“We added RAG, so citations are automatically true.” Models still invent ids and numbers past the chunks. Second: a bracket number is proof—unless the chunk supports the claim (Vol. 19 attribution). Third: blaming the generator when the gold chunk was never retrieved. Fourth: scraping the live web without an allowlist and treating every hit as licensed, current, and safe. Fifth: faithful summary of a wrong corpus equals a correct brief. Sixth: the assistant replaces reading the source before you publish.
Knowledge Check
- Short Answer: Name the four stages of this capstone pipeline. Answer: Query plan → retrieve → cite → synthesize (plus abstain/HITL).
- True/False: Inventing a plausible DOI is acceptable if the prose is fluent. Answer: False—invented citations fail the product.
- Multiple Choice: If the gold chunk was never in top-\(k\), blame first: (a) retrieval, (b) BLEU, (c) watermarking. Answer: (a).
- Short Answer: What is a dangling citation? Answer: A cited id/URL not in the retrieved (or allowed) set.
- True/False: Abstaining when sources are weak can be a passing acceptance test. Answer: True.
- Multiple Choice: Retrieved web/PDF text in the prompt should be: (a) wrapped as untrusted data, (b) pasted into the system prompt as policy, (c) billed as CUDA. Answer: (a).
- Short Answer: Which Vol. 21 lecture defined this product category? Answer: Research assistants.
- True/False: Faithfulness to a stale corpus means the brief is world-true. Answer: False.
- Multiple Choice: Publish/export without a human ack violates: (a) HITL for high-stakes drafts, (b) softmax, (c) KV-cache. Answer: (a).
- Short Answer: Name two Vol. 19 checks this MVP must run. Answer: Any two of: groundedness/faithfulness, attribution, dangling-cite fail, contradiction, abstention.
Key Takeaways
- Research assistants are citation-first RAG products: plan, retrieve, cite, synthesize—never invent sources.
- Split retrieval vs generation vs attribution miss; dangling cites fail CI.
- Abstain + HITL publish; wrap retrieved text as untrusted data.
- Vol. 14 + Vol. 19 + Vol. 21 patterns become a shippable FastAPI service.
- Next: AI Meeting Summarizer — action items from transcripts.
Lab: Give a 12-doc toy corpus students own (no live paywall scrape). Four gold questions must retrieve a labeled chunk; four must abstain; four drafts include a dangling [99]. Students implement the citation gate and a query-plan log. Score retrieval hit separately from groundedness.
Whiteboard: Question → sub-queries → chunk ids → claim spans → {support, contradict, neither, dangling}. Circle “neither” as the human-eval bucket. Tease meetings: the “source” becomes a speaker utterance, not a PDF page.
Recap: This capstone productizes Vol. 14 RAG and Vol. 21 research patterns—query plan, retrieval, citation gates, abstention, and HITL. Continue to AI Meeting Summarizer.