CoolFace
Apppublic

RimaAlaya/CineRAG

sourceHugging Faceupdated 9mo agoView on Hugging Face
1likes
App README

๐ŸŽฌCineRAG - Cinema Secrets Encyclopedia

Beyond IMDB: A RAG system for true cinema lovers with behind-the-scenes secrets, production trivia, and insider stories.

![Python 3.12+](https://www.python.org/downloads/) ![LangChain](https://langchain.com) ![Groq](https://groq.com)

๐Ÿš€ Live Demo | ๐Ÿ“น Video Demo | ๐Ÿ“Š Technical Details


๐ŸŽฏ The Problem

Movie databases give you the basics - who directed it, who starred in it, what it's about.

But cinema fans want more:

  • โ€”How did Heath Ledger prepare for the Joker?
  • โ€”What went wrong during Titanic's filming?
  • โ€”Why was the Inception hallway scene so hard to film?
  • โ€”Did the cast of your favorite movie take anything from the set?

This information is scattered across Reddit threads, Wikipedia trivia sections, YouTube videos, and fan forums.

CineRAG solves this by aggregating behind-the-scenes secrets, production stories, and insider trivia into one searchable system.


โœจ What Makes This Different

Traditional Movie Database:

Q: "Tell me about Inception" A: "Inception (2010) directed by Christopher Nolan. Stars Leonardo DiCaprio. A thief who steals corporate secrets..."

CineRAG:

Q: "What secrets are there about Inception?" A: "Nolan wrote Inception over 10 years. The rotating hallway fight? They actually built a rotating corridor - no CGI. Joseph Gordon-Levitt did his own stunts and got seriously dizzy filming those sequences."

This is what cinema fans get excited about.


๐Ÿ”ฅ Features

  • โ€”๐ŸŽฌ Cinema Secrets: 252 movies with behind-the-scenes content
  • โ€”๐Ÿ” Hybrid Search: BM25 + Semantic (85.7% Recall@3)
  • โ€”๐Ÿค– AI Answers: Groq's Mixtral for natural responses
  • โ€”โšก Fast: <1 second per query
  • โ€”๐Ÿ“š Comprehensive: 466 movies, 3,000+ chunks

๐Ÿš€ Quick Start

Installation

bash
# Clone
git clone https://github.com/RimaAlaya/CineRAG.git
cd CineRAG

# Install dependencies
pip install -r requirements.txt

# Setup API keys
cp .env.example .env
# Add your GROQ_API_KEY and TMDB_API_KEY

Run the App

bash
streamlit run app.py

Visit http://localhost:8501


๐Ÿ’ก Example Queries

Basic Movie Info

  • โ€”"Who directed Inception?"
  • โ€”"What is The Matrix about?"
  • โ€”"Leonardo DiCaprio movies"

Cinema Secrets ๐ŸŽฌ

  • โ€”"What secrets are there about Inception?"
  • โ€”"Behind the scenes of The Dark Knight"
  • โ€”"Tell me trivia about Titanic filming"
  • โ€”"Production stories from The Matrix"

๐Ÿ—๏ธ Architecture

User Query
    โ†“
Hybrid Search Engine
    โ”œโ”€ Semantic Search (FAISS + embeddings)
    โ””โ”€ BM25 Keyword Search
    โ†“
Score Fusion (0.5 + 0.5)
    โ†“
Top K Relevant Chunks
    โ†“
Groq LLM (Mixtral-8x7b)
    โ†“
Natural Answer + Sources

Data Pipeline

TMDB API โ†’ Movies Basic Info (466 movies)
    โ†“
Wikipedia Scraping โ†’ Behind-the-Scenes Secrets (252 movies)
    โ†“
Smart Chunking โ†’ 3,000+ Searchable Chunks
    โ”œโ”€ plot
    โ”œโ”€ cast
    โ”œโ”€ crew
    โ”œโ”€ metadata
    โ””โ”€ secrets (production, filming, casting, reception)
    โ†“
Dual Indexing
    โ”œโ”€ FAISS (semantic)
    โ””โ”€ BM25 (keyword)

๐Ÿ“Š Technical Details

Performance Metrics

MetricBaseline (Semantic Only)Hybrid (BM25 + Semantic)Improvement
Recall@381.5%85.7%+4.3% โœ…
Recall@588.8%93.8%+5.0% โœ…
Cross-Reference6.2%71.0%+64.8% ๐Ÿš€
Avg Latency21ms21ms-

Key Insight: Hybrid search dramatically improved cross-reference queries (e.g., "Leonardo DiCaprio movies") through exact keyword matching.

Tech Stack

  • โ€”Vector Search: FAISS + sentence-transformers (all-MiniLM-L6-v2)
  • โ€”Keyword Search: BM25 (rank-bm25)
  • โ€”LLM: Groq (Mixtral-8x7b-32768)
  • โ€”Orchestration: LangChain
  • โ€”Data Sources: TMDB API + Wikipedia
  • โ€”UI: Streamlit
  • โ€”Language: Python 3.12+

Dataset

  • โ€”Movies: 466 from TMDB
  • โ€”Movies with Secrets: 252
  • โ€”Total Chunks: ~3,000
  • โ€”Secret Chunks: 800+
  • โ€”Chunk Types: plot, cast, crew, metadata, secretsproduction, secretsfilming, secretscasting, secretsreception

๐Ÿ“ Project Structure

CineRAG/
โ”œโ”€โ”€ app.py                      # Streamlit web interface
โ”œโ”€โ”€ cinema_secrets_rag.py       # Main RAG system with Groq
โ”œโ”€โ”€ hybrid_rag.py              # Baseline hybrid search
โ”œโ”€โ”€ data_secrets_collector.py  # Wikipedia scraper
โ”œโ”€โ”€ chunking_secrets.py        # Chunk creation with secrets
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ movies_full.json       # TMDB movie data
โ”‚   โ”œโ”€โ”€ movie_secrets.json     # Wikipedia secrets
โ”‚   โ”œโ”€โ”€ movie_chunks_with_secrets.json
โ”‚   โ”œโ”€โ”€ embeddings_with_secrets.npy
โ”‚   โ””โ”€โ”€ evaluation_dataset.json
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ README.md

๐ŸŽ“ Why This Project Stands Out

1. Unique Value Proposition

Not another generic RAG system. Focuses on a specific niche (cinema secrets) that no one else addresses.

2. Technical Depth

  • โ€”Hybrid search implementation (not just vector search)
  • โ€”Systematic evaluation with 164 test questions
  • โ€”Production-ready with proper error handling
  • โ€”LangChain integration with Groq (cost-effective LLM)

3. Product Thinking

  • โ€”Identified a gap: "IMDB doesn't have secrets"
  • โ€”Built a solution: "Aggregate secrets into one place"
  • โ€”Validated with user stories: "Cinema fans want behind-the-scenes content"

4. Execution Quality

  • โ€”Clean, documented code
  • โ€”Deployed and working
  • โ€”Performance metrics tracked
  • โ€”Iterative improvement (baseline โ†’ hybrid โ†’ LLM)

๐Ÿ”ฎ Future Improvements

  • โ€”[ ] More Sources: Add Reddit (r/MovieDetails), YouTube transcripts
  • โ€”[ ] Actor/Director Profiles: Dedicated pages for people
  • โ€”[ ] Cross-Encoder Reranking: Improve top result accuracy
  • โ€”[ ] Conversation Memory: Multi-turn dialogue
  • โ€”[ ] User Feedback Loop: Learn from interactions
  • โ€”[ ] Multi-modal: Add movie posters, stills

๐Ÿค Contributing

Want to add more secrets? Improve the prompts? PRs welcome!

Areas for contribution:

  1. 1.Add more data sources (Reddit, YouTube, IMDb trivia)
  2. 2.Improve secret extraction quality
  3. 3.Add more evaluation metrics
  4. 4.Enhance UI/UX

๐Ÿ“„ License

MIT License - Free to use for personal or commercial projects.


๐Ÿ‘จโ€๐Ÿ’ป Built By

Rima Alaya AI/ML Engineer passionate about cinema and intelligent systems

GitHub | LinkedIn | Email


๐Ÿ“ง Contact

Questions? Ideas? Want to collaborate?

๐Ÿ“ง rimaalaya76@gmail.com ๐Ÿ’ผ LinkedIn ๐Ÿ™ GitHub


Made with โค๏ธ for cinema lovers and built with cutting-edge AI technology

If you love movies and technology, star this repo โญ