Problem
Spotify Search relied mostly on term matching in Elasticsearch: a result must contain the query words in its indexed metadata. Fuzzy matching, normalization and manual aliases only partly cover the many ways people phrase a request, especially in full sentences. For a query without exact word overlap the engine returns nothing, even when relevant content exists. This was most visible for podcast episodes.
Example from the article: the query "electric cars climate impact" retrieved nothing from Elasticsearch, although episodes such as "Are electric cars better for the environment?" exist.
Solution in brief
Train a bi-encoder that maps queries and episode metadata into one vector space, so that a query and its relevant episode land close together. Index episode vectors in an ANN-enabled engine and encode queries online. Run this as an additional retrieval source next to Elasticsearch, and give the final ranker the cosine similarity as a feature.
Questions this case answers
- How to retrieve relevant documents for natural-language queries that share no words with them, while keeping exact-match quality of an existing term-based engine
- How to train a retrieval encoder from interaction logs that contain only positive query-document pairs
- How to find relevant items for a search query when none of them contains the query words?
- How to train a query-to-document embedding model when search logs contain only positive pairs?
Tools and methods
- Dense retrieval (bi-encoder) — query and episode vectors in a shared embedding space
- Universal Sentence Encoder CMLM — multilingual pre-trained base model for both encoders
- In-batch negatives with hard negative mining and margin loss — negative pairs without extra labeling
- BART fine-tuned on MS MARCO — generates synthetic queries for episodes
- Vespa — ANN index of episode vectors and first-phase re-ranking
- Google Cloud Vertex AI — GPU serving of the query encoder
- Elasticsearch — the existing term-based source, kept
Google or a one-time email code. No password.