ALETHEX — Temporal Belief Consistency Engine
Catch AI self-contradictions in real time — Chrome extension + Python engine that watches AI chat sessions and flags when the AI says something that contradicts what it said before.
What Is ALETHEX?
ALETHEX is two things:
1. Chrome Extension — loads silently alongside your AI chats (ChatGPT, Claude, Gemini, Grok, Copilot) and shows a live Consistency Index badge. When the AI contradicts itself, ALETHEX flags it immediately.
2. Python Library — a full Temporal Belief Graph engine for researchers and developers building contradiction-aware RAG pipelines, LangChain memory, or LlamaIndex filters.
Chrome Extension
Install
- Download
dist/alethex-extension-v1.0.0.zipand unzip it - Open
chrome://extensions/and enable Developer mode (top right) - Click Load unpacked and select the unzipped
extension/folder - Visit ChatGPT, Claude, or Gemini — the ALETHEX badge appears automatically
How It Works
Every AI reply
|
[Fast regex pass — ~0ms]
Extract explicit facts (name, location, job, diet, age, etc.)
|
[NLI semantic pass — ~2-5s]
Build all sentence pairs across the full conversation
Run DeBERTa-v3-Large ONNX contradiction detection in-browser
|
[Consistency Index]
CI = 1.0 - (conflicts + superseded x 0.5) / totalClaims
─────────────────────────────────────────────────────────
1.0 = Fully consistent (green)
0.5-0.99 = Facts updated (amber)
< 0.5 = Active contradictions (red)
The NLI model runs 100% in-browser via Transformers.js — no server, no API calls. Downloaded once (~641MB), cached permanently.
Example Detections
| Earlier statement | Later statement | Detected |
|---|---|---|
| "I live in New York." | "I moved to London last year." | contradiction (0.97) |
| "I am vegetarian." | "I had steak for dinner." | contradiction (0.94) |
| "I work at Google." | "My job at Microsoft keeps me busy." | contradiction (0.91) |
| "I am 25 years old." | "I turn 30 next week." | contradiction (0.88) |
NLI Models on HuggingFace
Both models trained for 3 epochs on a unified 1M+ pair corpus (MultiNLI + SNLI + Temporal-NLI), no synthetic data.
| Model | Parameters | ONNX size | Accuracy | Link |
|---|---|---|---|---|
| alethex-nli-deberta-v3-large (default) | 400M | 641 MB | 92.8% | HuggingFace |
| alethex-nli-deberta-v3-small (lightweight) | 22M | 172 MB | 92.8% | HuggingFace |
Training Progression
| Epoch | Accuracy | Macro F1 | MCC |
|---|---|---|---|
| 1 | 91.94% | 91.94% | 0.879 |
| 2 | 92.51% | 92.52% | 0.887 |
| 3 | 92.80% | 92.81% | 0.892 |
Large model trained on 8x NVIDIA H100 80GB (BF16, effective batch size 2048). Small model trained on RTX 4050 Laptop GPU.
Python Library
Install
pip install alethex
Or from source:
git clone https://github.com/codewithyug/alethex.git
cd alethex
pip install -e .
Optional extras:
pip install "alethex[langchain]" # LangChain integration
pip install "alethex[llamaindex]" # LlamaIndex integration
pip install "alethex[dev]" # dev tools (pytest, ruff, mypy)
Quickstart
import alethex
memories = [
{"id": "m1", "timestamp": "2024-01-10", "text": "Alice works at Google in London."},
{"id": "m2", "timestamp": "2024-06-15", "text": "Alice relocated to Tokyo and joined Anthropic."}
]
filtered = alethex.filter_context(memories)
# -> returns only m2 (m1 is superseded)
Online Session Tracking
from datetime import datetime
from alethex.streaming.online_session import OnlineBeliefTracker
tracker = OnlineBeliefTracker()
tracker.process_turn("user", "I live in London and work at Google.", datetime(2024, 1, 15))
tracker.process_turn("user", "I moved to Tokyo last week.", datetime(2024, 7, 1))
print(tracker.get_active_beliefs("user"))
print(tracker.get_current_ci()) # 0.75 — superseded fact detected
LangChain / LlamaIndex
# LangChain — drop-in reconciled memory
from alethex.integrations.langchain_memory import AlethexReconciledMemory
# LlamaIndex — post-processor that drops or annotates contradicted context
from alethex.integrations.llamaindex_filter import AlethexConsistencyFilter
CLI
python -m alethex.cli run-pipeline --corpus dataset/corpus.jsonl --output-dir results/
python -m alethex.evaluation.eval_pipeline --samples 150
Repository Structure
alethex/
|
+-- alethex/ # Python package
| +-- ingestion/ # Document loaders and schema
| +-- extraction/ # Claim extraction (OpenIE + LLM)
| +-- coreference/ # Cross-document entity linking
| +-- temporal/ # TIMEX parsing and interval algebra
| +-- relation/ # NLI classifier and LLM judge
| +-- graph/ # Temporal belief graph (MultiDiGraph)
| +-- scoring/ # Consistency Index calculation
| +-- optim/ # ONNX export and INT8 runtime
| +-- training/ # NLI fine-tuning trainer
| +-- streaming/ # Incremental OnlineBeliefTracker
| +-- integrations/ # LangChain, LlamaIndex, MCP, OpenAI proxy
| \-- evaluation/ # Benchmarking suite
|
+-- extension/ # Chrome extension (MV3 source)
| +-- manifest.json
| +-- background.js # Service worker
| +-- content.js # Chat page observer
| +-- nli_worker.js # NLI Web Worker (Transformers.js)
| +-- popup.html / popup.js # Extension popup UI
| \-- vendor/ # Bundled transformers.min.js (no CDN)
|
+-- configs/ # Training and inference YAML configs
+-- dataset/ # Preprocessed NLI data (gitignored — large files)
+-- docs/ # Documentation and training reference
+-- experiments/ # Evaluation scripts and experiments
+-- models/ # Model checkpoints and ONNX (gitignored — large files)
| +-- alethex-nli/ # Small model checkpoints
| +-- alethex-nli-large/ # Large model (H100 trained, 1.7GB)
| +-- alethex-nli-onnx/ # Small ONNX (172MB quantized)
| \-- alethex-nli-large-onnx/ # Large ONNX (641MB quantized)
+-- paper/ # Draft paper and figures
+-- results/ # Training logs and benchmark reports
+-- scripts/ # Utility scripts
| +-- export_onnx.py # Export checkpoint to ONNX + INT8
| +-- analyze_training_results.py
| +-- start_all.py
| \-- alethex_desktop.py # Desktop companion (MCP auto-attach)
+-- tests/ # Test suite
+-- dist/ # Packaged extension zip for download
+-- pyproject.toml
+-- requirements.txt
\-- LICENSE
Export a Model to ONNX
python scripts/export_onnx.py \
--checkpoint models/alethex-nli-large \
--out-dir models/alethex-nli-large-onnx
Testing
python -m pytest tests/ -v
Citation
@misc{alethex2026,
title = {ALETHEX: Temporal Belief Consistency Engine for AI Chat Contradiction Detection},
author = {codewithyug},
year = {2026},
url = {https://github.com/codewithyug/alethex}
}
License
Apache 2.0 — free for commercial and research use.
Metadata
Release files for alethex 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| alethex-0.1.2.tar.gz | 93.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| alethex-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 192.8 kB
Release files / alethex-0.1.2.tar.gz
| Download URL | alethex-0.1.2.tar.gz |
|---|---|
| Size | 93.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d50d3de330ac345ad1b89b05ac6d8ab0fd548fabd96dba0918f9d73653a2b2d
|
|
BLAKE2b-256 checksum How to use checksums |
1d7b1a4e2b27c257a43da2477f5d7188d4f141f654dbf081f3cbaf0ae7a95504
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Release files / alethex-0.1.2-py3-none-any.whl
| Download URL | alethex-0.1.2-py3-none-any.whl |
|---|---|
| Size | 99.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
74167274d1d59f905f23787df3a02cefbfaebdfb7e6d5514368c6a5065bd451f
|
|
BLAKE2b-256 checksum How to use checksums |
99065015f434ad3c7d31e61b2b1d058880edb0a843334d3d6ca40d5514d563be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|