Learning a Unified Embedding for Visual Search at Pinterest

Andrew Zhai, Hao-Yu Wu, Eric Tzeng, Dong Huk Park, Charles Rosenberg

TL;DR

Pinterest researchers have successfully replaced a fragmented system of specialized image embeddings with a single, unified multi-task embedding that powers all their visual search products. By training one model on diverse datasets (web images, camera photos, and product catalogs), they achieved significant gains in search relevance and user engagement while drastically reducing engineering and storage costs.

What Problem Does This Paper Address?

At a scale of billions of images and hundreds of millions of users, Pinterest offers several distinct visual search experiences:

  • Flashlight: Browsing related content starting from a web image.
  • Lens: Searching for items using a real-world camera photo.
  • Shop-the-Look: Finding exact product matches for items within a home decor or fashion scene.

Previously, each of these products relied on its own specialized embedding model. This created a "maintenance nightmare": every time a new neural network architecture emerged, engineers had to retrain and "back-fill" (re-index) multiple models, which is prohibitively expensive. Furthermore, specialized models couldn't benefit from the data available to other tasks—for example, a model trained only on whole web images struggled with the cropped queries common in shopping searches.

Methods

The authors propose a multi-task deep metric learning framework. Instead of training separate models, they use a shared backbone (specifically, an SE-ResNeXt101) that branches into task-specific "heads."

Key technical innovations include:

  • Proxy-based Metric Learning: Rather than using traditional triplet losses (which are notoriously difficult to sample), they treat metric learning as a classification problem. Each "class" has a learned "proxy" vector in the embedding space.
  • Scalable Subsampling Module: To handle hundreds of thousands of classes from user engagement data, they developed a module that samples a subset of proxies for each training batch. This keeps the computation manageable and allows the proxy bank to reside in CPU RAM while the main model trains on GPUs.
  • Binarization Module: To save on massive storage costs for billions of images, the model learns to produce binary embeddings. By using GroupNorm instead of the standard LayerNorm, they found they could threshold the output at zero to create binary strings with almost no loss in accuracy.
The overall architecture for multi-task metric learning network, featuring the shared backbone and task-specific heads.

Datasets

The model is trained on a combination of three distinct datasets, each reflecting a different product goal:

  1. Flashlight Dataset: 800K images in 15K classes derived from user engagement (e.g., what users click on after seeing a specific image).
  2. Lens Dataset: 540K human-labeled images across 2K classes, specifically designed to bridge the "domain shift" between messy camera photos and clean Pinterest web images.
  3. Shop-the-Look Dataset: 340K images with 50K instance labels, focusing on exact matches between scene objects and product catalog images.
Visualization of the three training datasets showing the variety of image domains (web, camera, product).

Key Insights and Ideas

  • Cross-Pollination of Data: The most striking finding is that the unified model outperforms specialized models on every task. For instance, including "Shop-the-Look" data (which uses object crops) helped the "Flashlight" task handle cropped queries better, even though Flashlight was originally trained only on whole images.
  • The Power of Multi-Tasking: Multi-task learning acts as a regularizer. The "inherent complementary structure" between browsing and searching tasks helps the model learn more robust features that a single-task model would miss.
  • Efficiency via Binarization: Moving to binary embeddings isn't just about storage; it speeds up the "distance" calculations needed to find similar images during a search, which is critical for real-time performance.

Key Results

The researchers evaluated the unified embedding through offline metrics, human studies, and live A/B tests:

  • Offline Metrics: The unified model showed a significant jump in Precision@1 for Shop-the-Look (from 33.0 to 52.8) compared to the old specialized model.
  • Human Judgement: In side-by-side comparisons, the unified embedding improved relevance (Precision@5) by 22.2% for Flashlight and a staggering 110.1% for Lens.
  • Online A/B Tests: Live traffic experiments showed significant lifts in core engagement metrics, including "repins" (saving an image) and "clickthroughs."
A/B experiment results showing statistically significant lifts (blue highlights) in user engagement across various metrics.

Limitations and Future Work

While highly successful, the authors note a few areas for further exploration:

  • Loss Balancing: They currently use equal weights for all task losses. While they experimented with automated weighting (like GradNorm), a simple equal weighting performed best for them, suggesting that balancing diverse objectives remains a subtle art.
  • Domain Shift: While the Lens dataset helps, the gap between low-quality user photos and professional product photography is a persistent challenge in computer vision.
  • Scaling Proxies: While the subsampling module works for hundreds of thousands of classes, scaling to millions of classes (as engagement data grows) will require even more sophisticated distributed training strategies.

Summary updated

BibTeX
@misc{zhai2019learning,
  author = {Andrew Zhai and Hao-Yu Wu and Eric Tzeng and Dong Huk Park and Charles Rosenberg},
  title = {{Learning a Unified Embedding for Visual Search at Pinterest}},
  year = {2019},
  eprint = {1908.01707},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1908.01707},
}
Figure