A similarity metric measures how alike two items, user histories, or representations are according to selected features or behavior. In recommender systems, it turns relationships into scores used to retrieve related content, personalize candidates, or rank results. section 2.3 section 2.3.3
Similarity can be computed from several signals:
- Content similarity compares item features such as genres, descriptions, actors, or directors; genre-only vectors provide a simple but limited representation. section 2.3 section 2.3.3
- Behavioral similarity uses user interaction patterns to identify items related through collective behavior rather than shared metadata. section 2.3.3 section 1.6
- Embedding similarity compares vector representations, commonly with cosine similarity, and can capture semantic relationships unavailable to explicitly defined features. section 3.4.3 section 3.5
- Hybrid retrieval combines content and behavioral scores, then weights them with popularity or other ranking signals. section 2.3.3
A production pipeline usually retrieves candidates similar to recent user watches, merges duplicates, filters watched items, adds popularity scores, and ranks the survivors. Empty histories fall back to popular items, while multiple seeds can be averaged or aggregated before nearest-neighbor search. section 2.2.6 section 3.4.3
Toy Story recommendations
A hybrid recommender ranks Toy Story 2 first with strong content, behavioral, and popularity scores. Forrest Gump and Star Wars receive zero content similarity but rank because behavioral similarity and popularity compensate. Embedding search instead returns Toy Story sequels and other animated children's movies. section 2.3.3 section 3.4.3
Listing 3.14 looking at embeddings .
from sklearn.metrics.pairwise import cosine_similarity def find_similar_movies(movie_idx, embeddings, k=10): query_emb = embeddings[movie_idx:movie_idx+1] #A similarities = cosine_similarity(query_emb, embeddings)[0] #B similarities[movie_idx] = -1 #C top_indices = np.argsort(similarities)[-(k):][::-1] #D return top_indices, similarities[top_indices]
Inspect a compact implementation that computes cosine similarity, excludes the query item, and returns the highest-scoring neighbors. section 3.4.3













