I built an open-source hallucination detector that identifies when LLM outputs contain information not present in the source context. The tool is particularly useful for RAG systems where ensuring factual accuracy is critical.<p>Unlike most hallucination detection approaches that require separate LLM calls (which add cost and latency), this is a lightweight classifier built on HuggingFace transformers. It's adaptive, meaning it continuously improves as it processes more examples.<p>Technical approach:<p>- Uses a prototype memory system that maintains class examples for quick adaptation<p>- Combines transformer embeddings with an adaptive neural layer<p>- Trained on the RAGTruth benchmark dataset across QA, summarization, and data-to-text tasks<p>- Achieves 80.7% recall overall (51.5% F1), with strongest performance on data-to-text generation<p>Example usage:<p>from adaptive_classifier import AdaptiveClassifier<p># Load pre-trained detector<p>detector = AdaptiveClassifier.from_pretrained("adaptive-classifier/llm-hallucination-detector")<p># Format input with context, query and response<p>input_text = f"Context: {your_context}\nQuestion: {your_question}\nAnswer: {llm_response}"<p># Get prediction<p>prediction = detector.predict(input_text)<p># Returns: [('HALLUCINATED', 0.72), ('NOT_HALLUCINATED', 0.28)]<p>Current limitations:<p>- Performance varies by task type (stronger on data-to-text, weaker on summarization precision)<p>- Initial version focuses on binary classification; token-level detection is planned<p>- The model is relatively small, so it won't catch subtle nuanced hallucinations that require deep domain knowledge<p>The library's wider goal is to enable adaptive classification for use cases where models need to continuously learn from new examples. We've also built LLM routers and configuration optimizers with it.<p>Would love feedback from anyone working on RAG systems or LLM evaluation. What metrics or capabilities would be most useful to you in a hallucination detector?<p>Project: <a href="https://github.com/codelion/adaptive-classifier">https://github.com/codelion/adaptive-classifier</a><p>Docs: <a href="https://github.com/codelion/adaptive-classifier#hallucination-detector">https://github.com/codelion/adaptive-classifier#hallucinatio...</a>