Revisiting Generative Retrieval: From Negative Sampling to Item Encoding
2026-9-23
Words 3834Read Time≈ 10 min
notion image
If generative retrieval doesn't deliver gains easily, you're most likely doing it wrong.

Generative retrieval is actually simpler than two-tower

On the one hand, an increasing number of people in the industry are achieving significant business results quickly by using generative retrieval; on the other hand, compared to traditional retrieval methods, generative retrieval is actually much simpler in terms of modeling and infrastructure, especially when compared to building a dual-tower retrieval system from scratch. This may seem counterintuitive: in a company with a mature recommendation infrastructure, deploying a dual-tower system has become highly standardized, while generative retrieval is more likely to be seen as a newer and more complex technology. However, this is simply because the industry has accumulated nearly a decade of infrastructure and knowledge in dual-tower systems, and many capabilities that seem obvious today were not readily available in the past.
If you've built a dual-tower model from scratch, the first thing you need to solve is vector indexing. Back when there weren't any mature vector retrieval libraries, I had the opportunity to build an approximate retrieval system based on a K-Means search tree. Today, with Faiss, HNSW, and various vector retrieval systems, this has become a hidden task, but it's not simple in itself. Another often overlooked problem with dual-tower models is the consistency between the user tower and the item tower. User vectors can generally be computed in real-time, but item vectors often need to be refreshed asynchronously or in a streaming manner. If the model has already been updated, but the item vectors in the vector database still come from the old model, the user and items will no longer be in a completely consistent vector space, and you'll need vector refresh, model version management, incremental index building, and various fallback mechanisms. Generative retrieval is much more straightforward in terms of indexing: you only need to store the mapping from SID to item ID in a KV store or an inverted index. After the model generates the SID, you can directly retrieve the item.
Two-tower only looks simple — not because it was simple from day one, but because its complexity has sunk beneath the infra.
To be fair, generative retrieval also shifts some of the costs elsewhere: the inference overhead, latency, and GPU costs of autoregressive decoding combined with beam search are significantly higher than a single user tower forward pass plus a single ANN retrieval, and this is a real cost of generative retrieval on the serving side. However, today's models are based on scaling, and inference on GPUs should be a cost that all scalable models should be able to afford.
Infra aside, two-tower modeling isn't simple either; not many people got it right on the first try back then.

The real difficulty of two-tower: negative sampling

Ideally, we'd like to model a full softmax:
If there are only a few thousand items, this is not a problem. However, the candidate set for industrial recommendation systems may contain tens of millions or even hundreds of millions of items, making it impossible to calculate the complete denominator for each sample. Therefore, we can only sample a small number of items from a certain sampling distribution Q(i) and use a small set to approximate the entire item space. In other words, from the moment sampling is introduced, what we are optimizing is no longer the original full softmax, but its approximation.
Early versions of YouTubeDNN used a sampled softmax similar to Word2Vec. When the vocabulary size was only a few hundred thousand, storing the sampling table in memory was not a problem. However, when the candidate set grew to hundreds of millions of constantly changing items, maintaining the sampling distribution and efficiently sampling became a significant infrastructure challenge. Later, In-batch Negative greatly simplified this: it directly treated the positive examples of other samples within the same batch as negative examples for the current sample. The problem with this approach is also obvious: the negative example distribution is essentially aligned with the positive example distribution. An item that appears more frequently as a positive example is more likely to become a negative example for others, and popular items are therefore disproportionately suppressed.
"Sampling-Bias-Corrected Neural Modeling for Large Corpus Item Recommendations" introduces the classic LogQ correction, which is based on a simple intuition: an item should not be penalized again for its high sampling frequency if it is more likely to be selected as a negative example simply because it is popular. However, LogQ requires an accurate estimation of the sampling probability of each item, which is much more complex in a streaming system than the formula suggests. In my experience, I have seen LogQ implemented incorrectly multiple times in real-world applications.
However, the sampling probability is only the first layer of the problem. A good Q(i) must also cover the truly important competing items: if the positive example is a pair of sneakers, and the negative examples are mostly pots and pans, the loss function is easy to optimize, but the model learns almost nothing about the useful distinguishing boundaries. Therefore, there are hard negatives, mixed negative samples, cross-batch negative samples, and increasingly complex samplers.
Even more discouraging, this isn't something good engineering can fully solve. "Adaptive Sampled Softmax with Kernel Based Sampling" gives an elegant result: only when the sampling distribution exactly equals the model's own softmax distribution
is the sampled-softmax gradient an unbiased estimate of the full-softmax gradient. Uniform sampling, popularity sampling, and in-batch negatives can't achieve this in practice; LogQ and more negatives reduce the bias, but finite sampling is always an approximation. Hence the vivid saying in retrieval: ranking is the art of features, retrieval is the art of samples. The underlying fact is that two-tower modeling quality depends heavily on negative sampling.

This article is for paid subscribers

Subscribe to RecsysFrontier to read the full article

  • Read essays, dailies and weeklies the day they come out (free readers wait 2–8 days)
  • Full archive anytime, including the paid-only Premium section
  • Join the paid-subscriber chat on Substack to discuss technical questions
  • Ask career questions by direct message
  • Generative Recommendation
  • A Guide to Getting Promoted, Again and Again, in TechTechnical Depth and Technical Taste in Recommender Systems
    Loading...
    Catalog
    中