Subtracting an item’s log sampling probability (log(p_j)) from in-batch softmax logits nearly doubled live engagement gains in YouTube’s two-tower retrieval model, lifting A/B engagement from +0.20% to +0.37% over production. Because deep item towers encode content features at training time, sampling thousands of extra negatives per step is prohibitively slow, forcing teams to reuse other positive items in the mini-batch as negatives. Without correction, power-law item popularity turns hit videos into frequent batch negatives and overly suppresses them; Xinyang Yi and colleagues paired logQ logit correction with a vocabulary-free streaming frequency estimator to eliminate that bias across tens of millions of videos.
- Nearly 2x live YouTube A/B lift: At
tau = 0.05, bias-corrected batch softmax (correct-sfx) lifted live engagement by +0.37% over the existing production system, versus +0.20% for uncorrected batch softmax (plain-sfx). - 66% higher Wikipedia Recall@10: On the 5.3M-page English Wikipedia link graph,
correct-sfxreached 0.1065 Recall@10 (tau = 0.07) and 0.7413 Recall@300 (tau = 0.05), beatingplain-sfx(0.0643 and 0.5991) andmse-gramian(0.0432 and 0.3530). - Strong offline YouTube retrieval gains: Across a shifting 10M-video index (
batch = 8192,tau = 0.05),correct-sfxraised Recall@50 from 0.4586 (plain-sfx) to 0.5322 (+7.36 points, vs. 0.1338 formse-gramian). - No fixed item vocabulary required: A distributed hash-array estimator tracks moving-average step gaps
delta(p_hat = 1 / delta), adapting to daily catalog shifts across workers without storing an ID dictionary.
How LogQ and streaming frequency estimation work
In YouTube’s 2016 retrieval model, candidates were flat ID classes in an extreme softmax, making importance sampling from a static unigram table cheap. Once the candidate tower becomes a multi-layer ReLU network ([1024, 512, 128] on YouTube) over sparse IDs, topics, and continuous video features, evaluating extra negatives requires extra forward and backward passes through the item tower. Reusing the B examples already in the mini-batch avoids that compute, so each query x_i scores against {y_j}_{j in [B]} using L2-normalized tower embeddings and temperature scaling:
s(x, y) = <u(x, theta), v(y, theta)> / tau
Because items enter batches according to click frequency p_j, popular videos appear in the softmax denominator far more often than uniform negatives. Following sampled-softmax importance weighting, Yi and colleagues subtract the log proposal probability from each logit:
s^c(x_i, y_j) = s(x_i, y_j) - log(p_j)
Each positive pair (x_i, y_i) is weighted by continuous engagement reward r_i (0 for brief clicks, 1 for full watches) in the batch cross-entropy loss L_B(theta).
YouTube trains sequentially day by day on fresh interaction logs with a shifting catalog, so p_j cannot live in a fixed vocabulary table. Algorithm 2 tracks the average global step gap delta between consecutive hits of item y using two parameter-server hash arrays A and B of size H (50M on YouTube, 40M on Wikipedia):
- When item
yappears at global stept, updateB[h(y)] <- (1 - alpha) * B[h(y)] + alpha * (t - A[h(y)])(alpha = 0.01). - Record
A[h(y)] <- tand estimate sampling probability asp_hat = 1 / B[h(y)].
Because hash collisions blend items into one bucket and under-predict step gaps, Algorithm 3 maintains m independent hash tables {A_i, B_i} and takes p_hat = 1 / max_i B_i[h_i(y)] at inference, similar to a Count-Min Sketch. At serving, offline-computed item embeddings feed an approximate maximum inner product search index (like FAISS or DiskANN).
Key findings and ablation behavior
Three implementation choices proved critical alongside log(p_j):
- L2 normalization and temperature sensitivity: Unit-normalizing tower outputs stabilized training on both benchmarks, but made performance sensitive to
tau. On Wikipedia, raisingtaufrom0.07to0.14droppedcorrect-sfxRecall@10 from 0.1065 to 0.0807 and Recall@300 from 0.7234 to 0.5529. - Shared embeddings and OOV hashing: Sharing video ID embeddings across seed, candidate, and watch-history inputs matched separate tables while saving memory, and out-of-vocabulary hash buckets absorbed fresh uploads during sequential training.
- Adaptation vs. variance tradeoff: Proposition 4.1 proves
E[delta_t]converges todelta, while higheralphatracks distribution shifts faster at higher steady-state variance. Under fixed bucket memory,m = 2orm = 4hash functions loweredL1frequency error in simulation.
Caveats and builder takeaway
- LogQ depends on the actual batch sampler: Subtracting
log(p_j)corrects how items entered the batch. Uniform negative sampling or batch deduplication without updatingp_jskews logits the wrong way. - Does not fix positive exposure bias:
LogQcorrects negative sampling frequency, not display-position skew on positive clicks, which YouTube’s multitask ranker handles separately. - Offline vs. live reward mismatch: Offline tests used binary
r_i = 1across clicks (holding out10%of data over 7 days) because continuous offline reward metrics were unclear, whereas live A/B tests used engagement weights; Table 2 also keptm = 1(H = 50M) despite Algorithm 3 showingm > 1reduces collision error.
If you train a two-tower retriever on interaction streams with in-batch negatives, subtracting log(p_j) with L2-normalized towers and a streaming step-gap sketch is a low-cost retrieval upgrade.

