Detects hallucinations in AI-generated text from ChatGPT, Gemini, and Claude.
hallucination-extension/
├── backend/
│ ├── main.py # FastAPI backend
│ └── requirements.txt
└── extension/
└── public/
├── manifest.json # Chrome extension config
├── content.js # Extracts AI text from page
├── popup.html # Extension popup UI
├── popup.js # Popup logic + API call
└── icon.png
cd backend
pip install -r requirements.txt
uvicorn main:app --reload --port 8000First run downloads the model (~500MB). Wait for:
Model loaded!
INFO: Uvicorn running on http://127.0.0.1:8000
Test it works:
curl -X POST http://localhost:8000/predict \
-H "Content-Type: application/json" \
-d '{"text": "Einstein invented the telephone in 1875."}'Expected response:
{"score": 0.87, "label": "Highly Hallucinated"}- Open Chrome → go to
chrome://extensions - Enable Developer Mode (top right toggle)
- Click Load unpacked
- Select the
extension/public/folder - Extension appears in your toolbar
- Open ChatGPT, Gemini, or Claude
- Get any AI response on screen
- Click the extension icon
- Click Analyze
- See: ✅ Safe /
⚠️ Suspicious / 🚨 Highly Hallucinated
User clicks Analyze
→ popup.js asks content.js for AI text
→ content.js extracts text from the page DOM
→ popup.js sends text to FastAPI backend
→ backend runs NLI classification model
→ returns { score, label }
→ popup.js displays result with color + confidence bar
Uses cross-encoder/nli-MiniLM2-L6-H768 from HuggingFace — a Natural Language Inference (NLI) model that detects contradiction between a claim and factual context as a hallucination signal. No training required — pre-trained and production-ready.
| Safe Response | Suspicious Response |
|---|---|