An interactive Retrieval-Augmented Generation (RAG) web application built with Streamlit, LangChain, FAISS, and Hugging Face LLMs. This application enables users to paste any YouTube video URL, automatically extracts and translates its transcript into English, indexes the text into a vector store, and allows users to ask questions directly about the video's content.
- 🎥 YouTube Transcript Ingestion: Automatically fetches transcripts for YouTube videos (supports native English transcripts as well as auto-translating non-English transcripts like Hindi into English).
- ⚡ RAG Vector Store: Chunks transcripts using
RecursiveCharacterTextSplitterand indexes them into aFAISSvector database usingsentence-transformers/paraphrase-multilingual-MiniLM-L12-v2embeddings. - 🧠 Query Rewriting & Answering: Uses Llama-3.1-8B-Instruct via
HuggingFaceEndpointandChatHuggingFaceto rewrite search queries for high-precision retrieval and answer questions accurately. - 🌐 English Enforced Answers: Consistently returns answers in English regardless of the original video transcript's language.
- 🔄 Session & Video Management: Automatically resets chat history and vector stores when a new video URL is loaded to prevent context contamination between videos.
- Frontend UI: Streamlit
- Orchestration: LangChain
- Vector Database: FAISS
- Embeddings:
sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 - LLM:
meta-llama/Llama-3.1-8B-Instruct(Hugging Face Inference API) - Transcript Extraction:
youtube-transcript-api - Environment Management:
python-dotenv
- Python 3.9+ installed.
- A free Hugging Face Access Token (get yours at huggingface.co/settings/tokens).
-
Clone the repository:
git clone https://github.com/abhishekadbhute-create/YT_CHATBOT.git cd YT_CHATBOT -
Create and activate a virtual environment:
python -m venv venv # On Windows PowerShell: .\venv\Scripts\Activate.ps1 # On Mac/Linux: source venv/bin/activate
-
Install dependencies:
pip install streamlit langchain langchain-community langchain-huggingface langchain-text-splitters faiss-cpu youtube-transcript-api python-dotenv
-
Configure Environment Variables: Create a
.envfile in the root directory:HUGGINGFACEHUB_API_TOKEN=hf_your_actual_huggingface_token_here
Launch the Streamlit app:
streamlit run app.pyOpen your browser and navigate to: http://localhost:8501
- Load Video: Paste a YouTube URL (e.g.,
https://www.youtube.com/watch?v=...orhttps://youtu.be/...) into the input box and click Load Video. - Ask Questions: Type any question about the video in the query box and click Ask.
- Switching Videos: Paste a new video URL and click Load Video. The app will automatically clear the old chat history and load the new video's transcript.
Distributed under the MIT License. Feel free to use and modify!