How gurpreetkaurjethra/rag-based-llm-chatbot works
Project type and purpose
• This is a single-page, full-stack RAG (Retrieval-Augmented Generation) chatbot application built on Streamlit.
• Purpose: allow users to upload PDF files, generate embeddings for semantic search, and chat with a local LLM (Llama 3.2 via Ollama) using a LangChain orchestration layer and Qdrant vector database.
File structure
Top-level files and folders:
• new.py – Streamlit entrypoint (frontend + high-level orchestration)
• chatbot.py – LangChain chains and prompt logic (chat interface)
• vectors.py – Embedding creation and vector-store interaction
• aliases/ – JSON templates or prompt aliases (aliases/data.json)
• raft_state.json – state file for streamlit session or Qdrant Docker state
• requirements.txt, Docker config implied for Qdrant
Key patterns:
– MVC-like separation: new.py (view + controller), chatbot.py & vectors.py (model/services)
– External services: Qdrant (Docker container), Ollama (local LLM server), HuggingFace BGE embeddings, Unstructured for PDF parsing
README insights
• Tech stack: Streamlit (UI), LangChain (orchestration), Unstructured (PDF → text), BGE (embeddings), Qdrant (vector DB), LLaMA via Ollama (chat LLM).
• Workflow description: Upload → Preprocess → Embed → Store/Retrieve → Respond.
a. Main components
1. Streamlit Frontend (new.py)
2. Document Processor (Unstructured module invoked in vectors.py)
3. Embedding Generator (HuggingFace BGE via vectors.py)
4. Vector Database (Qdrant in Docker)
5. Orchestrator (LangChain chains in chatbot.py)
6. LLM Service (LLaMA 3.2 hosted by Ollama)
7. Prompt Templates (aliases/data.json)
b. Relationships & interactions
• User ↔ Streamlit UI: upload PDF, view chat window
• UI → Document Processor: raw PDF → text chunks
• Processor → Embedding Generator: text chunks → vector embeddings
• Embeddings ↔ Qdrant: store & retrieve top-k similar vectors
• Chat Orchestrator → LLM Service: provide context + user query → LLM response
• Orchestrator → UI: display chat responses
c. Architectural patterns
– Layered architecture (UI, service layer, storage, external services)
– Orchestration pattern via LangChain (chain of responsibility)
– RAG pattern (retrieval + generation)
d. Key technologies
– Streamlit (Python UI framework)
– Unstructured (PDF → text)
– BGE Embeddings (HuggingFace)
– Qdrant (vector DB in Docker)
– LangChain (workflow)
– Ollama (LLaMA 3.2 inference)
Essential details to capture
• Clearly separate the two RAG phases (ingestion vs chat)
• LangChain orchestration flow
• Where embeddings live and how they’re retrieved
• Local vs external (all components run locally, but Docker is isolation boundary)