Cover art for the article Two-tower retrieval for recommenders at scale

Two-tower retrieval for recommenders at scale

A ranker that scores every item breaks once the catalog reaches millions. Two-tower retrieval splits the work, and six gates show when it pays for itself.

AI/ML DECEMBER 4, 2026

A recommender that scores every item with one model hits a hard limit as the catalog grows. At about 0.05 milliseconds per candidate on a batched GPU, a ranker facing 10 million listings needs 500 seconds of compute behind a widget with a 200 millisecond budget.

The usual patch is a nightly batch job that precomputes the top 100 items for every user and caches them. Latency recovers. Listings created after the nightly job never appear, new users get the global popular list, and a seller who lists on Monday morning waits until Tuesday for a first impression.

Production recommenders avoid this wall by splitting the work into stages. A retrieval stage narrows millions of items to a few hundred candidates in tens of milliseconds, and a ranking stage spends its compute on those few hundred. Two-tower retrieval, also called dual-encoder retrieval, is the most common way to build the first stage, and it carries its own costs in training data, index operations, freshness and evaluation.

Many teams should not build it yet. The six gates below show when a two-tower retriever pays for itself, and the plan after them shows how to ship a first one in 30 days.

Why one scoring model stops working

Most recommendation systems begin as one model. The team trains a gradient-boosted tree or a small neural network on click and purchase logs, scores items for a user and sorts. That design works for a few thousand items, and the arithmetic breaks well before the catalog reaches millions.

Flow from a page request through retrieval over 10 million items, a few hundred candidates, ranking, and the final page. Click to expand
A retrieval stage narrows millions of items to a few hundred before ranking orders them.

The 0.05 millisecond figure is a planning number for a mid-sized neural ranker with cross features, and each team should measure its own. Give ranking 50 to 80 milliseconds of a 200 millisecond page budget, and the ranker affords 1,000 to 1,600 candidates. Something has to choose those candidates from 10 million items in a few tens of milliseconds, without scoring each item.

Retrieval is that stage, and it solves a recall problem. Its job is to place the items a user would engage with somewhere inside a candidate set of a few hundred to a few thousand. Ranking solves a precision problem, ordering those candidates with every available feature, including user and item cross features, context, price, inventory and freshness.

The two stages fail in different ways. A retriever that misses a good item cannot be corrected downstream, because the ranker never sees the item. A ranker that mis-orders good candidates produces a poor page even when retrieval was perfect, so a team that diagnoses a weak recommender from one quality number can tune the wrong stage for months.

Cold start is decided at retrieval as well. A model trained only on interaction logs has no basis for scoring an item without interactions, and an item that is never retrieved never earns any. On a marketplace, a new seller whose listings are never shown stops listing.

How two-tower retrieval works

The architecture fits in a few paragraphs. A user tower maps user features and recent behavior to a vector. An item tower maps item features, such as category, text, price and image embeddings, to a vector of the same dimension, between 64 and 256 in most systems.

Two paths, a batch path encoding items into an index and a request path encoding the user, meeting at an index lookup that returns candidates. Click to expand
Item vectors are built in batch while the user tower runs once per request.

The two networks train together so that the dot product of a user vector and an item vector is high for observed engagements and low for sampled negatives. The usual objective is a softmax over the positive and a set of negatives, often the other items in the same training batch. In the classic form the towers share no weights, and all interaction between user and item happens in that final dot product.

Serving is inexpensive because item vectors depend only on item features. The system encodes the catalog in batch, writes the vectors to an approximate nearest neighbor index and reuses them on every request. At request time it runs the user tower once, a few milliseconds on CPU for a small network, and asks the index for the items with the largest dot product.

Memory sets the capacity plan. At 10 million items and 128 float32 dimensions, the raw vectors occupy 5.12 GB, and int8 quantization reduces that to 1.28 GB before index overhead. A graph index such as HNSW, which builds a multi-layer proximity graph with logarithmic search complexity, adds neighbor lists on top of the vectors, and IVF with product quantization compresses vectors further at some cost in recall.

