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-sfx reached 0.1065 Recall@10 (tau = 0.07) and 0.7413 Recall@300 (tau = 0.05), beating plain-sfx (0.0643 and 0.5991) and mse-gramian (0.0432 and 0.3530).
  • Strong offline YouTube retrieval gains: Across a shifting 10M-video index (batch = 8192, tau = 0.05), correct-sfx raised Recall@50 from 0.4586 (plain-sfx) to 0.5322 (+7.36 points, vs. 0.1338 for mse-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.
Full-corpus Recall@K with and without LogQ correction (higher is better)
YouTube 10M-video corpus (Recall@50, tau = 0.05)
correct-sfx (LogQ)0.5322
plain-sfx (uncorrected)0.4586
mse-gramian0.1338
Wikipedia 5.3M pages (Recall@10 / @300)
correct-sfx (tau = 0.05)0.0987 / 0.7413
correct-sfx (tau = 0.07)0.1065 / 0.7234
plain-sfx (tau = 0.07)0.0643 / 0.5991
mse-gramian0.0432 / 0.3530

Wikipedia uses batch 1024 for 10M steps; YouTube uses batch 8192 and 7-day sequential eval. Source: Yi et al. (2019), Tables 1 and 2.

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):

  1. When item y appears at global step t, update B[h(y)] <- (1 - alpha) * B[h(y)] + alpha * (t - A[h(y)]) (alpha = 0.01).
  2. Record A[h(y)] <- t and estimate sampling probability as p_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, raising tau from 0.07 to 0.14 dropped correct-sfx Recall@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 to delta, while higher alpha tracks distribution shifts faster at higher steady-state variance. Under fixed bucket memory, m = 2 or m = 4 hash functions lowered L1 frequency 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 updating p_j skews logits the wrong way.
  • Does not fix positive exposure bias: LogQ corrects 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 = 1 across clicks (holding out 10% of data over 7 days) because continuous offline reward metrics were unclear, whereas live A/B tests used engagement weights; Table 2 also kept m = 1 (H = 50M) despite Algorithm 3 showing m > 1 reduces 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.