A complete end‑to‑end application that detects hallucinations in text using a Retrieval‑Augmented Generation (RAG) pipeline and provides an AI-powered chat assistant using Groq LLMs.
This project allows users to:
✔ Paste text or upload a PDF/TXT file
✔ Perform hallucination detection using a custom RAG pipeline
✔ Extract claims from text and validate them using retrieved evidence
✔ Chat with an AI assistant powered by Groq
✔ Use a clean, modern, WhatsApp-like chat UI
- Extracts text from PDFs or TXT files
- Splits content into manageable chunks
- Normalizes and prepares text for indexing
- Converts each document chunk into embeddings
- Stores embeddings in a FAISS vector index
- Enables high‑speed similarity search
Consists of:
- Claim Extraction
- Retriever (top‑k chunk retrieval)
- LLM‑based Verification
- Fact‑checking Verdict (Supported / Refuted / NEI)
- Uses the
GroqSDK - Low-latency inferencing
- Provides conversational capabilities
hallucination-detector/
│
├── .env
├── .gitignore
├── README.md
├── requirements.txt
│
├── data/
│ ├── corpora/
│ │ └── test.txt.jsonl
│ ├── uploads/ # runtime uploaded files
│ │ └── test.txt
│ ├── metadata.json
│ └── vector_index.faiss # FAISS index generated
│
├── models/ # (optional) huggingface models if downloaded
│
├── src/
│ ├── chunking/
│ │ ├── chunker.py
│ │ └── tokenizer_utils.py
│ │
│ ├── config/
│ │ ├── __init__.py
│ │ ├── paths.py
│ │ ├── settings_loader.py
│ │ └── settings.yaml
│ │
│ ├── embedder/
│ │ ├── __init__.py
│ │ └── embedder.py
│ │
│ ├── generator/
│ │ ├── __init__.py
│ │ ├── chat_generator.py
│ │ ├── generator.py
│ │ ├── groq_generator.py
│ │ └── modes.py
│ │
│ ├── index/
│ │ ├── __init__.py
│ │ └── index_builder.py
│ │
│ ├── ingest/
│ │ └── ingest_pipeline.py
│ │ └── chunker.py
│ │ └── pdf_parser.py
│ │ └── text_parser.py
│ │
│ ├── rag_pipeline/
│ │ ├── __init__.py
│ │ └── pipeline.py
│ │
│ ├── retriever/
│ │ ├── __init__.py
│ │ └── retriever.py
│ │
│ ├── ui/
│ │ ├── __init__.py
│ │ └── streamlit_app.py
│ │
│ └── verifier/
│ ├── __init__.py
│ ├── claim_extractor.py
│ └── verifier.py
│
└── architecture.png
└── system_design.png
- Uses claim extraction
- Retrieves factual evidence
- Applies NLI (Natural Language Inference)
- Produces verdicts:
- SUPPORTED
- REFUTED
- NOT ENOUGH INFO
- Groq-powered conversational agent
- Supports contextual memory
- WhatsApp-like UI
- Fast, low-latency responses
- Extracts text using PyPDF2
- Automatically processes chunks
- Center‑aligned layout
- WhatsApp-style chat bubbles
- Animated send button
- Clean dark theme
git clone https://github.com/ritup04/hallucinationRAG.git
cd hallucinationRAGpip install -r requirements.txtCreate a .env file:
GROQ_API_KEY=your_key_here
GROQ_MODEL=llama3-8b-8192
CUDA_VISIBLE_DEVICES=-1
streamlit run src/ui/streamlit_app.pyPaste input or upload a file.
Chunking improves retrieval quality.
Using Sentence Transformers.
Top relevant evidence chunks retrieved.
Groq or HF models determine if claims are factual.
Claim: Lumeria is a real country.
Verdict: ❌ REFUTED
Evidence: No factual records found.
For queries, suggestions, or feedback, please contact:
GitHub: ritup04
Email: ritupal1626@gmail.com