Positive pair: user clicked item → embeddings should be close
Random negative: random items pushed apart - easy, less informative
Embedding Space Visualization
Recall@10
87.0%
ANN Latency
2.5ms
Index Type
FAISS
Embedding Dim
128d
Top-K
10
Distance
COSINE
Model Controls
Embedding Dimension
Top-K Candidates
top-K10
5100
Distance Metric
ANN Index
Training Signal
Two towers enable efficient retrieval from billions of items.
The item tower runs offline, indexing all items into ANN. Only the query tower runs at request time.
Two-Tower Retrieval Model - Interactive Visualization
The two-tower model (dual encoder) is the dominant architecture for large-scale retrieval. A query tower encodes the user context into a dense vector; an item tower encodes each item into a dense vector. At serving time, only the query tower runs per-request - all item embeddings are pre-computed and indexed in an Approximate Nearest Neighbor (ANN) structure like FAISS or ScaNN. The system then finds the top-K closest item embeddings to the query embedding using cosine or dot-product similarity. Hard negative mining significantly improves training: instead of random negatives, the model is trained to distinguish the target item from similar-but-wrong items.
Item tower runs offline: all item embeddings are pre-computed and loaded into FAISS - per-request cost is just the query tower + ANN search
Cosine similarity: normalized dot product - insensitive to embedding magnitude; preferred when embedding norms vary
Hard negatives: items similar to the positive but not clicked - they provide a stronger training signal than random negatives
Recall@10: the fraction of requests where the true positive item appears in the top-10 ANN results - key offline metric
Part of the EngineersOfAI Interactive 3D - free interactive visualizations covering every major concept in machine learning and AI engineering. Hover any element for a plain-English explanation. No code required.