DEV Community

Zaima Sohail
Zaima Sohail

Posted on Originally published at Medium on

Most RAG Tutorials Skip the Hardest Part: Evaluation

Building a RAG demo takes an afternoon. Knowing whether it works takes much longer, and that’s the part almost nobody writes about.

Search for “RAG tutorial” and you’ll find hundreds of them. They all follow the same script: load some PDFs, split them into chunks, embed them, store them in a vector database, connect an LLM, and ask it a question. The answer comes back fluent and confident. The tutorial ends there.

But that last step hides the real question. Was the answer correct? Did it come from the documents, or did the model make it up? Would it still work on the next hundred questions?

I think evaluation is the hardest and most important part of building a RAG system, and the part most tutorials skip entirely.

Why evaluation gets skipped

The honest reason is that evaluation is boring to demo. A chatbot answering a question looks impressive in a screenshot. A spreadsheet of 50 test questions with scores next to them does not.

There’s also a deeper problem: LLMs are very good at sounding right. A wrong answer written in clear, confident English is hard to spot when you’re testing by hand. You ask five questions, the answers look reasonable, and you move on. That’s not testing. That’s hoping.

A RAG system can fail in two different places

This is the idea I wish someone had explained to me earlier. A RAG pipeline has two stages, and each one can fail on its own:

  1. Retrieval can bring back the wrong chunks. If the right information never reaches the model, even the best LLM can’t answer correctly.
  2. Generation can misuse the right chunks. The model might ignore the context, mix it with its own knowledge, or add details that aren’t in any document.

When you only look at the final answer, you can’t tell which stage failed. So you end up changing the wrong thing: swapping the LLM when the real problem was chunk size, or tuning the retriever when the model was ignoring good context.

That’s why “it answered my question” tells you almost nothing. You need to measure each stage separately.

What building a multi-agent pipeline taught me

For my MS thesis, I built EmoRAG: a pipeline of five agents in LangGraph that answers student questions and adapts its response to the student’s emotional state. One agent detects emotion with a fine-tuned BERT-style classifier, others handle retrieval and routing, and an LLM generates the final answer.

A few lessons stood out.

Every agent is another place to fail. In a single-step RAG system, there are two stages to check. With five agents, there are five, plus the hand-offs between them. If the emotion agent misreads a frustrated student as calm, the answer can be accurate and still land badly. The final output looks fine, but the system didn’t do what it was designed to do.

So each component needs its own test. Instead of judging only the final answer, I evaluate the emotion classifier on its own. I’m comparing five options (BERT-base, RoBERTa-base, DistilRoBERTa, DeBERTa-v3-small, and a simple TF-IDF with logistic regression baseline) on the same labelled data before choosing one. Including the simple baseline matters: if a basic model comes close, the extra complexity has to earn its place.

Speed is part of quality. I started with a local LLaMA 3.1 8B model through Ollama. The answers were fine, but generation was too slow for an interactive student tool, so I switched to a Gemini model. No accuracy metric would have caught that. A system that gives a good answer after a long wait still fails the user.

A result that surprised us. We expected the hosted LLM to be the stronger emotion detector, and on our own 35 emotion variants it was: gemini-3.5-flash-lite labelled all 35 correctly, while DistilRoBERTa got only 18 of them right (0.514). On 300 real Reddit comments from the GoEmotions test split, the result reversed. DistilRoBERTa was correct on 217 (0.723) and Gemini on only 149 (0.497). Gemini’s errors were not random: it labelled 54 of these comments as Confident, although only one of them was. Our variants were written so that the emotion is easy to see, the way an exam question is written, but real comments rarely say how the writer feels so clearly. Each detector did best on text that resembled what it was trained or prompted on. A perfect score on clean, hand-written examples therefore told us very little about how the system would handle real student messages.

A minimal evaluation checklist

You don’t need a huge framework to start. If I were adding evaluation to a RAG project from scratch, I’d start with this:

  1. Write a small test set first. Collect 30 to 50 real questions, each with the correct answer and the document it should come from. Writing these by hand is slow, and it’s the most valuable hour you’ll spend on the project.
  2. Measure retrieval on its own. For each question, check whether the correct chunk appears in the top results. If it doesn’t, stop there and fix retrieval before touching the prompt or the model.
  3. Check whether answers stay faithful to the context. Does every claim in the answer appear in the retrieved chunks? Tools like RAGAS can score this automatically, but reading 20 answers yourself teaches you even more.
  4. Test what happens when the answer isn’t there. Ask questions your documents can’t answer. A good system says it doesn’t know. A bad one invents something.
  5. Track latency and cost. Record how long each answer takes and what it costs. These matter to real users as much as accuracy does.
  6. Re-run everything after every change. New chunk size, new prompt, new model: run the same test set and compare. Without this, you’re guessing whether each change helped.

Conclusion

RAG tutorials make it look like the hard part is connecting the pieces. In my experience, connecting the pieces is the easy part. The hard part is proving the system works, finding out where it breaks, and knowing that the next change made it better rather than just different.

If you’re building a RAG project for your portfolio, add an evaluation section to it. A chatbot that answers questions is common. A chatbot with a test set, retrieval scores, and an honest list of failure cases shows that you think like an engineer.

How do you evaluate your RAG systems? I’d genuinely like to hear what’s worked for you in the comments.

Top comments (0)