Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/TangibleResearch/Halgorithem/llms.txt

Use this file to discover all available pages before exploring further.

Halgorithem is a Python library that detects AI hallucinations by splitting AI output into individual claims and verifying each one against your provided source documents. Unlike AI-based approaches, Halgorithem uses semantic embeddings, NLP, and symbolic math to flag unsupported claims, contradictions, and hallucinated facts — without requiring a second AI call.

Quickstart

Get from install to your first hallucination report in under 5 minutes.

How it works

Understand the claim-extraction and verification pipeline.

Python integration

Use Halgorithem directly in your Python scripts and notebooks.

API reference

Full reference for the Halgorithm class and Engine module.

What Halgorithem detects

Every AI output claim receives one of four verdicts after comparison with your truth documents:
StatusMeaning
SUPPORTEDClaim is semantically supported by source documents
WEAK_SUPPORTClaim is related but not strongly backed
CONTRADICTIONClaim directly conflicts with source documents
HALLUCINATIONClaim has no grounding in source documents

Get started in three steps

1

Install the library

Clone the repository, create a virtual environment, and install dependencies.
git clone https://github.com/TangibleResearch/Halgorithem.git
cd Halgorithem
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
python -m spacy download en_core_web_sm
2

Provide source documents

Point Halgorithem at your truth sources — local files or web URLs.
from Halgorithem import Halgorithm

algo = Halgorithm()
docs = algo.load_files(["my_source.txt"])
3

Verify AI output

Pass AI-generated text and get a per-claim verification report.
results = algo.compare_to_docs(
    truth_docs=docs,
    ai_output="The Apollo 11 mission landed on the Moon in 1969.",
    threshold=0.30
)
algo.print_report(results)

Key features

No AI required

Detection runs entirely on NLP and semantic similarity — no LLM calls needed for verification.

Number conflict detection

Catches numeric hallucinations — wrong dates, figures, costs, and statistics.

Negation mismatch

Flags claims where the AI inverts the meaning of a source statement.

AI pipeline integration

Drop into LangGraph, CrewAI, PydanticAI, or AutoGen workflows.

Web scraping

Automatically scrape URLs (including Wikipedia) as truth sources.

Interactive TUI

Run verification interactively from the command line with the built-in TUI.

Build docs developers (and LLMs) love