Problem
leboncoin is the first French second-hand marketplace, with almost 30 million monthly active users and more than 60 million ads. Sellers describe ads in free text, so wording varies widely. Poor results frustrate buyers and make them leave. Good results bring more contacts between buyers and sellers. The search team needed to sort ads in the best order for a query within a few dozen milliseconds, at peaks of a few thousand requests per second.
Example from the article: ElasticSearch returns a pool of ads for a query, and the ads most likely to be clicked should come first.
Solution in brief
Train a two-tower model (ad encoder and query encoder, each a language model plus custom layers) on click-derived data to predict click probability. Embed the catalogue offline, then at query time re-rank only the top k ElasticSearch results from stored ad vectors and a fresh query vector.
Questions this case answers
- How to add a learned relevance model on top of a keyword-based retrieval stage when the search must answer in tens of milliseconds
- How to train a query-item relevance model from implicit click feedback when clicks are noisy and position-biased
- How to improve the ranking of search results in a classifieds marketplace with a language model trained on click data?
- How to serve a large neural re-ranker within a few dozen milliseconds at thousands of requests per second?
Tools and methods
- Two-tower (bi-encoder) model — separate ad and query encoders trained jointly, used separately at serving.
- Contrastive learning on click data — builds a dataset of good and bad ads per query.
- Statistical filtering and example weighting — turns noisy implicit feedback into training labels.
- DistilBERT — the language model the post cites (reference [3]) for the text part of the encoders.
- Elasticsearch — first-stage retrieval and ranking (TF-IDF-like score with custom functions).
- Vector database — stores precomputed ad embeddings.
Google or a one-time email code. No password.