Notes

Two-Tower Model

Scoring every item in a catalogue against every request is impossible past a certain size. The two-tower model gets around it by never putting the user and the item into the same network.

Two encoders, one space
One tower encodes the user — history, demographics, context — into a vector. A second encodes the item — identifiers, text, categories — into a vector of the same dimension. The score is their dot product, with no layer anywhere that sees both inputs at once. That restriction is the design, not an oversight: because the item tower depends only on the item, every item embedding can be computed in advance and loaded into an ANN index such as FAISS or ScaNN. At request time only the user tower runs, and retrieval becomes a nearest-neighbour lookup — sub-linear in catalogue size instead of linear.

Training
Training is classification over the catalogue with in-batch negatives or sampled softmax: the other items in the minibatch stand in for the millions not scored. Popular items appear as negatives more often than chance, so the logits are corrected by the sampling probability — skip that and the model systematically suppresses the head of the catalogue.

Where it sits and what it costs
It is a retriever, not a ranker. Without cross-features it cannot model “this user clicks this brand on mobile”, which is what the ranking stage downstream is for. Its other standing cost is freshness: embeddings are only as current as the last index build.

A two-tower model encodes the user and the item with two separate networks into one shared embedding space and scores a pair by dot product, with no layer that sees both sides at once. That separation is what makes retrieval tractable: item embeddings are precomputed into an ANN index, and only the user tower runs per request. Trained with in-batch negatives or sampled softmax, it serves as the retrieval stage rather than the ranker.

Picture a dating agency that writes two kinds of index card: one describing each member, one describing what each member is looking for. Matchmaking is then just finding cards that line up — and the member cards can be filed in advance, long before anyone walks in.

A two-tower model works like that. One part of the system turns you into a short list of numbers; another turns every item in the catalogue into the same kind of list, ahead of time. Finding your recommendations means looking for the item numbers closest to yours, which a computer can do across millions of items in a few milliseconds.