A comprehensive command-line project exploring multimodal search and Retrieval-Augmented Generation (RAG) for movies.
It demonstrates the progression from classic keyword search to semantic search, hybrid ranking, LLM-powered answering, and image-based retrieval using modern embedding models.
- Keyword Search: Classic BM25-style search over movie metadata
- Semantic Search: Vector-based retrieval using text embeddings
- Hybrid Search: Reciprocal Rank Fusion (RRF) combining keyword and semantic signals
- Query Enhancement: Spell correction, query rewriting, and expansion
- LLM Reranking: Cross-encoder and LLM-based reranking
- Retrieval-Augmented Generation (RAG): Contextual answer generation from retrieved documents
- Multi-Document Summarization: Synthesis across multiple movies
- Citation-Aware Answers: Inline citations referencing source documents
- Conversational Q&A: Natural, chat-style interaction
- Multimodal Query Rewriting: Query enhancement using image understanding
- Image-Based Search: Movie retrieval via poster images using CLIP embeddings
- Search Evaluation: Precision@k, Recall@k, and F1 scoring with golden datasets
rag-search-engine/
βββ cli/
β βββ augmented_generation_cli.py # RAG, summarization, citations, Q&A
β βββ describe_image_cli.py # Multimodal query rewriting (image + text)
β βββ evaluation_cli.py # Precision/Recall/F1 evaluation
β βββ hybrid_search_cli.py # Hybrid RRF search with reranking
β βββ keyword_search_cli.py # BM25 keyword search
β βββ multimodal_search_cli.py # CLIP-based image search
β βββ semantic_search_cli.py # Vector/embedding search
β βββ lib/
β βββ config.py # Centralized configuration
β βββ hybrid_search.py # BM25 + embeddings + RRF logic
β βββ keyword_search.py # Keyword search implementation
β βββ multimodal_search.py # CLIP multimodal search logic
β βββ query_enhancement.py # Query enhancement and reranking
β βββ reranker.py # Cross-encoder reranking
β βββ search_utils.py # Dataset loading and utilities
β βββ semantic_search.py # Semantic search implementation
βββ data/
β βββ movies.json # Movie dataset
β βββ golden_dataset.json # Evaluation queries
β βββ paddington.jpeg # Example image for multimodal search
βββ pyproject.toml # Project dependencies
βββ README.md
- Python 3.12+
uv(recommended) orpip
git clone https://github.com/Utkarsh736/rag-search-engine.git
cd rag-search-engine
# Install with uv (recommended)
uv sync
# Or with pip
pip install -e .Create a .env file in the project root:
GEMINI_API_KEY=your_gemini_api_key_hereGet your API key from Google AI Studio.
Run all commands from the project root using uv run.
uv run cli/keyword_search_cli.py search "bear in london"Classic BM25-style keyword matching over movie titles and descriptions.
uv run cli/semantic_search_cli.py search "talking teddy bear comedy"Finds semantically similar movies using embeddings, even without exact keyword overlap.
# Basic hybrid search
uv run cli/hybrid_search_cli.py rrf-search "bear in london" --limit 5
# With cross-encoder reranking
uv run cli/hybrid_search_cli.py rrf-search "dinosaur" --rerank-method cross_encoder
# With query enhancement
uv run cli/hybrid_search_cli.py rrf-search "scary ber atack" --enhance spellCombines keyword and semantic rankings using Reciprocal Rank Fusion.
uv run cli/evaluation_cli.py --limit 4Evaluates performance using Precision@k, Recall@k, and F1 on test queries.
uv run cli/augmented_generation_cli.py rag "what dinosaur movies are available?"Generates contextual answers grounded in retrieved documents.
uv run cli/augmented_generation_cli.py summarize "action adventure movies" --limit 10Produces a synthesized overview across multiple movies.
uv run cli/augmented_generation_cli.py citations "sci-fi movies with robots"Generates answers with inline citations like [1], [2].
# Factual question
uv run cli/augmented_generation_cli.py question "when was Jurassic Park released?"
# Analytical question
uv run cli/augmented_generation_cli.py question "which bear movies are most intense?"Chat-style answers suitable for conversational interfaces.
uv run cli/describe_image_cli.py --image data/paddington.jpeg --query "funny bear movie"Enhances queries using image understanding from multimodal LLMs.
Example output:
Rewritten query: family-friendly British comedy film featuring anthropomorphic bear in blue coat and red hat
Total tokens: 1247
# Verify image embeddings
uv run cli/multimodal_search_cli.py verify_image_embedding data/paddington.jpeg
# Search movies by image
uv run cli/multimodal_search_cli.py image_search data/paddington.jpegFind movies by poster images using CLIP embeddings and cosine similarity.
Example output:
1. Paddington (similarity: 0.722)
Deep in the rainforests of Peru, a young bear lives peacefully...
2. Ted (similarity: 0.685)
In 1985, eight-year-old John Bennett makes a Christmas wish...
Located in cli/lib/multimodal_search.py:
- Encodes movie text as
title: description - Generates text and image embeddings using CLIP
- Ranks results via cosine similarity
Located in cli/lib/hybrid_search.py:
- BM25 keyword ranking
- Semantic vector search
- Reciprocal Rank Fusion (RRF)
- Optional LLM-based reranking
Located in cli/augmented_generation_cli.py:
- Hybrid document retrieval
- Context-aware generation
- Supports summaries, citations, and Q&A
| Component | Model | Purpose |
|---|---|---|
| Text Embeddings | all-MiniLM-L6-v2 |
Semantic search |
| Image Embeddings | clip-ViT-B-32 |
Multimodal search |
| Cross-Encoder | cross-encoder/ms-marco-MiniLM-L-6-v2 |
Result reranking |
| LLM | gemini-2.5-flash-lite |
RAG, Q&A, summarization |
All models are configurable via cli/lib/config.py.
A golden dataset (data/golden_dataset.json) is provided for benchmarking.
uv run cli/evaluation_cli.py --limit 4Metrics:
- Precision@k
- Recall@k
- F1 Score
# Linting
uv run ruff check .
# Formatting
uv run ruff format .- Small, static dataset
- Runtime embedding computation (no caching)
- LLM API latency and rate limits
- Limited joint text + image scoring strategies
- π Web UI (FastAPI + React)
- ποΈ Vector databases (pgvector, Pinecone, Weaviate)
- βοΈ Tunable text vs image similarity weighting
- π Advanced metrics (NDCG, MRR)
- π¬ Live movie database integration
MIT License. See the LICENSE file for details.
- Built as part of the Boot.dev RAG Search Engine course
- CLIP model by OpenAI
- Sentence Transformers library
- Gemini API by Google