I Built a RAG System. Then I Added Evals. Here’s What I Found.

· Source: Artificial Intelligence on Medium · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Software Development & Engineering · Depth: Intermediate, medium

Summary

A RAG system, initially appearing plausible, was found to be "lying" when subjected to rigorous evaluation. The author built an eval harness featuring a 17-question golden set and an LLM-as-a-judge to score relevance and faithfulness, logging every run in Postgres. This exposed critical issues: a 0.5 average relevance initially, revealing corpus coverage gaps (e.g., missing agent tool-calling docs, leader election) and prompt engineering flaws (model not utilizing all context). Introducing a local, in-process cross-encoder reranker ("Xenova/ms-marco-MiniLM-L-6-v2" via "@huggingface/transformers") initially dropped relevance to 0.88, but further analysis showed it exposed another pre-existing corpus gap. After addressing these data and prompt issues, the system achieved 0.94 average relevance and 1.0 average faithfulness.

Key takeaway

For AI Engineers building RAG systems, relying solely on "plausible" outputs is insufficient and misleading. You should integrate an LLM-as-a-judge eval harness early in development to scientifically measure relevance and faithfulness. This approach will quickly identify corpus gaps or prompt engineering issues, preventing wasted effort on refactoring functional retrieval code. Prioritize data ingestion and prompt refinement based on objective metrics to ensure robust system performance.

Key insights

Rigorous LLM-as-a-judge evaluation is crucial for RAG system reliability, exposing hidden data and prompt issues.

Principles

Method

The eval loop involves: golden question → RAG answer → LLM judge scores it → every run persisted for before/after comparison.

In practice

Topics

Code references

Best for: AI Engineer, Machine Learning Engineer, MLOps Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Artificial Intelligence on Medium.