A production-style RAG Agent for academic literature research, featuring multi-stage retrieval, agentic routing, and automated evaluation.
SecuRAG is an intelligent research assistant built on a full agentic architecture. Unlike simple RAG systems, SecuRAG implements a multi-stage retrieval pipeline and an autonomous intent router that decides whether to retrieve from the knowledge base or respond directly.
- Agentic Intent Router: Autonomously classifies user queries into SEARCH or CHAT, achieving 85% accuracy on a 20-case test set.
- Hybrid Retrieval Pipeline: Combines BM25 keyword retrieval and dense vector search for higher recall.
- CrossEncoder Reranking: Two-stage retrieval with CrossEncoder re-scoring for improved precision.
- Query Rewriting: LLM-based coreference resolution to handle multi-turn ambiguous queries.
- Multi-turn Memory: Session-based conversation history management.
- LLM-as-a-Judge Eval: Automated evaluation of answer relevance and completeness.
- Local Privacy Mode: Fully offline using Ollama + ChromaDB. Zero data egress.
- Microservices Architecture: Decoupled FastAPI backend + Streamlit frontend, Docker-ready.
| Metric | Result |
|---|---|
| Intent Router Accuracy | 85% (17/20 test cases) |
| Retrieval | BM25 + Vector hybrid, top-5 recall |
| Reranking | CrossEncoder ms-marco-MiniLM-L-6-v2 |
| Eval | LLM-as-a-Judge (relevance + completeness) |
- Python 3.10+
- Ollama installed and running
- Docker (optional)
git clone https://github.com/HITGoose/SecuRAG-Agent.git cd SecuRAG-Agent pip install -r requirements.txt
APP_MODE=local OLLAMA_HOST=http://localhost:11434 DEEPSEEK_API_KEY=your_key
ollama pull deepseek-r1:1.5b
Option A: Docker docker-compose up
Option B: Manual Terminal 1: python api_server.py Terminal 2: streamlit run frontend.py
| Layer | Technology |
|---|---|
| LLM | DeepSeek / Ollama |
| Vector DB | ChromaDB |
| Retrieval | BM25 + Dense Vector |
| Reranking | CrossEncoder |
| Backend | FastAPI |
| Frontend | Streamlit |
| Deployment | Docker |
securag_engine.py - Core RAG Agent engine hybrid_retriever.py - BM25 + Vector hybrid retrieval reranker.py - CrossEncoder reranking security_guard.py - Input sanitization pdf_loader.py - PDF ingestion pipeline api_server.py - FastAPI backend frontend.py - Streamlit UI test_intent.py - Intent router evaluation test_eval.py - LLM-as-a-Judge evaluation Dockerfile docker-compose.yml
