How sujith-chowdary/hallucination-detection works
This is a web-based hallucination-verification system: users submit answers with supporting knowledge, the backend checks extracted claims, and the UI presents verdicts and revised answers. The documented workflow includes PDF/text ingestion, translation, short-answer expansion, claim extraction, hybrid retrieval, prioritized verification, optional web evidence, consensus, revision, and translation back. Authentication and saved knowledge bases form a supporting branch. The README documents several stages whose detailed implementation was not sampled; those links are cited to the README.
Main entry points: main.py API server · app_with_auth.py Web interface · routes.py Auth and KB routes · user_service.py User service
Components 19
User interface
- Web interface
frontend/app_with_auth.py - Auth views
frontend/auth_components.py
Verification pipeline
- API server
backend/main.py - PDF and language tools
backend/core/utils.py - Answer expansion
backend/core/self_correction_pipeline.py - Claim extraction
backend/core/self_correction_pipeline.py - Hybrid retrieval
backend/core/rag.py - Claim verification
backend/core/self_correction_pipeline.py - Verdict and revision
backend/core/self_correction_pipeline.py
Accounts and knowledge
- Auth and KB routes
backend/routes.py - Token authentication
backend/auth.py - User service
backend/services/user_service.py - Knowledge service
backend/services/knowledge_base_service.py
Evidence and persistence
- Web search
backend/core/utils.py - User records
backend/models/user.py - Knowledge records
backend/models/knowledge_base.py - PostgreSQL access
backend/database.py
Other components
- User
- SerpAPI
Connections 23
- User → Web interface: submits input
README.md - Web interface → API server: sends requests
README.md - API server → Web interface: returns results
README.md - Web interface → Auth views: uses auth views
frontend/app_with_auth.py - API server → Answer expansion: runs verification
backend/main.py - Answer expansion → Claim extraction: expands answer
README.md - Claim extraction → Hybrid retrieval: retrieves evidence
README.md - Hybrid retrieval → Claim verification: supplies evidence
README.md - Claim verification → Verdict and revision: provides verdicts
README.md - Verdict and revision → Web interface: returns revised answer
README.md - API server → PDF and language tools: uses processing tools
backend/main.py - PDF and language tools → Answer expansion: translates input
README.md - API server → Web search: uses optional search
backend/main.py - Web search → SerpAPI: queries
README.md - API server → Auth and KB routes: registers routes
backend/main.py - Auth and KB routes → Token authentication: checks identity
backend/routes.py - Auth and KB routes → User service: delegates user actions
backend/routes.py - Auth and KB routes → Knowledge service: delegates KB actions
backend/routes.py - User service → User records: uses user schema
backend/services/user_service.py - User service → PostgreSQL access: queries and writes
backend/services/user_service.py - Knowledge service → Knowledge records: uses KB schema
backend/services/knowledge_base_service.py - Knowledge service → PostgreSQL access: queries and writes
backend/services/knowledge_base_service.py - API server → PostgreSQL access: connects at startup
backend/main.py