The index choice is a trade between recall, memory and throughput. A 2026 benchmark of six index types inside Milvus on 1.6 million embeddings found that HNSW delivered the highest recall with greater memory pressure, while ScaNN and IVF-SQ8 delivered the highest throughput. We set a recall target against exact search at the ranker’s candidate count, commonly 95 percent, and tune index parameters on our own catalog until the index meets it.

The design has a known ceiling. Because the towers never see each other’s features, a two-tower model cannot express interactions such as “this user buys this brand only on discount”. We accept that limit at retrieval and recover precision in the ranker, which has the full feature set and only a few hundred candidates to score.

When a simpler retriever is enough

Two-tower retrieval commits a team to training pipelines, embedding stores, index builds and a negative sampling strategy. Adopting it before the catalog needs it takes engineering time away from problems with larger returns.

Public benchmarks show how much the answer depends on the catalog. In the benchmark section of a December 2025 survey of retrieval methods in ACM Transactions on Information Systems, a popularity baseline reaches a HitRate@50 of 0.7703 on MovieLens-1M, against 0.9412 for LightGCN, a learned embedding model served through the same dot product lookup. On Amazon-Book, a larger and sparser catalog, popularity reaches a HitRate@100 of 0.1072 and LightGCN reaches 0.5574 under the same training setup.

HitRate@K is the share of users with at least one held-out item in their top K. On MovieLens-1M, a popular list already hits for more than three users in four, so a learned retriever adds a modest gain. On Amazon-Book, popularity misses almost nine users in ten, and the learned retriever earns its cost.

SituationRecommended retrievalReason
Under 10,000 items, dense interactionsPopularity plus business rulesLearned retrieval adds little recall over a well-filtered popular list
10,000 to 1 million items, stable catalogMatrix factorization or item-to-item co-occurrenceOffline training is simple, and serving is a lookup
Over 1 million items, or rich item and user featuresTwo-tower with an approximate nearest neighbor indexContent features cover cold start, and cost per request stays flat as the catalog grows
Strong sequential behavior, such as sessions and watch historyTwo-tower with a sequence encoder in the user towerRecent behavior carries most of the signal
Fewer than 2,000 daily active usersRules and editorial curation firstTraining data is too thin to learn stable embeddings

The thresholds in this table are planning boundaries, and we adjust them per product. Catalog size, feature richness and traffic set the retrieval design, and a team can defer the build until its own measurements call for it.

The six-gate retrieval scorecard

Score six gates before committing to a two-tower retriever. A team that passes four or more starts the build. A team that fails gate one or two fixes its baseline and its latency budget first.

Decision flow where gates one and two must pass, then four of six gates decide whether to build a two-tower retriever or keep a simpler one. Click to expand
Failing the catalog or latency gate sends a team back to fix its baseline first.
GateQuestionEvidence to collectPlanning threshold
1. Catalog and trafficIs there enough scale to need a learned retriever?Item count, daily interactions, interactions per itemOver 1 million items, or a popularity baseline that trails a learned model offline
2. Latency budgetDoes retrieval fit its share of the request?Per-stage latency percentilesRetrieval p99 under 30 ms inside a 200 ms end-to-end budget
3. Cold startCan new items and users receive a meaningful vector?Share of traffic on items under 7 days old, feature coverageItem features cover 95 percent or more of new items
4. Negatives and biasIs there a negative sampling plan?Popularity skew of impressions, logged exposure dataExposure logs exist, and a sampling strategy is written down
5. FreshnessDo embeddings and the index update at the needed cadence?Time from item change to retrievableUnder 1 hour for inventory-sensitive catalogs, daily otherwise
6. EvaluationCan offline gains be verified online?A/B test capacity, holdout designAt least one test per month with a primary metric agreed in advance

Gate 1, catalog and traffic

Compute recall at the candidate count the ranker uses, for example recall at 500. Run it for a popularity retriever and for a simple matrix factorization on a time-based holdout, training on everything before a cutoff date and testing on the weeks after it. If the learned model’s lead over popularity is small, the gate fails.

The measurement takes a few engineer-days and settles the build decision. It also becomes the offline baseline that every later retriever must beat.

Gate 2, latency budget

