Embedding-Based Retrieval: Our Journey and Learnings around Semantic Search at Faire

Jason Xu17 Jun 2024

Problem

Faire is an online wholesale marketplace. Retailers find products through search. Its search ran on Elasticsearch with BM25 keyword matching and a product quality score, followed by a real-time ranking layer. Retrieval became the bottleneck, because ranking cannot surface relevant products that retrieval never returns. A query such as "comfortable furniture" misses products whose metadata says only "couch" or "sofa". The new retrieval had to fit the latency budget and needed a cheap first version, since its value was unproven.

Example from the article: a search for "comfortable furniture" finds few products described only as "couch" or "sofa".

Solution in brief

Add embedding-based retrieval next to keyword retrieval and blend both candidate lists before ranking. Train a two-tower query-product model, first on text, then with image embeddings. Ship it first as a daily-built cache of top products per historical query. After A/B tests showed a conversion gain, move to real-time ANN search with prefiltering.

Questions this case answers
  • How to add semantic retrieval to a keyword search engine so that relevant items are found when query and item words differ, within a tight latency budget
  • How to validate a retrieval model online cheaply before committing to real-time vector search infrastructure
  • How to add embedding-based retrieval to an existing keyword search engine without hurting latency?
  • How to prove the value of semantic retrieval before building a full ANN serving system?

Tools and methods

  • Two-tower model — separate query and product encoders trained so that matching pairs score high by dot product
  • Elasticsearch — keyword retrieval, filtering and hydration; version 8 adds prefiltered ANN
  • Universal Sentence Encoder / BERT — pre-trained text encoders for the query tower
  • CLIP — base for image-text embeddings of products
  • Amazon DynamoDB — key-value store for cached query results
  • Approximate nearest neighbors (ANN) — real-time vector search for all queries
Continue reading — it's free

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