Prod2Vec product embeddings: how we improved matching and got rid of a pile of embeddings

Alexander (alex_golubev13)28 Jan 2022

Problem

A marketplace gets millions of product updates a day, and the matching team must find identical offers from different sellers so that users do not see the same product several times in the feed. Each product has images, a title, a description and attributes. Matching features were built from separate embeddings per modality: fastText and transformers for text, ResNet, EfficientNet and NFNet for images. Computing all of them for every update does not scale. The ranking model that consumes them also pays for every extra input.

Example from the article: without merging offers, the feed would show three identical product cards.

Solution in brief

Train one model on image, title and attribute inputs that predicts the lowest-level category (cat3) with an ArcFace head, and use the layer before the head as the product embedding. Intermediate cat1 predictions from each encoder, with a loss weight that decays over training, make the encoders converge. The single vector replaced image and text embeddings in the ranker and made its inference more than three times faster.

Questions this case answers
  • How to compress several per-modality item embeddings into one vector without losing the signal a downstream ranker needs, when the item catalog is very large and updates continuously
  • How to train a single item embedding from a noisy, hierarchical label tree with thousands of near-duplicate classes
  • How to replace several per-modality product embeddings with one vector that covers images, title, description and attributes?
  • How to train a product embedding when there are thousands of fine-grained categories and plain softmax gives weak embeddings?

Tools and methods

  • Multimodal encoder — ResNet34 for images, two Rubert-Tiny models for titles and attributes, outputs concatenated.
  • ArcFace (angular margin loss) — classification head that pulls same-class embeddings together and pushes classes apart.
  • Hierarchical auxiliary losses — cat1 predictions from each encoder, weighted by an exponentially decaying coefficient.
  • Horovod — multi-GPU training; Spark Structured Streaming computes embeddings daily in production.
Continue reading — it's free

Google or a one-time email code. No password.