RAG Evaluation & Testing: Measure What Matters
How to measure retrieval quality, faithfulness, and answer relevance — with automated testing pipelines for continuous RAG improvement.
Why RAG Evaluation Is Hard
Traditional software testing verifies exact outputs. RAG systems produce natural language answers that can be correct in multiple ways. You need metrics that capture retrieval quality (did we find the right documents?), faithfulness (does the answer match the sources?), and relevance (does it actually answer the question?).
The RAGAS Framework
Vincony integrates the RAGAS evaluation framework, which measures four key metrics: Context Precision (are retrieved documents relevant?), Context Recall (did we find all relevant documents?), Faithfulness (is the answer grounded in context?), and Answer Relevance (does the answer address the question?).
import Vincony from "vincony";
const client = new Vincony({ apiKey: "YOUR_API_KEY" });
// Define evaluation dataset
const evalSet = [
{
question: "How do I reset my API key?",
ground_truth: "Go to Settings > API Keys > Regenerate",
expected_sources: ["docs/settings.md"]
},
{
question: "What models support function calling?",
ground_truth: "GPT-4.1, Claude 4, Gemini 2.5 Pro",
expected_sources: ["docs/models.md", "docs/function-calling.md"]
}
];
// Run evaluation
const results = await client.rag.evaluate({
pipeline: "product-docs",
eval_set: evalSet,
metrics: [
"context_precision",
"context_recall",
"faithfulness",
"answer_relevancy"
]
});
console.log(`Faithfulness: ${(results.faithfulness * 100).toFixed(1)}%`);
console.log(`Answer Relevancy: ${(results.answer_relevancy * 100).toFixed(1)}%`);
console.log(`Context Recall: ${(results.context_recall * 100).toFixed(1)}%`);Building a Test Suite
Create a golden dataset of 50-100 question-answer pairs covering common queries, edge cases, and adversarial inputs. Run evaluations on every pipeline change — chunking strategy, embedding model, retrieval parameters — to catch regressions.
// Automated regression testing
const baseline = await client.rag.evaluate({ pipeline: "v1", eval_set: evalSet });
const candidate = await client.rag.evaluate({ pipeline: "v2", eval_set: evalSet });
const comparison = client.rag.compare(baseline, candidate);
comparison.metrics.forEach(m => {
const delta = ((m.candidate - m.baseline) / m.baseline * 100).toFixed(1);
const icon = m.candidate >= m.baseline ? "✅" : "❌";
console.log(`${icon} ${m.name}: ${delta}% (${m.baseline.toFixed(3)} → ${m.candidate.toFixed(3)})`);
});
if (comparison.overall_improvement < 0) {
throw new Error("RAG pipeline regression detected — blocking deployment");
}Debugging Retrieval Failures
When answers are wrong, trace back through the pipeline: Were the right documents retrieved? Was the relevant chunk in the top-k? Did the LLM ignore the context? Vincony's trace view shows each stage with scores and timing.
Continuous Monitoring
In production, track user feedback (thumbs up/down), unanswered query rate, retrieval confidence distribution, and answer latency. Set alerts when faithfulness drops below your threshold.
Pricing
RAG evaluation is included on Pro plans (up to 1,000 eval runs/month). Enterprise plans include unlimited evaluations, custom metrics, and CI/CD integration.
Try It Free — 100 API Credits
Start using these tools today with Vincony's free Developer plan.
Get Free API Key