Founder & CEO Insight — Enow A. Jovial
Deploying a Retrieval-Augmented Generation (RAG) prototype in a demo environment is simple; maintaining high accuracy in production is notoriously difficult. Without automated, quantitative evaluation metrics, engineering teams flying blind suffer from silent hallucinations, irrelevant vector chunk retrieval, and degraded customer trust.
The RAG Triad and Ragas evaluation framework provide empirical mathematical formulas to measure every stage of the RAG pipeline independently.
Mathematical Synthesis: Harmonic Retrieval F1 Formula
To balance retrieval quality between noise minimization (Precision) and coverage completeness (Recall), engineering teams calculate the harmonic mean:
Where:
- $\text{Context Precision} = \frac{\sum_{k=1}^K (\text{Precision@}k \times v_k)}{\text{Total Relevant Chunks in Top } K}$ (measuring signal-to-noise ratio)
- $\text{Context Recall} = \frac{\text{Ground Truth Sentences in Retrieved Context}}{\text{Total Ground Truth Sentences}}$ (measuring omission rate)
Real-World Case Study: Enterprise Financial Search & SLA Benchmarks
In a real-world operating scenario, an AI enterprise search company with $3,600,000 in ARR, $920,000 in EBITDA, and $480,000 in COGS processes corporate subscription invoices via ACH and Wire into an FDIC-insured business bank account under its corporate EIN identity.
Before automated evaluation, the platform suffered from a 12% hallucination rate on legal query answers. By integrating Ragas into GitHub Actions CI/CD:
- The team enforced a strict threshold of Faithfulness $\ge 0.95$ and Context Recall $\ge 0.90$ on every git commit.
- Because pull requests that degraded retrieval precision were automatically blocked, therefore customer support escalations dropped by 64%, and annual customer churn dropped from 9.2% to 2.8%, directly protecting $230,000 in recurring net margin.
```
+-----------------------------------------------------------------------------+
| THE RAG EVALUATION TRIAD |
| |
| [ USER QUERY ] |
| / \ |
| / \ |
| Context Relevance Answer Relevance |
| / \ |
| v v |
| [ RETRIEVED CONTEXT ] <==== Faithfulness ====> [ GENERATED ANSWER ] |
| |
| +-----------------------------------------------------------------------+ |
| | 1. Context Precision: Did we retrieve only relevant chunks? | |
| | 2. Faithfulness: Is the answer 100% grounded in retrieved context? | |
| | 3. Answer Relevance: Does the generated answer answer the query? | |
| +-----------------------------------------------------------------------+ |
+-----------------------------------------------------------------------------+
```
The Core Ragas Metrics Matrix
| Ragas Metric | Pipeline Component Evaluated | Mathematical Definition & Focus | Target Production SLA |
|---|---|---|---|
| Faithfulness (Groundedness) | Generation (LLM) | $\frac{\text{Claims in Answer Grounded in Context}}{\text{Total Claims in Answer}}$ | $\ge 0.95$ (Zero Hallucination) |
| Answer Relevance | Generation (LLM) | Mean cosine similarity of generated hypothetical questions vs. original user query | $\ge 0.88$ |
| Context Precision | Retrieval (Vector DB) | $\text{Mean Average Precision@K}$ of ground-truth chunks in retrieved ranks | $\ge 0.85$ |
| Context Recall | Retrieval (Vector DB) | $\frac{\text{Ground Truth Sentences Attributed to Context}}{\text{Total Sentences in Ground Truth}}$ | $\ge 0.90$ |
Mathematical Breakdown of Faithfulness (Hallucination Detection)
To compute Faithfulness automatically without manual human labeling:
- Deconstruct the Answer into Atomic Claims: An evaluation LLM breaks the generated output $A$ into a set of discrete, factual propositions $S = \{s_1, s_2, \dots, s_n\}$.
- Verify Claims Against Retrieved Context: For each proposition $s_i$, the evaluation model verifies whether the proposition is logically entailed by the retrieved context chunks $C$.
- Calculate the Groundedness Ratio:
If a generated response contains 5 factual claims and 1 claim cannot be substantiated by the retrieved document chunks, the Faithfulness score is $4 / 5 = \mathbf{0.80}$ (Flagged for hallucination review).
Production Evaluation Stack: Integrating Ragas with Qdrant & Gemini
```python
from ragas import evaluate
from ragas.metrics import faithfulness, answer_relevance, context_precision, context_recall
from datasets import Dataset
Construct evaluation dataset from production logs
eval_data = {
'question': ['What is the penalty for late Form 5472 filing?'],
'contexts': [['Under IRC Section 6038A, the statutory penalty for failing to timely file Form 5472 is $25,000 per entity.']],
'answer': ['The IRS assesses a mandatory $25,000 late-filing penalty under IRC Section 6038A.'],
'ground_truth': ['A $25,000 penalty is assessed by the IRS under Section 6038A.']
}
dataset = Dataset.from_dict(eval_data)
results = evaluate(dataset, metrics=[faithfulness, answer_relevance, context_precision, context_recall])
print(results)
```
Actionable RAG Quality Assurance Checklist
The $230,400 Churn Ledger
The case study in the previous section states three results from enforcing the Ragas gates in CI/CD: support escalations down 64%, annual churn down from 9.2% to 2.8%, and $230,000 of recurring net margin protected. The churn figures alone reproduce the $230,000, which is the check that the case study's numbers hang together instead of floating free.
| Line | Before Ragas gates | After Ragas gates | Change |
|---|---|---|---|
| Annual churn rate | 9.2% | 2.8% | 6.4 percentage points |
| Revenue exposed to churn on $3,600,000 ARR | $331,200 | $100,800 | $230,400 |
| Relative churn reduction | — | — | 69.6% |
| Support escalations (indexed) | 100 | 36 | 64% fewer |
The derived $230,400 sits $400 above the $230,000 the article states as protected margin — the same figure rounded to the nearest ten thousand, not a second number. The 6.4-point churn drop is a 69.6% relative reduction (6.4 / 9.2 = 0.696), which is why the absolute dollars look large: the team did not shave churn at the margin, it cut more than two-thirds of it. The other stated figure, EBITDA of $920,000 on $3,600,000 ARR, is a 25.6% margin, and COGS of $480,000 is 13.3% of revenue — the churn saving of $230,400 is 25.0% of that EBITDA, which is the scale on which the evaluation spend has to be judged. A Ragas pipeline that costs a few thousand dollars a year in compute and defends a quarter of EBITDA is not a quality initiative; it is the cheapest margin defence in the company.
The F1 Threshold Ledger
The article's F1 formula is a gate, not a score to admire. Work it at the SLA thresholds the metrics matrix states — Context Precision at least 0.85, Context Recall at least 0.90 — and then at each threshold breached on its own, so the team knows which breach costs more.
| Context Precision | Context Recall | F1 | Verdict |
|---|---|---|---|
| 0.85 | 0.90 | 0.874 | Both thresholds met |
| 0.70 | 0.90 | 0.788 | Precision breach costs 0.086 of F1 |
| 0.85 | 0.70 | 0.768 | Recall breach costs 0.106 of F1 |
| 0.95 | 0.90 | 0.924 | Precision headroom buys only 0.050 |
The harmonic mean punishes the weaker leg, and it punishes recall harder than precision at these thresholds: a recall breach to 0.70 costs 0.106 of F1 against 0.086 for the same-sized precision breach. That asymmetry is the operational point. A team that tunes chunk size for precision — smaller chunks, tighter retrieval — and lets recall slide is optimising the wrong leg. The same asymmetry shows up in the Faithfulness gate. The article's worked example scores a five-claim answer at 4 / 5 = 0.80 and flags it. Against the stated gate of Faithfulness at least 0.95, a five-claim answer has no room at all: 4 / 5 = 0.80 fails, and only 5 / 5 = 1.00 passes. It takes a twenty-claim answer for a single unverified claim to pass, at 19 / 20 = 0.95 exactly. Short answers are judged more harshly than long ones by the same gate, which is correct — a short answer that hallucinates one claim in five is 20% wrong, and no customer-facing system should ship that.
The 5% Sampling Ledger
The checklist tells teams to sample 5% of live customer queries for asynchronous hallucination scoring. Five percent sounds small until it is multiplied by real query volume, and the volume is what decides whether the sample catches a regression before customers do.
| Live queries per day | Sampled at 5% | Sampled per 30-day month |
|---|---|---|
| 100 | 5 | 150 |
| 1,000 | 50 | 1,500 |
| 10,000 | 500 | 15,000 |
At the article's stated 12% hallucination rate, 1,000 live answers a day contain 120 hallucinated answers, and a 5% sample catches about 6 of them a day (50 sampled times 0.12). At 100 queries a day the sample is 5 answers, which catches a hallucinated answer roughly every other day — too slow to notice a bad deploy before the support queue does. The sampling rate is not a constant to copy; it is a function of volume, and low-volume systems need a higher rate or a smaller golden dataset run on every deploy instead. The golden dataset the checklist specifies — 100 or more verified question-context-answer pairs — is the floor, not the ceiling: at 5 claims per answer, one full regression run verifies 500 claims, and a single claim slipping past the 0.95 gate is the difference between a passing and a failing build.
The warning at the top of the article adds a correction the sample math needs. An LLM judge scores its own outputs 15–20% higher than competitors' outputs, so a self-scored Faithfulness of 0.95 is not a pass. Dividing out the bias gives a true score between 0.79 and 0.83 (0.95 / 1.20 = 0.79; 0.95 / 1.15 = 0.83) — below the 0.95 gate by a wide margin. An uncalibrated self-score of 0.95 is evidence of a failing system, not a passing one. The fix is the one the article already implies: human calibration datasets, where a sample of judge scores is checked against human verdicts and the judge's threshold is moved until its scores line up. Until that calibration exists, treat every LLM-judge score as inflated by roughly a sixth and set the passing bar accordingly. The chunk-overlap figure in the checklist deserves the same treatment: 50 tokens of overlap on a 512-token chunk is 9.8% of every chunk (50 / 512 = 0.098) — nearly a tenth of the retrieval budget spent re-reading the previous chunk, which is the price of not splitting a sentence across a boundary.
Decision Table: Which Operator Shape Are You?
| Operator shape | System & volume | Evaluate this way | Why |
|---|---|---|---|
| Pre-launch prototype | Under 100 queries a day, no golden dataset yet | Build the 100-pair golden dataset first; run it on every deploy | At 100 queries a day a 5% sample catches a hallucination every other day — the dataset is the only gate that works |
| Regulated answers (legal, tax, medical) | Faithfulness gate is the business | Faithfulness at least 0.95 on every commit, human calibration mandatory | A 4-in-5 answer is 20% wrong; the 12% hallucination rate in the case study is the cost of shipping without the gate |
| High-volume support search | 10,000+ queries a day | 5% live sampling plus the golden regression on every deploy | 500 sampled answers a day catches about 60 hallucinated answers a day at a 12% rate — fast enough to roll back the same day |
| Retrieval tuning in progress | Chunk size or embedding model changing | Watch Context Recall first, Precision second | The F1 ledger shows a recall breach costs 0.106 against 0.086 for precision — recall is the leg that breaks the score |
| Cost-capped team | Cannot afford a judge model on every commit | Golden dataset on deploy, LLM-judge sampling weekly, human spot-check monthly | The judge's 15–20% self-preference means weekly scores need the 0.79–0.83 correction; monthly human checks keep the correction honest |
Operator Boundaries: Where Each Metric Breaks
- Faithfulness at 0.95 is unforgiving on short answers. A five-claim answer must be perfect; one unverified claim fails it. Do not average Faithfulness across answers to hide this — report the share of answers below 0.95, not the mean.
- Context Recall below 0.90 means the answer is built on missing evidence. The model will fill the gap with fluent invention, and Faithfulness will catch it only if the judge is calibrated. A recall breach is a hallucination waiting one step downstream.
- Context Precision below 0.85 means the context window is mostly noise. The model reads ten chunks to use three, and the seven irrelevant chunks are seven chances to cite the wrong document. Fix chunk size and re-ranking before touching the prompt.
- Answer Relevance below 0.88 means the answer is fluent and off-topic. This is the metric that catches the model answering the question it wishes you had asked. It fails silently in demos because the answer reads well.
- A 5% sample is a floor for high volume and a fiction for low volume. At 100 queries a day, 5% is 5 answers — raise the rate or accept that the golden dataset, not live sampling, is your regression gate.
To optimize your production retrieval infrastructure, read our guide on Self-Hosting Qdrant & Vector DBs on Hetzner and explore Building Autonomous Customer Support Agents.
For real-time voice latency benchmarks, consult AI Voice Agents for Inbound Sales and automate engineering checks in AI Code Review Actions. For the tracker the reviewed code lands in, compare Linear vs Jira vs ClickUp.