Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎬 YouTube RAG with Gemini + FAISS

An interactive Streamlit app to ask grounded questions about any YouTube video.
Paste a YouTube URL or ID, build a transcript index with Gemini embeddings + FAISS, and query it with Gemini 2.5 Flash.


📖 Description

This app implements a classic Retrieval‑Augmented Generation (RAG) pipeline for YouTube:

  1. Fetch transcript via youtube-transcript-api (if available).
  2. Split into overlapping chunks (LangChain RecursiveCharacterTextSplitter).
  3. Embed with Gemini (models/embedding-001) and index in FAISS.
  4. Retrieve top‑k chunks (MMR) and answer using Gemini 2.5 Flash, constrained to transcript context.

✨ Features

  • 🔗 Paste YouTube URL or raw ID; robust ID parser for common formats.
  • 🌐 Transcript language selector (en/hi/bn/te/ta/mr).
  • ⚙️ Tunables: chunk size, overlap, Top‑K, LLM temperature.
  • 🧩 Show supporting chunks for transparency.
  • 🧱 Fail‑safes for disabled or missing transcripts.

🛠️ Implementation Details

  • Embeddings: GoogleGenerativeAIEmbeddings (models/embedding-001)
  • Vector store: FAISS from langchain_community
  • Retriever: MMR with configurable k
  • LLM: ChatGoogleGenerativeAI(model="gemini-2.5-flash")
  • Prompting: strict, context‑only answers; says “don’t know” if context is insufficient
  • Frontend: Streamlit with wide layout and sidebar controls

Main app file: YT_app.py


🚀 Quickstart

1) Install

pip install -r requirements.txt

requirements.txt (minimal):

streamlit
youtube-transcript-api
langchain
langchain-core
langchain-google-genai
langchain-community
faiss-cpu
python-dotenv

2) API key

Create a .env file:

GOOGLE_API_KEY=your_api_key_here

3) Run

streamlit run YT_app.py

Open http://localhost:8501


▶️ How to Use

  1. Paste a video URL/ID → Build index / Refresh
  2. Type your question → Ask
  3. Expand Show supporting chunks to see evidence

📸 Demos

Overview

Overview

URL / ID input + Build index

URL input

Ask a question

Question box

Sidebar settings

Settings


🌥 Deploy to Streamlit Cloud (summary)

  1. Push repo with YT_app.py, requirements.txt, README.md (and optional runtime.txt: 3.11).
  2. In Streamlit Cloud → New app → pick repo → main file YT_app.py.
  3. Add Secrets:
    GOOGLE_API_KEY="your_gemini_api_key"
  4. Deploy.

Note: FAISS index is ephemeral on Cloud; rebuilding on refresh is expected.


🔮 Roadmap

  • Cache & persist FAISS indexes
  • Multi‑video collections
  • Export answers + sources (JSON/Markdown)
  • Fallback speech‑to‑text when captions are unavailable

📜 License

Souvik Sarkar

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages