How kumar2302github/rag-powered-chatbot-for-youtube-transcript-understanding_ works
Project Type and Purpose
• This is a full-stack, modular RAG (Retrieval-Augmented Generation) system in a single Python application, exposed via a Streamlit web UI.
• It fetches YouTube transcripts, chunks and embeds them, stores vectors locally, performs hybrid retrieval, and generates conversational answers using an LLM (e.g., Google Gemini).
High-Level File Structure Analysis
• Top-level:
• app.py (Streamlit entry point)
• rag.py (core RAG pipeline: chunking, embedding, retrieval, generation)
• transcription.py (YouTube transcript fetcher)
• requirements.txt, .streamlit/secrets.toml (config & secrets)
• Test_rag.ipynb (experimental notebook)
• No separate “frontend” vs. “backend” folders, but modules logically separate:
• UI layer in app.py
• Service layer in rag.py and transcription.py
• Storage layer using ChromaDB
Key Components
a. User (Web Browser)
b. Streamlit Frontend
• Hosts the chat interface, sidebar controls for Top-K, threshold, chunk size/overlap, MMR λ, reset/delete
c. Transcript Service
• transcription.py calls YouTube Transcript API
d. Chunking & Embedding Service
• Sentence-Transformers model
e. Vector Store (ChromaDB)
• Local persistent vector database, one collection per video
f. Retrieval Engine
• Score threshold + HDBSCAN clustering + MMR re-ranking
g. LLM API
• External (Gemini) or pluggable endpoint
h. Notebook (Test_rag.ipynb)—optional, for development/testing
Data Flow & Interactions
1. User submits a video URL or query via Streamlit UI
2. Frontend invokes Transcript Service → retrieves raw transcript
3. Transcript passed to Chunking & Embedding → generates embeddings
4. Embeddings upserted into ChromaDB
5. On user query:
a. Query embedded via same embedding model
b. Query embedding sent to Vector Store → retrieves candidate chunks
c. Apply threshold filtering → HDBSCAN → MMR → final chunk set
6. Selected chunks + original query → sent to LLM API
7. LLM returns answer → Frontend displays response back to user
Architectural Patterns & Design Principles
• Modular separation: UI, data ingestion, embedding, retrieval, generation
• Pipeline pattern: sequential processing stages (extract → embed → store → retrieve → generate)
• Hybrid retrieval: combining relevance (distance) and diversity (MMR + clustering)
• Pluggable components: embedding model, vector DB, LLM endpoint
Final Checklist
• [ ] Components: User, Streamlit UI, Transcription, Embedding, Vector DB, Retrieval, LLM, Notebook
• [ ] Annotations on pipeline stages (chunk size, overlap, MMR λ, thresholds)