A Two-Tower Model is a dual-encoder neural architecture that independently maps user features and item features into a shared, low-dimensional embedding space, enabling efficient candidate retrieval via dot-product scoring. The 'user tower' processes features like search history and demographics, while the 'item tower' processes attributes like price and category, with no interaction between the towers until the final similarity computation.
Glossary
Two-Tower Model

What is a Two-Tower Model?
A foundational neural network design for large-scale retrieval that independently encodes user and item features into a shared embedding space for efficient similarity scoring.
This decoupled design allows item embeddings to be pre-computed and indexed in an Approximate Nearest Neighbor (ANN) vector database, making inference sub-linear and ideal for massive catalogs. Training typically employs contrastive learning with in-batch negative sampling, where the model learns to pull relevant user-item pairs together while pushing apart random pairings, optimizing for retrieval recall rather than ranking precision.
Key Characteristics of Two-Tower Models
The two-tower model is a dual-encoder architecture that independently maps user features and item features into a shared embedding space, enabling efficient dot-product scoring for large-scale candidate retrieval.
Dual-Encoder Independence
The defining characteristic of the two-tower architecture is the complete separation of the user and item encoders. Each tower processes its respective features independently:
- User Tower: Ingests user features (demographics, search history, past purchases) and outputs a normalized user embedding
- Item Tower: Ingests item features (title, description, category, price) and outputs a normalized item embedding
This independence means the item tower can pre-compute embeddings for the entire catalog offline, while the user tower generates a single vector at query time. The two sides never interact until the final dot-product scoring, enabling sub-millisecond retrieval from billion-scale corpora.
Dot-Product Scoring in Shared Space
Both towers project their inputs into a shared, L2-normalized embedding space where cosine similarity reduces to a simple dot product. The relevance score between a user and item is computed as:
score(u, i) = u · i
This mathematical property is critical for efficiency:
- No cross-encoder computation at serving time
- Scores are directly compatible with Maximum Inner Product Search (MIPS) indices
- Normalization constrains embeddings to the unit hypersphere, stabilizing training and bounding scores to [-1, 1]
The shared space enforces that proximity implies semantic relevance—users are close to items they are likely to engage with.
Asymmetric Feature Access
A fundamental design constraint of two-tower models is that features are partitioned by tower:
- The user tower has access to user-side features only (historical behavior, profile attributes, real-time context)
- The item tower has access to item-side features only (metadata, content, static attributes)
This asymmetry prevents the model from learning cross-feature interactions—for example, it cannot directly model that a specific user prefers items from a particular brand when that brand is on sale. This limitation is the primary trade-off for the architecture's retrieval speed. Advanced implementations mitigate this by:
- Encoding cross-features as pre-computed user-item affinity signals in one tower
- Using the two-tower as a candidate generator followed by a cross-encoder ranker
In-Batch Negative Sampling
Training a two-tower model with a full softmax over millions of items is computationally prohibitive. The standard solution is in-batch negative sampling:
- For each user in a batch of size N, the model treats the other N-1 items in the batch as negative samples
- This approximates the full softmax distribution using the random composition of the mini-batch
- The InfoNCE loss (or sampled softmax) is applied to maximize the score for the true (user, item) pair while minimizing scores for all other pairs
This technique is computationally free—no additional forward passes are needed for negatives—but introduces a popularity bias where frequently occurring items are more likely to be sampled as negatives, requiring correction mechanisms like log-Q correction or mixed negative sampling.
Pre-Computed Item Embeddings
The separation of towers enables a critical serving optimization: offline pre-computation of the entire item catalog. The item tower runs as a batch inference job, generating embeddings for every item in the corpus:
- Item embeddings are stored in a vector database with an ANN index (typically HNSW or ScaNN)
- At serving time, only the user tower executes, producing a single query vector
- The top-k items are retrieved via approximate nearest neighbor search in logarithmic time
This decoupling means the computational cost of serving is independent of catalog size. A catalog of 100 million items requires the same inference cost as a catalog of 10,000—only the ANN search time scales (sub-linearly). Item embeddings are refreshed periodically as the catalog updates.
Multi-Objective Optimization
Two-tower models can be extended to optimize for multiple business objectives simultaneously by using multiple tower heads or weighted loss functions:
- Shared bottom layers with task-specific projection heads for click, purchase, and engagement predictions
- Each head produces a separate embedding, and final retrieval scores are a weighted combination
- Training uses a multi-task loss:
L_total = α·L_click + β·L_purchase + γ·L_engagement
This allows a single model to balance immediate engagement (clicks) with long-term value (purchases). The weights α, β, γ are hyperparameters tuned to business KPIs. Advanced implementations use uncertainty weighting or gradient surgery (PCGrad) to handle conflicting gradients between objectives.
Frequently Asked Questions
Clear, technical answers to the most common questions about dual-encoder architectures for large-scale candidate retrieval and personalization.
A Two-Tower Model is a dual-encoder neural architecture that independently maps user features and item features into a shared, low-dimensional embedding space, enabling efficient dot-product or cosine similarity scoring for large-scale candidate retrieval. The architecture consists of two separate neural networks—the user tower and the item tower—that never directly interact until the final similarity computation. The user tower ingests features like click history, demographic data, and session context to produce a dense user embedding vector. The item tower processes item attributes, content metadata, and contextual features to generate a corresponding item embedding. During training, the model optimizes for in-batch negative sampling or sampled softmax loss, pulling relevant user-item pairs closer while pushing apart irrelevant ones. At inference, the item tower pre-computes embeddings for the entire catalog, and the user tower generates a query embedding in real-time. An Approximate Nearest Neighbor (ANN) index then retrieves the top-k items in milliseconds, making this architecture the backbone of modern industrial recommendation systems.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Two-Tower vs. Alternative Retrieval Architectures
Comparison of the Two-Tower dual-encoder architecture against alternative candidate retrieval paradigms for large-scale recommendation and search systems.
| Feature | Two-Tower Model | Matrix Factorization | Cross-Attention Model |
|---|---|---|---|
Architecture Type | Dual-encoder (user + item towers) | Latent factor decomposition | Single unified encoder with cross-interaction |
Scoring Mechanism | Dot product of independent embeddings | Dot product of latent vectors | Full cross-attention between user and item features |
Inference Latency | < 10 ms (pre-computed item embeddings) | < 5 ms (pre-computed item vectors) |
|
Candidate Retrieval Scale | Billion-scale via ANN indices | Million-scale via approximate search | Thousand-scale (re-rank only) |
Cold-Start Handling | Content-based tower for new items/users | Requires interaction history; poor cold-start | Content features processed jointly; moderate |
Modeling Non-Linear Interactions | |||
Embedding Pre-Computation | |||
Typical Use Case | Candidate generation (retrieval stage) | Collaborative filtering baseline | Precision re-ranking (top-N refinement) |
Industry Applications of Two-Tower Models
The dual-encoder architecture excels in large-scale candidate retrieval where user and item representations must be computed independently and matched via dot-product scoring.
YouTube Video Recommendation
Google's seminal deployment uses a user tower trained on watch history and search queries, and a video tower trained on content features and demographics. At serving time, the user embedding is computed once and an ANN index retrieves the top-N videos from a corpus of millions, enabling sub-100ms response times for the candidate generation phase.
E-Commerce Product Discovery
Major retailers deploy two-tower models to power search and browse experiences. The user tower encodes purchase history, real-time clicks, and session context. The item tower encodes product titles, descriptions, and categorical attributes. The shared embedding space enables semantic matching—a user searching for 'hiking gear' retrieves trail shoes even when the exact keyword is absent from the product title.
App Store Search Ranking
Apple and Google app stores use two-tower architectures where the query tower encodes the search string and the app tower encodes the app title, description, and in-app purchase behavior. The dot-product score determines relevance ranking. The dual-encoder design allows the app tower embeddings to be pre-computed and indexed nightly, while the query tower runs in real-time at sub-millisecond latency.
News Feed Personalization
Social media platforms use two-tower models to retrieve relevant content from a constantly updating corpus. The user tower captures long-term interests and short-term session signals. The content tower processes article text, images, and publisher authority. The architecture naturally handles the cold-start content problem—new articles get embeddings immediately from their content features without waiting for interaction data.
Music Streaming Discovery
Spotify and similar platforms use two-tower models where the listener tower encodes play history, skip rates, and playlist context, while the track tower encodes audio features, genre tags, and co-occurrence patterns. The shared embedding space enables cross-modal retrieval—a user who listens to acoustic folk discovers instrumental lo-fi tracks through proximity in the latent space rather than explicit genre matching.
Ad Candidate Retrieval
Programmatic advertising platforms use two-tower models to match users with relevant ads in real-time bidding environments. The user tower processes browsing behavior and purchase intent signals. The ad tower encodes creative content, landing page semantics, and advertiser category. The dot-product score determines relevance before auction, filtering billions of candidates to a manageable set for downstream ranking models.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us