How we use engagement-based embeddings to improve search and recommendation on Faire

Qinyu Wang17 Jan 2023

Problem

Faire is a wholesale marketplace (600,000+ retailers, 85,000+ brands) that personalizes search, category, brand-page and carousel rankings. Its LightFM embeddings were a black box, hard to change as the catalog grew. A pairwise ranking loss with exact negative sampling does not scale either: it needs all historical engagements in memory and loops until it finds a hard negative.

Example from the article: category pages are personalized, but cosine similarity over millions of products is too costly and the retrieval stack has no full ANN retrieval.

Solution in brief

Train a two-tower PyTorch model on positive engagement pairs only. Negatives come from shuffling products inside each batch, and a modified WARP loss uses the hardest of three. Embeddings sit in a feature store: search and category retrieval rescore top candidates with them, and brand pages use precomputed similar-brand lists.

Questions this case answers
  • How to learn user and item embeddings from positive-only interaction logs when exact negative sampling does not fit in memory
  • How to use embedding similarity as a personalization signal in a retrieval stack that cannot run a full nearest-neighbor scan
  • How to learn retailer and product embeddings from engagement logs without building a negative-sample dataset
  • How to add embedding similarity to search and category retrieval when the retrieval stack has no full ANN support

Tools and methods

  • Two-tower model — retailer and product towers, cosine similarity at the end
  • In-batch negative sampling — shuffle products within a batch to get negatives on the fly
  • Modified WARP loss — pairwise ranking loss with three shuffles instead of an unbounded loop
  • PyTorch — replaced LightFM for training
  • Elasticsearch rescore — applies an embedding script to the top first-pass candidates
  • Annoy / FAISS — offline top-K similar brands
  • Apache Airflow, Docker — training job every other day
  • Amazon DynamoDB — stores similar brands by brand id
Continue reading — it's free

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