In a striking demonstration of how AI systems can generate convincing falsehoods, a developer caught his own robot confidently describing a World Cup match that never happened. The robot claimed Senegal lost to Belgium in the final — a complete fabrication.
This incident prompted the creator to build a custom faithfulness evaluation system, known as RAGAS (Retrieval Augmented Generation Assessment), from first principles. The goal: systematically detect and measure hallucinations in AI responses.
Why Hallucinations Are Normal
Hallucinations are not bugs; they are a known feature of large language models. Relying on single spot-checks can be misleading because the same question posed minutes apart can yield different answers. A systematic evaluation method is essential.
Building a Faithfulness Metric by Hand
The developer implemented a manual faithfulness metric in about 60 lines of code. The process involves three steps:
- Claim extraction – break the answer into individual factual claims.
- Per-claim verification – check each claim against a trusted knowledge base.
- Supported/total ratio – calculate the fraction of claims that are supported.
Critically, faithfulness measures grounding, not absolute truth. A factually correct answer can score zero if the claims are not supported by the given context.
Live Scoring Examples
The developer demonstrated three real robot answers:
- Full hallucination (score 0.00): The robot fabricated the World Cup result entirely.
- Clean answer (score 1.00): All claims were supported by context.
- Dangerous half-grounded case (score 0.50): Partially correct, partially fabricated — the most insidious kind.
Broader Framework
Faithfulness is just one of four metrics in the full RAGAS framework:
- Faithfulness – are answer claims grounded in retrieved context?
- Answer Relevancy – does the answer address the question?
- Context Recall – was all necessary context retrieved?
- Context Precision – was irrelevant context avoided?
The next part of the series will apply all four metrics to a single question, producing a complete report card for the robot's responses.
Technical Stack
The evaluation pipeline uses DistilBERT for routing, ChromaDB for vector storage, MCP tools for model context protocol, and a fine-tuned 1B Llama model (GRPO) running on a Raspberry Pi 5. The judge model is Claude API.
Code for the manual faithfulness implementation is available on GitHub: github.com/puneetratan.
This article is based on a video from the AI Classroom with Puneet channel, demonstrating the importance of robust evaluation metrics for AI systems.