MongoDBArek BoruckiTutorial
Building a Movie Recommendation Engine with Hugging Face and Voyage AI
Summary
Traditional movie search mechanisms depend on coarse filters such as genre, actor, or title, which fail to capture emotional context and narrative nuances. This guide demonstrates building a mood-based semantic recommendation system by combining the voyage-4-nano open-weights embedding model, Hugging Face datasets, and MongoDB Atlas Vector Search. The architecture uses Sentence Transformers to generate embeddings and exposes an endpoint through FastAPI to match user moods against movie plots. Truncating the Matryoshka embeddings from 2048 to 1024 dimensions balances semantic retrieval quality, storage footprint, and query latency. Testing shows that while abstract emotional queries return moderate similarity scores around 0.62 to 0.67, concrete descriptive queries exceed 0.75 without requiring exact keyword matches.
Context
Traditional movie search relies on coarse metadata filtering like genres, actors, or titles, which cannot capture nuanced emotional states or abstract intents such as searching for an uplifting or cathartic film.
Approach / What changed
The implementation deploys the open-weight voyage-4-nano embedding model using Sentence Transformers, indexes over 1500 movie plot summaries from Hugging Face into MongoDB Atlas Vector Search, and serves semantic search via a FastAPI application using 1024-dimension Matryoshka embeddings.
Takeaways
The voyage-4-nano model uses asymmetric encoding prompts to improve retrieval quality by distinguishing between query representations and document representations.
Matryoshka embeddings allow truncating vector dimensions from 2048 to 1024 or 512, balancing storage overhead and search latency while preserving ranking stability.
Concrete descriptive mood queries achieve higher semantic similarity scores (0.75+) compared to abstract emotional concepts (0.62 to 0.67).
Source and freshness
- Source
- mongodb.com
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.