How ashishkumar0724/simple_rag_chat works
Project Type and Purpose
• This is a lightweight Retrieval‑Augmented Generation (RAG) application: a single‑page Streamlit web app that lets a user chat with local PDF documents.
• It leverages Deepseek for embeddings, LangChain as the orchestration layer, and Ollama (running a local LLM: deepseek‑r1:1.5b) for answer generation.
File Structure Highlights
• main.py: contains the entire app logic (UI + pipeline).
• requirements.txt: lists Python dependencies (streamlit, langchain, deepseek, ollama).
• README.md: usage instructions.
• zhang2021.pdf: example document.
Key Components
a. Frontend (Streamlit UI)
b. PDF Loader & Text Splitter
c. Embedding Service (Deepseek via Ollama)
d. Vector Store (in‑memory or disk)
e. RAG Chain (LangChain orchestrator)
f. LLM Inference (Ollama running deepseek‑r1:1.5b)
g. User’s Local PDF Files
Relationships & Data Flow
1) User enters a query in the Streamlit UI
2) The app loads the selected PDF(s) → splits into chunks
3) Each chunk is sent to Deepseek to produce embeddings
4) Embeddings are saved in a local vector store
5) On query, retrieve top‑k relevant chunks from the vector store
6) LangChain RAG chain constructs a prompt with retrieved chunks
7) Prompt is sent to Ollama (deepseek‑r1:1.5b) → returns an answer
8) Streamlit displays the response back to the user
Architectural Patterns & Principles
• Pipeline pattern: stages (load → embed → store → retrieve → generate)
• Separation of concerns: UI vs data processing vs model inference
• Local-first design: PDFs and model run on the user’s machine
• Orchestration via LangChain simplifies the glue code
Technologies & Frameworks
• Streamlit: Rapid UI development
• LangChain: Chain-of-thought orchestration
• Deepseek: Embedding model, served via Ollama
• Ollama: Local LLM hosting
• Python: single‑script implementation
Essential Elements
• Component names
• Notes on local dependencies (PDF folder, Ollama model)