Write down the end-to-end budget and divide it among feature fetching, retrieval, ranking, re-ranking rules and serialization. For a 200 millisecond budget, we give retrieval 20 to 30 milliseconds and ranking 50 to 80 milliseconds, and network and business logic take the remainder.

A retriever that consumes 60 milliseconds forces cuts in the ranker. Allocate the budget before designing the model, because user tower depth and index search parameters both trade against it. Edge vision teams follow the same order, where the five gates for edge Computer Vision deployment fix the latency budget before anyone chooses hardware.

Gate 3, cold start

A new item has no interaction history, but it has a title, description, category, price and image. A well-trained item tower maps those features to a vector near similar existing items. If the item tower also learns an embedding per item ID, the model can lean on that ID and ignore content, so new items land at a random point. Randomly dropping the ID embedding during training forces the tower to place items from content alone.

User cold start works the same way, using device, locale, referrer and the first few clicks. Coverage is the measurement for both. If 30 percent of new listings lack a usable description or category, the item tower produces weak vectors for them, and the fix is a data quality project before any model work.

Gate 4, negatives and bias

The choice of negatives shapes a retriever more than most architecture decisions. In-batch negatives are cheap, and they appear in proportion to how often items occur in training data, so popular items get penalized as negatives far more often than tail items. Google’s sampling-bias-corrected modeling work for YouTube recommendations corrects this by subtracting the log of each item’s estimated sampling probability from its logit, an adjustment usually called the logQ correction.

Mixed negative sampling adds uniformly sampled items from the whole catalog to the in-batch set, which gives tail items a fair share of negative updates. Hard negatives teach the fine distinctions that random negatives miss. A 2026 RecSys workshop paper on real-time hard negative sampling draws negatives from the same LLM-derived content cluster as the positive item, from a live in-memory pool, and reports gains in a 14-day online A/B test along with lower popularity bias.

We do not start training without exposure logs. Records of what was shown, at which position, are the only way to measure exposure bias, and impressed-but-ignored items are a useful source of hard negatives. Use them alongside sampled negatives, because a retriever trained mostly on the previous system’s impressions learns to imitate the previous system.

Gate 5, freshness

Item vectors in the index are a snapshot. When an item changes in price, availability or description, the index serves the old vector until the item is re-encoded and inserted. Marketplaces with one-off listings need an incremental path that inserts new items within minutes to an hour, plus a daily or weekly full rebuild.

Index type affects that path. HNSW accepts incremental inserts, and deletions are usually marked and filtered until the next rebuild. IVF indexes assign vectors to centroids learned at build time, so a shifting catalog degrades recall until the centroids are retrained.

User vectors are computed per request, so they are fresh by construction. Retraining carries the larger risk, because the two towers train together and their vector spaces do not carry over between versions. Re-encode every item and rebuild the index before the new user tower goes live.

Gate 6, evaluation

Offline metrics such as recall at K and NDCG measure agreement with logged behavior, and logged behavior reflects what the previous system chose to show. A retriever that surfaces items the old system never exposed scores lower offline than its online effect, and a retriever that imitates the old system scores higher. Only an online A/B test measures the user-facing result, and the same holds in search, where A/B evaluation gates catch ranking regressions that offline metrics miss.

Towerbench, an open-source benchmark framework published in SoftwareX, shows what disciplined offline evaluation looks like. It ranks the full catalog, reads the test split once, and reports model differences as paired per-user bootstrap intervals across seeds and rolling-origin temporal windows. Its full sweep of 1,974 experiments across seven datasets runs in about a day on two GPUs, so a small team can afford that rigor.

We do not ship a retriever on a single point estimate from one split. A difference that sits inside the bootstrap interval is noise until an online test says otherwise.

A 30-day plan for a first production retriever

The plan produces a measured two-tower retriever behind a feature flag in 30 days, with the existing system as fallback. It assumes two to three engineers, an existing logging pipeline and a ranker already in production.

Days 1 to 7, baseline and data

Split interactions by time and hold out the final one to two weeks. Compute recall at the ranker’s candidate count for popularity, item-to-item co-occurrence and matrix factorization.

Assemble training rows that carry the user, the item shown, whether it was engaged with and its position. Close the largest feature coverage gaps against the gate 3 threshold.

