An advanced, fault-tolerant Retrieval-Augmented Generation (RAG) agent designed for mission-critical document auditing. This engine bypasses the limitations of standard semantic search by implementing a high-performance Hybrid Retrieval pipeline, Reciprocal Rank Fusion (RRF), and AI Cross-Encoder re-ranking.
Standard RAG systems suffer from keyword blindness and contextual hallucinations. This engine solves those bottlenecks through a multi-stage data pipeline:
- Hybrid Retrieval: Executes parallel searches using FAISS (for deep semantic meaning) and BM25 (for exact keyword/ID matching).
- Mathematical Fusion (RRF): Merges distinct search results using a custom Reciprocal Rank Fusion algorithm to guarantee zero data loss.
- Cross-Encoder Re-Ranking: A secondary AI (
ms-marco-MiniLM-L-6-v2) ruthlessly scores and filters the retrieved chunks, feeding only the highest-quality evidence to the primary LLM. - Verifiable Citations: PyMuPDF extracts strict layout metadata, forcing the model to explicitly cite the exact Source File and Page Number for every claim.
- Dual-Engine LLM Routing: Hot-swap between
llama-3.3-70b-versatile(deep reasoning) andllama-3.1-8b-instant(high speed). - SaaS-Grade UI: High-contrast dark mode, glassmorphism chat bubbles, CSS keyframe animations, and real-time system telemetry.
- Graceful Degradation: Built-in safeguards auto-generate required directories and catch API rate-limit timeouts without crashing.
1. Clone the repository
git clone https://github.com/Ags-Ghafoor601/intelligent-audit-engine.git
cd intelligent-audit-engine
2. Create a virtual environment and install dependencies
python -m venv venv
source venv/bin/activate
# On Windows use: venv\Scripts\activate
pip install -r requirements.txt
3. Configure Environment Variables
Create a .env file in the root directory and add your Groq API key:
GROQ_API_KEY=your_actual_api_key_here
4. Run the Engine
streamlit run app.py
📂 Usage
- Launch the application.
- The system will automatically create a documents/ folder in your root directory if one does not exist.
- Drop your PDF files (invoices, legal contracts, compliance policies) into the documents/ folder.
- Click "Initialize Pipeline" in the sidebar telemetry dashboard.
- Enter your complex audit queries in the chat interface and expand the "View Verified Source Evidence" tab to verify the AI's citations.
System Architect: Abdul Ghafoor | Lead Data Engineer
Developed for the Softora: www.softorapk.com