18 interview questions on recommender & association, each answered in full. Free to read, no account needed.
Collaborative filtering — how does it use unsupervised methods?
medium- Learn user + item embeddings from interaction matrix (implicit or explicit ratings).
- No content features required — 'unsupervised' in the sense that only interactions are used.
- Methods: (1) SVD / matrix factorization (Netflix Prize), (2) ALS (Spark), (3) Neural CF, (4) Two-tower / dual-encoder models, (5) Graph-based (LightGCN).
- Cold-start problem (new user / item) needs content features → hybrid.
Implicit feedback vs explicit ratings in recsys.
hard- Explicit: users give a star rating.
- Rare in practice.
- Implicit: clicks, views, time-on-page, purchases → 'positive' signal only, no negatives.
- Weight positive (confidence) by frequency; treat unobserved as low-confidence negatives (Hu-Koren-Volinsky weighted ALS).
- BPR: pairwise ranking loss on 'clicked > not-clicked'.
- Standard in industry: Spark ALS (implicit), Amazon DSSTNE, YouTube's dual-tower.
How do you handle the cold-start problem?
medium- New user or item with no interactions.
- Solutions: (1) Content-based features (user profile, item text/image → embed) → hybrid recsys.
- (2) Popularity-based fallback.
- (3) Bandits: explore new items early (Thompson sampling on Beta posteriors).
- (4) Meta-learning to warm-start embeddings.
- (5) Ask onboarding questions.
- Every real production recsys hybridizes CF + content to handle cold-start.
Two-tower recsys — architecture and use.
hard- User tower: NN encoding user features / history → user embedding.
- Item tower: NN encoding item features → item embedding.
- Score = cosine or dot product.
- Trained with softmax over batch (in-batch negatives).
- Deployment: precompute item embeddings, index with ANN; user embedding computed at query time → real-time retrieval.
- Standard in YouTube, TikTok, Instagram, LinkedIn retrieval-stage recsys.
Association rule mining — Apriori & FP-Growth.
medium- Find frequent itemsets in transactions (e.g. 'diapers → beer').
- Apriori: level-wise search, prune non-frequent supersets — slow, many DB scans.
- FP-Growth: build FP-tree in one scan, mine recursively — much faster.
- Metrics: support (frequency), confidence (P(consequent∣antecedent)), lift (association strength vs random).
- Classic market-basket analysis; modern replaced by embedding-based recsys but still asked in interviews.
How does image similarity search work in production?
medium- (1) Extract embeddings: CLIP / DINOv2 / SigLIP → 512-1024 dim vectors.
- (2) L2-normalize + index in FAISS / Qdrant / pgvector (HNSW / IVF-PQ).
- (3) Query: embed uploaded image, ANN search, rerank with cross-encoder if precision needed.
- (4) Filter by metadata (category, brand).
- Production examples: Pinterest visual search, Google Images similar, Bing 'search by image'.
Market basket analysis — modern approach.
hard- Classical: association rules (Apriori/FP-Growth).
- Modern: (1) product embeddings via word2vec-on-baskets ('prod2vec'), (2) session-based recsys (GRU4Rec, SASRec) on sequential purchases, (3) graph embeddings on co-purchase network, (4) contextual bandits for personalization.
- Association rules still useful for interpretable insights + regulatory reporting; embeddings win on prediction / recall metrics.
Unsupervised image segmentation — approaches.
hard- (1) Classical: k-means or mean-shift on pixel color + position (SLIC superpixels).
- (2) Spectral clustering on affinity graph.
- (3) Modern DL: DINO's self-attention maps segment objects without any supervision.
- (4) SAM (Segment Anything Model, Meta 2023): promptable segmentation trained on 1B masks — used with 'automatic mask' mode for full-image unsupervised segmentation.
- (5) STEGO (Hamilton et al. 2022): contrastive semantic segmentation.
Zero-shot image classification via CLIP — mechanism.
medium- (1) Encode candidate class names as text ('a photo of a dog', 'a photo of a cat') → text embeddings.
- (2) Encode query image → image embedding.
- (3) Cosine similarity → class with max similarity is prediction.
- No training on class labels.
- Weakness: sensitive to prompt engineering; competitive with fine-tuned models on many benchmarks.
- Foundation of open-vocabulary classification and detection (OWL-ViT, GLIP).
How does unsupervised learning help with noisy labels?
hard- (1) Cluster the data unsupervisedly; check consistency of labels within clusters — outliers likely mislabeled.
- (2) Confidence learning (Northcutt et al., cleanlab): use self-consistency + probabilistic label pruning.
- (3) Small-loss trick during training (Co-teaching): assume noisy samples have larger loss; ignore top-loss fraction.
- (4) Semi-supervised: leverage unlabeled or auto-labeled data.
- Foundation of modern label cleaning at scale.
Interview: design a recommender for a new streaming service.
hard- (1) Cold-start heavy: no history.
- Start with content-based recsys (title/description embeddings, genre, actors → cosine similarity to what user selects).
- (2) Log implicit signals from day 1 (plays, completes).
- (3) After N interactions, hybrid: two-tower CF + content features.
- (4) Diversity: MMR reranking + calibration.
- (5) Bandits for exploration of new content.
- (6) Evaluate: retention, watch time (long-term), CTR/CVR (short-term), diversity, novelty.
- (7) A/B test each change.
Interview: your model's accuracy dropped 15% overnight — how do you diagnose?
hard- (1) Rule out incidents first: pipeline break, feature-source outage, label logging bug.
- (2) Check input distributions: KS + PSI per feature vs baseline.
- (3) Check label distribution + prediction distribution shift.
- (4) Segment: is drop uniform or in specific segment?
- (5) Retrain on last 7 days as sanity check.
- (6) Post-mortem: if drift, decide short-term (rollback / hotfix threshold) vs long-term (retrain cadence + monitoring).
- (7) Add automated alert for the specific drift metric caught.
Interview: you must ship an embedding service serving 100M vectors, 10ms p95 latency.
hard- (1) Choose embedding model by quality + latency (E5-small / bge-small / OpenAI text-embedding-3-small).
- (2) Batch-embed the corpus offline.
- (3) Index in HNSW (Qdrant, pgvector, Weaviate) — M=32, efconstruction=200.
- (4) Serve queries: encode + ANN.
- (5) Cache popular queries.
- (6) Sharding by partition key + horizontal scale.
- (7) Cold-index rebuild + hot-swap for updates.
- (8) Monitor: recall@k, latency percentiles, index memory.
- (9) Consider IVF-PQ if memory-constrained.
- (10) Backup index.
Interview: how do you monitor drift in an embedding-based retrieval system?
hard- (1) Query distribution drift: KS/PSI on query embedding norms, cluster distribution of queries over time.
- (2) Corpus drift: same on doc embeddings.
- (3) Retrieval quality: NDCG@k on golden query set + regression on click-through rates.
- (4) Semantic drift: cluster queries weekly, compare centroids vs baseline (ARI between weekly clusterings).
- (5) Model drift: recompute embeddings with new version, measure alignment (Procrustes / linear-CKA) to old version.
- Alert on all four.
Interview: 'when should you use graph-based methods over tabular?'
medium- (1) Data has natural relational structure (users↔items, molecules, transactions, social nets).
- (2) Prediction depends on neighborhood (link prediction, fraud rings, drug interactions).
- (3) Rich metadata on nodes + edges.
- (4) You want to explain via relational features (visible connections).
- Don't use graphs when: (1) data is purely tabular independent samples, (2) no clear notion of relation, (3) added complexity outweighs marginal gains.
Interview: 'you have to embed 100M documents monthly — cost strategy?'
hard- (1) Only re-embed changed / new documents (change-data-capture).
- (2) Choose model by cost/quality tradeoff: OpenAI-3-small ($0.02/1M tokens) vs OSS bge-small hosted on your infra (initial GPU spend, then free).
- (3) Batch requests → economies of scale in API cost.
- (4) Truncate long docs after N tokens or chunk + aggregate.
- (5) Cache embeddings by content hash.
- (6) Consider Matryoshka embeddings (OpenAI-3 supports variable dim) → smaller dim for retrieval, full dim for reranking.
Interview: 'summarize when unsupervised learning wins in production.'
medium- Unsupervised wins when: (1) labels are expensive / impossible (fraud rings, anomalies, cold-start recsys).
- (2) Data has natural structure worth exposing (customer segments, log templates, image duplicates).
- (3) You need representations for downstream tasks (embeddings for RAG, features for classifiers).
- (4) You need to detect novelty / drift (production monitoring).
- (5) You want to enable exploratory analysis at scale (topic discovery, log clustering).
- Rule: it's rarely the final answer — usually feeds a supervised or business-decision layer.
How do you make recommendations for a brand-new user?
medium- Fall back through a ladder of decreasing personalization.
- With no history, serve popularity, ideally popularity within whatever context you do know, such as country, device, or referral source, which is far better than global top items.
- Use any content signal available: the first item viewed, a stated interest at signup, or the search query, and recommend by content similarity rather than collaborative signal.
- Deliberately explore in the first sessions, since early diverse impressions are how you acquire the data personalization needs, and a purely greedy policy starves itself.
- Then switch to the collaborative model once the user crosses an interaction threshold.
- A hybrid model that consumes content features handles this natively instead of needing a separate rule.