ML System Design
How would you build positives and negatives for training a similar-items model, and what loss would you use?
Ответить самому
Сначала сформулируйте ответ как на собеседовании, затем откройте разбор и оцените себя.
Короткий ответ
Mine candidate pairs from pretrained/content neighbors and interaction logs, label positives/negatives with human/VLM/behavioral signals, then train with contrastive, triplet or sampled softmax objectives using random and hard negatives.
Полный разбор
For positives, use multiple sources: co-watch/co-click/co-purchase patterns, editorial/manual similar-item labels, items in the same franchise/genre/entity clusters, and VLM or human labels for semantic similarity. For new items without interactions, content-neighbor mining can generate candidates for labeling.
Negatives should not be only random items from the full catalog. Random negatives are too easy in a million-item catalog. Mix random negatives with hard negatives: close ANN neighbors judged not similar, same-category but wrong intent, high-popularity distractors and exposed-but-skipped items.
Loss choices include contrastive loss, triplet loss, InfoNCE/in-batch negatives or sampled softmax. In-batch negatives make training efficient, while mined hard negatives make the task meaningful. Keep train/validation splits careful so that the model does not memorize near-duplicate labels or future feedback.
Теория
The model learns the quality of the negative set. Too-easy negatives produce misleading offline metrics.
Типичные ошибки
- Use only random negatives from a huge catalog.
- Treat all unobserved pairs as negative without exposure context.
- Forget that manual/VLM labels need quality checks.
Как отвечать на собеседовании
- Say random negatives for coverage and hard negatives for discrimination.
- Mention in-batch negatives as an efficient default.