Issue
LLM-generated technical tutorials contained unverified claims about FastMCP API behavior, lacking ground truth validation. This resulted in:
- Undetected hallucinations regarding API parameters.
- Incorrect method signatures in code examples.
- Missing or misrepresented configuration options.
- No citation trail to official documentation.
Culprit
The validation approach relied solely on LLM self-assessment without external reference points, leading to:
- No Document Grounding: No connection to official FastMCP documentation.
- Semantic Gap: Claims were compared only against LLM’s parametric knowledge.
- No Citation Trail: Inaccuracies could not be traced to specific documentation sections.
- Binary Judgments: Only ‘correct/incorrect’ assessments without detailed explanations.
Solution
ChromaDB Semantic Index
- Document Ingestion: Indexed all
.mdxfiles from the official FastMCP documentation into ChromaDB using theall-MiniLM-L6-v2embedding model. - Semantic Search Endpoint: Added a tool to search and retrieve relevant documentation chunks for validation purposes.
Document-Grounded Validation
- Claim Extraction: Used an LLM to extract technical claims from generated tutorials in JSON format.
- Semantic Validation Loop: For each claim, retrieved relevant documentation chunks and validated the claim against these chunks using the LLM.
Key Implementation Details
- Ultra-Lean Architecture: 155 lines total across components.
- Zero Configuration: Utilized ChromaDB defaults for embeddings.
- Fail-Fast Design: No error handling for LLM JSON parsing, making errors visible.
- Whole-File Indexing: Processed complete
.mdxfiles without chunking. - Accuracy Scoring: Returned percentage accuracy and specific inaccuracies with citations.
Performance Metrics
- Indexing: 181 documentation files indexed in approximately 20 seconds.
- Validation: ~3 seconds per tutorial script.
- Accuracy Improvement: Increased accuracy from 78% to 96% in test cases, with documentation citations.