Days 8 to 15, model and negatives

Train a first model with in-batch softmax and the logQ correction. Use one hidden layer per tower and 128-dimensional outputs, with category, price bucket, a frozen sentence-encoder text embedding and the user’s last 20 interactions as inputs.

Add uniform negatives and compare both variants with confidence intervals across at least three seeds. If the model does not beat matrix factorization by a margin outside the interval, extend feature work before moving on.

Days 16 to 22, index and serving

Encode the catalog, build an HNSW or IVF-PQ index, and measure recall against exact search at the candidate count. Tune until recall reaches the target, then measure p50 and p99 latency under production-like load.

Deploy the user tower and index lookup as a service with a hard timeout, so a slow call falls back to the existing retriever. Define the incremental encode job and a daily full rebuild with versioned artifacts.

Days 23 to 30, shadow traffic and the A/B test

Run the retriever in shadow mode, logging the candidates it would have returned and their overlap with the existing system. Inspect candidate sets for a sample of users and for new items, and confirm that the share of new items retrieved is above zero and rising.

Start an A/B test with a primary metric agreed in advance, such as conversion per session. Add secondary metrics for catalog coverage and for the share of impressions on items under seven days old.

Run the test through at least one full weekly cycle. A retriever that wins on day two and loses by day seven is a common result, and the usual causes are a novelty effect or a different weekday mix.

Failure modes that recur

Two-tower failures concentrate in operations and statistics. Six patterns account for most of them.

Popularity feedback loops start when a retriever trained on logs learns that popular items receive clicks, retrieves more of them and generates logs that confirm the pattern. Over weeks the candidate set narrows and long-tail items lose exposure. We apply the logQ correction in training, reserve 5 to 10 percent of retrieval slots for exploration candidates drawn from new or under-exposed items, and track the Gini coefficient of impressions as a standing dashboard metric.

Index and model version mismatch returns plausible but wrong candidates. A new user tower served against an index built by the previous item tower produces vectors of matching dimension and valid dot products, so no error is raised. Version both towers and the index under one artifact identifier, and refuse to serve when the identifiers differ.

Training and serving skew in the user tower is quieter. If the “last 20 interactions” feature is built from a nightly table in training and from a live event stream in serving, the two disagree for every active user. Compute user features through one shared code path, and compare logged serving features against training features on a sample each day.

Offline gains that vanish online often trace to redundant candidates. A retriever tuned only for recall at 500 can return 40 versions of the same item, and the ranker then fills the page with near-duplicates. Measure the number of distinct categories in the top 50 candidates alongside recall, and inspect candidates for a sample of users before touching the model.

Filter bubbles form when a user tower relies on the last few interactions and narrows recommendations around recent behavior. Mix a long-term profile vector with the session vector, and merge a second source such as co-occurrence or editorial lists with the two-tower candidates. Multiple sources also give a safe fallback when one degrades.

A single metric for two stages hides which stage is failing. Track recall at the candidate count for retrieval, and NDCG or a calibrated engagement metric for ranking. Attribute online changes to a stage with ablations, swapping one stage at a time.

What to do this week

Start with measurement. Compute recall at the ranker’s candidate count for popularity and for matrix factorization on a time-based holdout, and write down the gap.

Then write the latency budget by stage, using measured p99 values from production traces. Count the share of new items in the last 30 days that have a usable title, category and image.

Those three numbers score gates 1, 2 and 3. If any of them fails, fix it first, because a two-tower retriever built on a weak baseline or a blown latency budget will not survive its first A/B test.

How Algorithmic helps

Algorithmic builds production Machine Learning systems, from the first baseline through serving, monitoring and the A/B tests that prove them. Our systems serve more than 14 million end users, with more than 2 million predictions produced in production each day. We score the six gates with your team, build the retriever only when the evidence calls for it, and hand over the pipelines, index jobs and dashboards your engineers will run. Bring your three numbers from this week and start a conversation.

Have a complex project in mind?Let's talk.

We limit our client roster to keep depth on every engagement. If your project needs senior engineering judgment from the first architectural decision, share it and we'll respond within 48 hours.

Get in touch