Skip to main content

Document-Grounded Verification for Large Language Models

Project description

HalluciNOT Logo

PyPI version Python versions License

HalluciNOT

Why HalluciNOT?

The Trust Problem in AI: Large Language Models (LLMs) have revolutionized how we interact with information, but they come with a critical flaw - hallucinations. When an LLM confidently presents incorrect information as fact, it undermines trust in AI systems and can lead to serious consequences in high-stakes domains.

The RAG Gap: Retrieval-Augmented Generation (RAG) systems attempt to ground LLM outputs in reliable sources, but they often lack rigorous verification mechanisms. The source material is retrieved, but how do we ensure the LLM's claims actually align with it?

HalluciNOT bridges this gap.

HalluciNOT is a modular toolkit that systematically verifies LLM outputs against source documents, providing:

  • Precise verification that maps specific claims to document evidence
  • Quantified confidence scores for each factual assertion
  • Actionable intervention strategies when hallucinations are detected
  • Transparent reporting that builds trust through visibility

Unlike general hallucination detection systems, HalluciNOT is specifically designed for document-grounded applications where source material is available as the ground truth.

Key Features

HalluciNOT Workflow

🔍 Claim Detection and Source Mapping

  • Extract discrete factual assertions from LLM outputs
  • Map claims back to specific document chunks using metadata
  • Calculate semantic alignment between claims and sources
  • Identify unsupported or misaligned claims

📊 Confidence Scoring System

  • Quantify alignment between claims and source material
  • Provide multi-dimensional confidence metrics for different claim types
  • Generate consolidated trustworthiness assessments for responses
  • Calibrate confidence scores based on evidence strength

🛠️ Hallucination Management

  • Select appropriate interventions for detected inaccuracies
  • Generate corrections grounded in source material
  • Implement standardized uncertainty communication patterns
  • Maintain conversation flow while addressing factual issues

📈 Visualization and Reporting

  • Highlight confidence levels within responses
  • Create clear source attributions and citations
  • Generate detailed verification reports
  • Monitor hallucination patterns over time

Quick Start

Installation

pip install hallucinot

# Optional: Install spaCy for enhanced claim extraction
pip install spacy
python -m spacy download en_core_web_sm

Basic Usage

from hallucinot import VerificationProcessor, DocumentStore, DocumentChunk

# Create document chunks
chunks = [
    DocumentChunk(
        id="doc1-chunk1",
        text="The Earth orbits the Sun at an average distance of 93 million miles.",
        source_document="astronomy_facts.txt"
    ),
    # Add more document chunks...
]

# Create document store
document_store = DocumentStore(chunks)

# Create verifier
verifier = VerificationProcessor()

# Verify an LLM response
llm_response = "The Earth orbits the Sun at a distance of 90 million miles, completing one orbit every 365.25 days."
result = verifier.verify(llm_response, document_store)

# Print results
print(f"Overall confidence: {result.confidence_score:.2f}")
print(f"Hallucination score: {result.hallucination_score:.2f}")

# Generate highlighted output
highlighted = verifier.highlight_verification_result(result, format="html")

# Generate corrected response
corrected = verifier.generate_corrected_response(result, strategy="balanced")

Business Value

Risk Mitigation

  • Reduce the risk of propagating false information in customer-facing AI applications
  • Protect your organization's reputation through verifiable AI claims
  • Create audit trails of verification for regulated industries

Enhanced User Trust

  • Provide transparency into the reliability of AI-generated content
  • Allow users to distinguish between verified and unverified information
  • Build confidence in your AI systems' outputs

Operational Efficiency

  • Automate the fact-checking process that would otherwise require human review
  • Focus reviewer attention only on claims that need human verification
  • Reduce the time and cost of manually validating AI outputs

Competitive Advantage

  • Differentiate your AI offerings with superior factual reliability
  • Address a key concern that limits enterprise adoption of generative AI
  • Demonstrate responsible AI practices to stakeholders

Integration with RAG Systems

HalluciNOT works seamlessly with ByteMeSumAI and other RAG frameworks to create a complete document processing and verification pipeline:

  1. Document ingestion and chunking (RAG system)
  2. Metadata enrichment and embeddings (RAG system)
  3. LLM response generation (RAG system)
  4. Claim extraction and verification (HalluciNOT)
  5. Confidence scoring and reporting (HalluciNOT)
  6. Hallucination correction (HalluciNOT)

Technical Approach

HalluciNOT uses a modular architecture with specialized components:

  1. Claim Extraction: Identifies discrete factual assertions in text
  2. Source Mapping: Maps claims to supporting document chunks
  3. Confidence Scoring: Calculates alignment scores and confidence metrics
  4. Intervention Selection: Recommends strategies for handling hallucinations
  5. Visualization: Generates reports and highlighted outputs

Each component can be configured independently, allowing for customization to specific use cases.

Status and Roadmap

Current Status: Alpha release (v0.1.0)

Roadmap

  1. Alpha Phase (Current)

    • Core verification functionality
    • Basic integration capabilities
    • Rule-based and NLP-based claim extraction
  2. Beta Phase (Q2 2025)

    • Performance optimization
    • Enhanced visualization options
    • Integration with popular RAG frameworks
    • Benchmarking suite
  3. Production Release (Q3 2025)

    • Full test coverage
    • Comprehensive documentation
    • Pre-trained models for claim extraction
    • Real-world case studies

Use Cases

  • Enterprise Knowledge Bases: Verify information extracted from company documents
  • Customer Support: Ensure accurate responses based on product documentation
  • Legal & Compliance: Verify claims against regulatory documents
  • Research Analysis: Ground scientific claims in research papers
  • Educational Content: Ensure factual accuracy in learning materials
  • Content Creation: Validate auto-generated content against style guides

Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

Acknowledgments

HalluciNOT is developed as a companion to ByteMeSumAI to create a more robust ecosystem for document-grounded AI applications.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hallucinot-0.1.0.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hallucinot-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file hallucinot-0.1.0.tar.gz.

File metadata

  • Download URL: hallucinot-0.1.0.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for hallucinot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 12c64376e65e6e932e9d4f516cc3ba0b51c2e56080ec57d4d642e02dfffe72f5
MD5 54f0336172a93cc061ee882ff6d9f7fe
BLAKE2b-256 eec60518f9e0b43218855e1f5cfd0b63aec4edbd42f67299343b12837143e16d

See more details on using hashes here.

File details

Details for the file hallucinot-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hallucinot-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for hallucinot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dce47bb6dc55c779ae18d6a0df245e04db64e8e4e107b6d7632245d50b177c15
MD5 7879e59137d022d243b55d85164674a5
BLAKE2b-256 cb9af9ff786b9491da64eb68f4eb9c221669d5a993294d780d0c89448d79f6a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page