From loading documents to handling failures — your complete guide to the RAG homework. Follow each task in order and you’ll have a working knowledge agent by the end.
Choose a domain you care about, gather documents, and wire up a complete knowledge agent that retrieves information before answering questions.
Choose something you know well so you can evaluate accuracy. Here are some ideas:
Menu items, allergens, wine pairings, reservation policies
Academic policies, registration deadlines, grading systems
Product specs, pricing, compatibility, warranty info
Contract templates, compliance checklists, regulation summaries
Patient guidelines, medication info, procedure protocols
This is the restaurant worked example. Replace the documents with your domain content.
Your documents don’t need to be long. A paragraph per document is fine. What matters is that they cover different aspects of your domain — the agent should be able to tell them apart when searching.
Deliberately feed your agent bad data and document what breaks. This is how you learn where RAG systems fail — and every production system has these failure modes.
Add a document with old pricing or policies. Does the agent quote the outdated info?
Observe: Which document does the agent cite? Does it notice the date difference?
Add two documents that say different things about the same topic.
Observe: Does the agent blend the answers? Flag the conflict? Pick one?
Ask questions your documents DON’T cover.
Observe: Does the agent hallucinate? Admit it doesn’t know? Make something up?
Use this format (a Markdown table in your notebook or a simple list):
| Test | What You Tried | What Happened | Why It Happened | How to Fix |
|---|---|---|---|---|
| Outdated data | Added 2022 menu | Agent quoted old prices | No date prioritization | Add date metadata, sort by recency |
| Contradiction | Conflicting refund policies | Agent blended both | No conflict detection | Add contradiction check before answering |
| Knowledge gap | Asked about competitors | Agent hallucinated pricing | No guardrails on search results | Add confidence threshold, refuse if no relevant docs |
If your agent handles everything perfectly, you’re not trying hard enough. Real-world RAG systems fail in exactly these ways — that’s why companies spend millions on guardrails.
Measure how well your agent actually performs. This is the same evaluation framework real companies use — just on a smaller scale.
| Criteria | Score | Description |
|---|---|---|
| Retrieved right doc? | Yes / No | Did the search tool return the correct document? |
| Answer correct? | Yes / Partial / No | Is the answer factually accurate based on the documents? |
| Hallucinated? | No / Yes | Did the agent add information not in the documents? |
| Cited sources? | Yes / No | Did the agent mention which document it used? |
| Question | Right Doc? | Correct? | Hallucinated? | Cited? | Notes |
|---|---|---|---|---|---|
| “What’s the salmon price?” | Yes | Yes | No | Yes | Found in menu_main_courses.md |
| “Do you have vegan options?” | No | No | Yes | No | Agent invented vegan dishes not in our menu |
| “What are your hours?” | No | No | Yes | No | Not in docs — agent should have said “I don’t know” |
After testing 10 questions, tally your results:
Grading guidance:
Your grade is based on the quality of your evaluation, not on how well your agent performs. A score of 4/10 with a thoughtful analysis of why it failed is worth more than 10/10 with no explanation.
Write a 1-page proposal for a knowledge agent at a real company. This is the kind of deliverable consultants charge $50K+ to produce.
The best proposals come from personal experience. If you worked at Starbucks, write about Starbucks. If you follow Tesla, write about Tesla. Domain knowledge makes your risk assessment and success metrics more realistic.
Click any question to expand the answer.
"If the search results don't contain relevant information, you MUST say: I don't have information about that in our knowledge base." You can also add: "NEVER make up information that is not in the search results."
You built a complete knowledge agent — from document loading to failure handling to business proposal. This is exactly what companies pay $100K+ for consultants to build. The architecture is identical; only the scale is different.
RAG is the #1 enterprise AI pattern. Every company deploying AI today — from Slack to Salesforce to internal tools at Goldman Sachs — uses retrieval-augmented generation. You now understand how it works, why it breaks, and how to evaluate it.
The proposal matters. Being able to articulate what to build, who it’s for, and what could go wrong is the difference between an engineer and a leader. That’s the skill companies pay for.