Problem
Kuper's search runs on a Boolean full-text index in Elasticsearch: a product is shown only if all query words occur in its card. Precision is high, but one product can be named in dozens of ways, and synonym lists and spelling correction cannot cover them. Scale: 35 thousand retailers, about 150 thousand unique queries a day, peaks of 2000 RPS and a 300 ms response limit.
Example from the article: the query "sgushchennoe moloko" (condensed milk) finds nothing in a card titled "Moloko 2,5% pasterizovannoe" because the word "sgushchennoe" is absent from it.
Solution in brief
Fine-tune a multilingual E5 encoder on query-to-purchased-product pairs with carefully chosen hard negatives. Offline, find the k nearest historical queries for every product and write them into an extra text field of the Elasticsearch document. Online, the existing Boolean search matches the user query against that field, so no vector database or online encoder is needed.
Questions this case answers
- How to add semantic matching to a lexical Boolean retrieval system under a tight latency budget when deploying a vector index and an online encoder is too costly
- How to train a dense text encoder on purchase logs when in-batch negatives are either too easy or falsely negative and GPU memory limits the batch size
- How to make a Boolean full-text product search find items that users describe with other words, misspellings or rephrasings?
- How to fine-tune a text embedding model on purchase history so that it understands the catalog?
Tools and methods
- multilingual-E5 — base encoder, fine-tuned on Kuper's data
- InfoNCE loss with hard negatives — contrastive training on purchase pairs
- Cross-batch memory — queue of earlier product vectors reused as negatives to save GPU memory
- Qwen (32B) — LLM check that candidate negatives are truly irrelevant
- FAISS — offline search of the k nearest queries per product
- Elasticsearch — a
vector_searchtext field with two analyzers - Apache Airflow — daily refresh of the field
Google or a one-time email code. No password.
