An embedding is a dense vector that places similar items near one another. A movie’s text might produce a sparse TF-IDF representation with more than 50,000 dimensions; an embedding can compress it into a dense vector of 128–1,536 dimensions while preserving useful similarity. Unlike TF-IDF, an embedding can place differently worded descriptions close together. section 3.1.1 section 3.0
What “similar” means depends on how the vector was made. Collaborative filtering learns user and item embeddings from interactions, so shared audiences can link items with different descriptions; it cannot learn behavioral vectors for new users or items. Content models encode text or metadata, making them useful for new items. LLM embeddings can also capture entity relationships, cultural references, implicit themes, and franchise connections, but they are not inherently personalized. section 3.1.3 section 3.5.1
A basic content-based retrieval workflow is:
- Combine each movie’s title, genres, and available description, then encode the resulting text with a Sentence Transformer. The demonstrated model produces 384-dimensional vectors. section 3.4.2
- Compare a seed vector with catalog vectors using cosine similarity, exclude the seed, and rank the highest scores. For unit-length vectors, the dot product gives the same ranking as cosine similarity. section 3.1.2 section 3.4.3
- For several seeds, average their vectors to blend their signals, or use maximum-score aggregation to preserve each seed’s signal. Test which works better for the domain. section 3.4.3
Listing 3.12 Create Embeddings for the movies
from sentence_transformers import SentenceTransformer
import numpy as np
model = SentenceTransformer('all-MiniLM-L6-v2') #A
embeddings = model.encode(
movies['content'].tolist(),
show_progress_bar=True,
batch_size=32
) #BThe encoding listing shows where prepared catalog text becomes one vector per movie, using a named model and batched calls. section 3.4.2
A “more like this” result
Using a content embedding for Toy Story as the query returns Toy Story 3 (0.753), Toy Story 2 (0.715), and Toy Story 4 (0.652) among the closest movies. These matches come from titles, genres, and descriptions—not viewing behavior. A production filtering stage could remove redundant sequels or near-duplicates. section 3.4.3
Choose a more capable embedding model only when its extra signal matters. LLM embeddings can help when metadata is vague or when cultural context and franchise relationships are implicit. They can also be steered with instructions. The demonstrated comparison reports under a second for BERT-based embedding and retrieval versus up to 30 seconds with an Instructor model, with 768 rather than 384 dimensions per item. Batch generation may tolerate that cost; real-time query encoding may not. section 3.5.4 section 3.7
For a hybrid recommender, retrieve candidates from content and behavioral embeddings separately, merge their scores, and favor content when an item has few ratings. Shift weight toward collaborative filtering as interaction data grows. Measure whether another source improves recommendations before adding its operational cost; large-scale vector indexing and approximate nearest-neighbor search are separate scaling steps. section 3.6







































































