Correcting Popularity Bias in Two-Tower Retrieval With In-Batch Negatives

Last updated: November 29, 2026

Quick Overview

A two-tower retrieval model trained with in-batch negatives keeps retrieving the same popular videos. Explain why and how to correct it.

TikTok
Machine Learning
Machine Learning Engineer
TikTok
November 29, 2026
Machine Learning Engineer
Onsite
Machine Learning
Hard

0

0

0 solved


A two-tower retrieval model trained with in-batch negatives keeps retrieving the same popular videos. Explain why and how to correct it.

Candidate retrieval for TikTok's feed narrows a huge video corpus to thousands of candidates, usually with two-tower models. Onsite interviewers probe sampling bias in in-batch softmax training and the logQ correction, plus how to add hard negatives.

What the Interviewer Expects
  • Describe the two-tower architecture and softmax training
  • Explain why in-batch negatives oversample popular items
  • Derive or state the logQ correction
  • Discuss mixed negative sampling and hard negatives
  • Evaluate with recall@K by item popularity bucket
Key Topics to Cover
two-tower model
in-batch negatives
sampling bias
logQ correction
retrieval evaluation
How to Approach This
  1. Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
  2. Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
  3. Feature engineering is often more impactful than model selection.
  4. Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
  5. Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
  • How would you estimate item sampling probability in a stream?
  • Why are hard negatives risky?
  • How do you set the softmax temperature?
  • How does retrieval differ in objective from ranking?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Explore ML Interview Prep
Sample Answer
Clarify

The model encodes users and videos into embeddings uu and vv and scores with s(u,v)=u⊤v/τs(u, v) = u^\top v / \tau. Positives are engaged impressions. In-batch training uses the other positives in the batch a...

Approach

In a batch drawn from engagement logs, popular videos appear often, so they show up as negatives far more often than in a uniform sample. The in-batch softmax is therefore a biased estimate of the ful...


Submit Your Answer
Markdown supported