Content-Based Filtering for Recommendation Service (aka User-based Model) | ||
| ||
| Content-Based Filtering (CBF) recommends items whose attributes resemble items a user has already engaged with. Instead of learning from the behavior of other users, it builds a profile of the target user purely from the features of the items in that user’s history. The core hypothesis: if you liked items with certain attributes, you will like other items that share those attributes. A user who watched several documentaries by a particular director is shown that director’s other films. This makes CBF a per-user model: each user has an independent profile, and recommendations never depend on the existence of a user community.
How It Works (The Math)CBF has three stages: item representation, profile construction, and scoring. 1. Item representationEach item
2. User profile constructionThe user profile pᵤ is an aggregate of the vectors of items the user interacted with, often weighted by rating or engagement:
where 3. ScoringCandidate items are ranked by similarity to the profile, typically cosine similarity:
Alternatively, a supervised classifier/regressor (logistic regression, gradient-boosted trees) is trained per user or globally with the user profile as features, predicting the probability of a positive interaction.
RequirementsTo deploy CBF you need:
Simplified Architecture
Reference Architecture
Reference Architecture (with Technology Stack)The same flow mapped onto common production technologies — Kafka for event streaming, Spark for batch feature jobs, Redis for the online profile store, and FAISS/Milvus for vector retrieval.
PRO
Signals & FeaturesThe most common feature families are item text (titles, descriptions, transcripts), structured metadata (genre, category, brand, price band, language), media embeddings (image/audio/video), and provenance signals (creator, publication date). On the user side, the only required signal is the item-interaction history, optionally enriched with explicit ratings and per-interaction weights such as dwell time or watch fraction.
Training & Serving ConsiderationsCBF often has no global training step when using pure similarity — profiles are computed on the fly. When a supervised model is layered on top (e.g., logistic regression predicting click probability from profile-item interaction features), training is standard offline batch learning with periodic refresh. Serving cost is dominated by ANN retrieval and feature freshness. New items become recommendable as soon as their vectors are indexed, which is why CBF handles item cold-start gracefully — a key contrast with collaborative filtering.
EvaluationOffline, CBF (Content-Based Filtering) is evaluated with ranking metrics: precision@k, recall@k, MAP (Mean Average Precision), and NDCG (Normalized Discounted Cumulative Gain) on held-out interactions. Because over-specialization is the dominant failure mode, teams also track catalog coverage, intra-list diversity, and novelty to detect filter-bubble behavior. Online, the decisive signals are A/B-tested click-through rate, engagement depth, and long-term retention.
Strengths & WeaknessesStrengths: works for new users with even a little history; no dependence on a user community (no user cold-start); naturally handles new items; transparent and explainable (“recommended because it shares X with something you liked”). Weaknesses: prone to over-specialization / filter bubbles — it rarely surfaces genuinely novel interests; quality is bounded by feature richness and requires significant feature-engineering investment; it cannot capture “users like you also enjoyed…” signals that drive serendipity.
When to Use ItReach for content-based filtering when item metadata is rich and well-structured, when the catalog turns over quickly (news, job postings, listings) so item cold-start matters, when you cannot rely on cross-user data for privacy reasons, or as the content arm of a hybrid system that compensates for collaborative filtering’s cold-start gap. | ||
| | ||
| |