How saiakhil066/deepseek-rag-chatbot works
Main Components
• User Interface (UI): Represented by app.py which launches a Streamlit web app. This is where users interact with the chatbot.
• Document Processing: The module (doc_handler.py inside the utils folder) handles file uploads (PDF, DOCX, TXT) and preliminary document processing.
• Retrieval Pipeline: The retriever_pipeline.py handles the hybrid retrieval process using BM25 and FAISS. This module is responsible for fetching the most relevant chunks from the processed documents.
• Knowledge Graph / GraphRAG Module: The build_graph.py script builds the Knowledge Graph from the documents; this component underpins the GraphRAG functionality.
• Neural Reranking & Query Expansion: Although not a separate file, the README indicates the use of a cross-encoder model for neural reranking and HyDE for query expansion.
• Chat Memory Integration: An essential feature that maintains conversation history, influencing how queries are processed for contextual understanding.
• External Model Service (Ollama): The system interacts with external LLM services (via the Ollama tool) to generate responses from the DeepSeek-7B model and others. This is integrated either as a host service or containerized via docker-compose.
• Deployment & Containerization: Key files like Dockerfile, docker-compose.yml, and environment configurations (.env) indicate container setups, particularly for two-container arrangements (one for the chatbot service and one for Ollama).
Relationships and Interactions
• User initiates interactions via the UI (Streamlit app).
• Uploaded documents are handled and processed by doc_handler, then routed through the retriever_pipeline which applies retrieval algorithms (BM25 + FAISS).
• The retrieved chunks are further processed by the GraphRAG module to build a knowledge graph.
• Neural reranking and query expansion modules (invoked within the backend logic) refine the results.
• Chat memory integration ensures previous interactions influence the current query, maintaining context.
• The final answer generation involves communication with the external LLM service (Ollama) for deep model inference.
• In a Docker-based setup, the chatbot service and Ollama run in separate containers and are connected via network links (as shown in the docker-compose file).
Architectural Patterns and Design Principles
• Modular Design: The separation of concerns is clear (UI layer, document processing, retrieval, graph building, integration with external LLM), which aligns with microservices or modular monolith patterns.
• Containerization: Use of Docker and docker-compose enforces clearly separated runtime environments.
• Hybrid Retrieval and Neural Reranking: Incorporates multiple advanced techniques for information retrieval and response generation.
• Extensibility: With features like selecting different RAG pipelines and models, the architecture is built to naturally extend to new methods or data sources.