CoolFace
Apppublic

Ascendrix/NLP

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes
README.md120 linesDownload Raw Back to root
1---2title: MovieMate3emoji: ๐ŸŽฌ4colorFrom: indigo5colorTo: purple6sdk: gradio7sdk_version: "4.31.0"8app_file: app.py9pinned: false10license: mit11---12 13# ๐ŸŽฌ MovieMate โ€” Conversational AI Movie Assistant14 15> Exploring Conversational AI for Intelligent Movie Search and Recommendations  16> NLP Assignment โ€” Hugging Face Spaces Deployment17 18---19 20## What it does21 22MovieMate lets you discover movies through natural conversation instead of rigid keyword search.  23Ask in plain English โ€” it retrieves semantically similar films and explains its recommendations.24 25**Example queries**26- *"Recommend a sci-fi movie like Inception"*27- *"Movies starring Leonardo DiCaprio after 2010"*28- *"Best feel-good films for a Friday night"*29- *"Who directed Interstellar?"*30 31---32 33## Architecture34 35| Layer | Technology |36|---|---|37| Dataset | TMDB API โ€” ~1 000 movies with genres, cast, director |38| Embeddings | `all-MiniLM-L6-v2` (SentenceTransformers) |39| Vector search | FAISS `IndexFlatL2` |40| Response generation | Gemini 1.5 Flash |41| UI | Gradio 4 `Blocks` |42 43**Pipeline per query:**441. Encode user query โ†’ 384-dim embedding  452. FAISS nearest-neighbour search (k=3)  463. Format retrieved movies + conversation history as context  474. Gemini generates a conversational, explained recommendation48 49---50 51## Setup (first-time / local)52 53### 1. Clone and install54```bash55git clone https://huggingface.co/spaces/<your-username>/moviemate56cd moviemate57pip install -r requirements.txt58```59 60### 2. Set environment variables61```bash62export GEMINI_API_KEY="your-gemini-key"   # from https://aistudio.google.com63export TMDB_API_KEY="your-tmdb-key"       # from https://www.themoviedb.org/settings/api64```65 66### 3. (Optional) Pre-fetch the dataset67If `movies_updated.csv` is absent the app fetches it automatically on first launch (takes ~5 min).  68To pre-generate and commit it:69```bash70python scripts/fetch_dataset.py71```72 73### 4. Run locally74```bash75python app.py76```77 78---79 80## Hugging Face Spaces deployment81 82### Secrets (required)83In your Space โ†’ **Settings โ†’ Repository secrets**, add:84 85| Secret name | Value |86|---|---|87| `GEMINI_API_KEY` | Your Google Gemini API key |88| `TMDB_API_KEY` | Your TMDB API key (only needed if CSV is absent) |89 90### Committing the dataset (recommended)91Committing `movies_updated.csv` to the repo avoids the TMDB fetch on every cold start:92```bash93git lfs install           # HF uses LFS for large files automatically94git add movies_updated.csv95git commit -m "add pre-fetched dataset"96git push97```98 99---100 101## File structure102 103```104moviemate-hf/105โ”œโ”€โ”€ app.py                  # Main application (Gradio + RAG pipeline)106โ”œโ”€โ”€ requirements.txt        # Python dependencies107โ”œโ”€โ”€ README.md               # This file (also the HF Space card)108โ”œโ”€โ”€ scripts/109โ”‚   โ””โ”€โ”€ fetch_dataset.py    # Standalone script to pre-build movies_updated.csv110โ””โ”€โ”€ movies_updated.csv      # Pre-fetched dataset (commit this to avoid cold-start delay)111```112 113---114 115## Notes116 117- **Cold start**: If `movies_updated.csv` is absent, the app fetches ~1 000 movies from TMDB (โ‰ˆ5 min). Commit the CSV to avoid this.  118- **Gemini quota**: The free tier allows ~60 requests/min. The app retries up to 3 times with back-off.  119- **FAISS on CPU**: `faiss-cpu` is used for HF compatibility. Search over 1 000 movies is near-instant.120