Upload multiple documents, perform Hybrid Search using FAISS + BM25, rerank results with Cross-Encoder, and generate context-aware answers using Google's Gemini 2.5 Flash—all through an elegant Streamlit interface.
🌐 Live Demo:
https://hyperrag.streamlit.app/
💻 GitHub Repository:
https://github.com/ms00000ms0000/HyperRAG
Enterprise Multi-Document RAG Assistant is a production-oriented Retrieval-Augmented Generation (RAG) system designed to answer user queries from multiple uploaded documents using modern information retrieval and Large Language Models.
Unlike traditional document chatbots that rely solely on semantic similarity, this project combines Hybrid Retrieval, Cross-Encoder Reranking, Conversation Memory, and Citation Generation to provide highly relevant, explainable, and context-aware responses.
The system is built with a modular architecture that separates indexing, retrieval, reranking, prompting, inference, memory management, and user interface into independent components, making it scalable and easy to maintain.
Whether you're querying company policies, employee handbooks, research papers, legal documents, or technical manuals, the assistant efficiently retrieves the most relevant information before generating an accurate response backed by citations.
The primary goals of this project are:
- Build a production-ready Retrieval-Augmented Generation (RAG) system.
- Support multiple document formats.
- Enable semantic and lexical search simultaneously.
- Improve retrieval quality using reranking.
- Generate trustworthy answers with citations.
- Maintain conversation history.
- Provide an intuitive enterprise-grade Streamlit interface.
- Follow modular software engineering principles.
- Create a deployment-ready AI application.
Upload multiple files simultaneously and query them together.
Supported formats:
- DOCX
- TXT
Instead of relying on only vector similarity, the system performs:
- Semantic Search (FAISS)
- Lexical Search (BM25)
Both retrieval methods are fused using Reciprocal Rank Fusion (RRF) to maximize retrieval accuracy.
The assistant uses Google's Gemini 2.5 Flash to generate natural, human-like answers based strictly on retrieved document context.
Benefits include:
- Reduced hallucinations
- Context-aware responses
- Better factual grounding
Retrieved chunks are reranked using a Cross-Encoder model before being sent to the LLM.
Advantages:
- Higher answer quality
- Better relevance
- Reduced noisy retrieval
Every generated answer includes source references containing:
- Document Name
- Page Number
This allows users to verify where information originated.
The assistant remembers previous interactions during the current session, enabling:
- Follow-up questions
- Context-aware conversations
- Better user experience
Every query includes detailed execution statistics:
- Retrieval Time
- Reranking Time
- Prompt Building Time
- LLM Response Time
- Total Execution Time
- Retrieved Chunks
- Indexed Vectors
- Embedding Dimension
The system avoids unnecessary re-indexing using document hashing.
Features include:
- Automatic change detection
- Incremental rebuild logic
- Faster startup
- Efficient indexing
The project includes a modern Streamlit frontend featuring:
- Drag-and-drop document upload
- ChatGPT-style conversation interface
- Source citations
- Metrics dashboard
- Download options
- Session management
- Clean responsive layout
The application follows a modular enterprise architecture consisting of two major pipelines.
Responsible for preparing documents for retrieval.
Workflow:
Documents
│
▼
Document Loader
│
▼
Chunking Service
│
▼
Embedding Generator
│
▼
FAISS Vector Index
│
├──────────────► BM25 Index
│
▼
Persistent Storage
Responsible for answering user queries.
User Query
│
▼
Conversation Memory
│
▼
Hybrid Search
│
├──── FAISS
│
└──── BM25
│
▼
Reciprocal Rank Fusion
│
▼
Cross Encoder Reranker
│
▼
Prompt Builder
│
▼
Gemini 2.5 Flash
│
▼
Answer + Citations + Metrics
| Component | Responsibility |
|---|---|
| Document Manager | Finds and validates uploaded files |
| Loader Factory | Selects appropriate loader (PDF/DOCX/TXT) |
| Chunking Service | Splits documents into overlapping chunks |
| Embedding Service | Generates sentence embeddings |
| FAISS Vector Store | Semantic similarity search |
| BM25 Engine | Keyword-based retrieval |
| Hybrid Search | Combines FAISS and BM25 |
| RRF Service | Fuses search rankings |
| Cross Encoder | Reranks retrieved chunks |
| Prompt Builder | Builds optimized prompts |
| Gemini Service | Generates AI responses |
| Citation Service | Creates document citations |
| Conversation Memory | Maintains chat history |
| Session Manager | Tracks session statistics |
| Streamlit UI | User interaction layer |
Most basic RAG systems only perform vector search, which often misses exact keyword matches or retrieves less relevant context.
This project enhances traditional RAG by combining:
- Hybrid Retrieval (FAISS + BM25)
- Reciprocal Rank Fusion (RRF)
- Cross-Encoder Reranking
- Conversation Memory
- Source Citations
- Performance Metrics
- Enterprise-grade Streamlit UI
- Smart Index Rebuilding
- Modular Software Architecture
The result is a scalable, production-oriented AI assistant suitable for enterprise knowledge bases, HR policy assistants, legal document search, research paper analysis, and internal documentation systems.
| Category | Technology |
|---|---|
| Programming Language | Python 3.11+ |
| Frontend | Streamlit |
| LLM | Google Gemini 2.5 Flash |
| Embedding Model | Sentence Transformers (all-MiniLM-L6-v2) |
| Vector Database | FAISS |
| Lexical Search | BM25 |
| Retrieval Fusion | Reciprocal Rank Fusion (RRF) |
| Reranker | Cross-Encoder (MS MARCO) |
| Document Processing | PyMuPDF, python-docx |
| Numerical Computing | NumPy |
| Environment Management | python-dotenv |
| Logging | Python Logging |
| Deployment | Streamlit Community Cloud |
| Version Control | Git & GitHub |
enterprise-multi-document-rag/
│
├── app/
│ ├── chunking/
│ ├── config/
│ ├── document_loader/
│ ├── fusion/
│ ├── llm/
│ ├── logging/
│ ├── pipelines/
│ ├── prompts/
│ ├── reranker/
│ ├── retrieval/
│ ├── search/
│ ├── services/
│ ├── session/
│ ├── storage/
│ ├── ui/
│ ├── utils/
│ └── vectorstore/
│
├── docs/
│
├── uploaded_documents/
│
├── faiss_index/
│
├── run.py
├── requirements.txt
├── packages.txt
├── .env.example
├── .gitignore
└── README.md
The project follows a Retrieval-Augmented Generation (RAG) workflow consisting of two major stages.
Documents
│
▼
Load Documents
│
▼
Chunk Documents
│
▼
Generate Embeddings
│
▼
Create FAISS Index
│
▼
Create BM25 Index
│
▼
Save Index
User Query
│
▼
Conversation Memory
│
▼
Hybrid Search
│
▼
Reciprocal Rank Fusion
│
▼
Cross Encoder
│
▼
Prompt Builder
│
▼
Gemini 2.5 Flash
│
▼
Answer
│
├── Citations
└── Performance Metrics
git clone https://github.com/ms00000ms0000/enterprise-multi-document-rag.git
cd enterprise-multi-document-ragpython -m venv .venv
.venv\Scripts\activatepython3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtFor Streamlit Cloud, install system packages using:
packages.txt
libgl1
libglib2.0-0
Create a file named:
.env
Add the following:
GEMINI_API_KEY=YOUR_GEMINI_API_KEY- Visit
https://aistudio.google.com/app/apikey
-
Create a new API Key
-
Copy it into the
.envfile
python run.pyExample
python run.py --docs docsstreamlit run app/ui/streamlit_app.pyAfter launching, open
http://localhost:8501
The application is deployed on Streamlit Community Cloud.
https://hyperrag.streamlit.app/
The assistant currently supports:
- DOCX
- TXT
Multiple files can be uploaded simultaneously.
Every user query goes through the following pipeline:
User Question
│
▼
Conversation Memory
│
▼
Vector Retrieval (FAISS)
│
▼
Keyword Retrieval (BM25)
│
▼
Reciprocal Rank Fusion
│
▼
Cross Encoder Reranking
│
▼
Prompt Construction
│
▼
Gemini 2.5 Flash
│
▼
Answer + Citations + Metrics
This project includes several optimizations for faster retrieval and lower latency.
Previously generated FAISS indexes are reused whenever possible to avoid unnecessary embedding generation.
Embeddings are generated in configurable batches for better memory utilization and faster indexing.
Combining semantic and lexical retrieval significantly improves recall compared to standalone vector search.
Only the most relevant chunks are forwarded to the language model, improving both response quality and inference speed.
Recent interactions are maintained within the session, enabling contextual follow-up questions.
- API keys are never hardcoded.
- Environment variables are used for sensitive credentials.
- Uploaded documents remain isolated within the active session.
- The application does not permanently store user conversations.
- Document citations improve transparency and answer traceability.
This system can be adapted for:
- 📚 Enterprise Knowledge Base
- 🏢 HR Policy Assistant
- ⚖️ Legal Document Search
- 🏥 Healthcare Documentation
- 🎓 Educational Content Assistant
- 📄 Research Paper Exploration
- 🏦 Banking & Financial Compliance
- 🛡️ Internal SOP Search
- 📑 Technical Documentation Assistant
- 🧾 Company Handbook Assistant
The modular architecture allows future integration with:
- Pinecone
- ChromaDB
- Weaviate
- Milvus
- Azure AI Search
- Elasticsearch
- OpenSearch
- PostgreSQL + pgvector
without major architectural changes.
For every user query, the system reports detailed execution statistics.
| Metric | Description |
|---|---|
| Retrieval Time | Time spent performing Hybrid Search |
| Reranking Time | Cross-Encoder reranking latency |
| Prompt Build Time | Prompt construction time |
| LLM Time | Gemini inference time |
| Total Time | Overall pipeline execution |
| Indexed Vectors | Number of vectors stored in FAISS |
| Embedding Dimension | Embedding vector dimension |
| Final Chunks | Chunks provided to Gemini |
- Google Gemini SDK
- Sentence Transformers
- Cross Encoder
- FAISS
- rank-bm25
- NumPy
- PyMuPDF
- python-docx
- Streamlit
- python-dotenv
- pathlib
- hashlib
- logging
- pickle
- json
- tempfile
- shutil
Upload Documents
│
▼
Documents Indexed
│
▼
Ask Question
│
▼
Hybrid Retrieval
│
▼
Cross Encoder
│
▼
Gemini Generates Answer
│
▼
Answer + Citations + Metrics
The architecture has been intentionally designed to support enterprise-scale enhancements.
Planned improvements include:
- 🔐 User Authentication
- 👥 Multi-user Session Management
- 🖼️ Image Retrieval (Multimodal RAG)
- 📊 Admin Dashboard
- ☁️ Cloud Vector Databases (Pinecone, Weaviate, Milvus)
- 📂 Shareable Knowledge Bases
- 📑 OCR Support for Scanned PDFs
- 🎤 Voice-based Question Answering
- 🌍 Multi-language Document Support
- 🔎 Metadata-based Filtering
- 📅 Incremental Document Indexing
- 📡 API Version using FastAPI
- 🤖 Agentic RAG Workflow
- 🧩 MCP (Model Context Protocol) Integration
- 📈 Analytics Dashboard
- 🛡️ Role-Based Access Control (RBAC)
- 📝 Feedback-based Answer Improvement
This project demonstrates practical implementation of:
- Retrieval-Augmented Generation (RAG)
- Large Language Model Integration
- Hybrid Information Retrieval
- Vector Search using FAISS
- Lexical Search using BM25
- Cross-Encoder Reranking
- Prompt Engineering
- Modular Software Architecture
- Production-ready Python Development
- Streamlit Web Application Development
- Performance Monitoring
- Citation-based Explainability
- Enterprise Software Design
Contributions are always welcome.
If you would like to improve this project:
- Fork the repository
- Create a new feature branch
git checkout -b feature/your-feature- Commit your changes
git commit -m "Add new feature"- Push the branch
git push origin feature/your-feature- Open a Pull Request
If you encounter any bugs or have suggestions for improvements, please open an issue on GitHub.
Every contribution helps make the project better.
If you found this project helpful or learned something from it:
⭐ Star the repository
🍴 Fork the project
🛠️ Contribute new features
📢 Share it with others
Your support motivates continued development and future open-source AI projects.
This project is licensed under the MIT License.
You are free to:
- Use
- Modify
- Distribute
- Build upon this project
with proper attribution.
See the LICENSE file for complete details.






