LLM-Powered Search Relevance Re-Ranking System

leboncoin · E-commerce · 2023 · source Agentic: no · promotional bias: med · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Marketplace search relevance

LeBonCoin needed to improve search-result ordering across a large, volatile user-generated classifieds catalog while preserving the low latency expected from a production search engine.

Constraints:

Architecture

LeBonCoin deployed a DistilBERT-based bi-encoder re-ranker beside its existing ElasticSearch search stack. The ad encoder precomputes embeddings for catalog ads into a vector database, while the query encoder and scorer run at request time on the top-k ads returned by ElasticSearch. The neural scores are combined with the original ElasticSearch scores, then the re-ranked top-k results are shown ahead of the residual result set.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  Dataset["Click-model dataset builder"] --> Ad["Ad encoder"]
  Dataset --> Query["Query encoder"]
  Ad --> Vector["Vector database"]
  Elastic["ElasticSearch retriever"] --> Scorer["Scorer"]
  Vector --> Scorer
  Query --> Scorer
  Scorer --> Final["Final ranker"]
  Elastic --> Final
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Click-model dataset builder Turns implicit user clicks into contrastive examples for learning which ads are good or bad for a query. Ad encoder, Query encoder
Ad encoder Encodes ads offline into vector representations using the ad side of the bi-encoder. Click-model dataset builder, Vector database, Scorer
Query encoder Computes a query representation at request time for the selected search query. Click-model dataset builder, Scorer
Vector database Stores precomputed ad vectors so online serving can retrieve representations instead of encoding all ads in real time. Ad encoder, Scorer
ElasticSearch retriever Runs the first-stage lexical and custom-scored retrieval to produce the candidate pool and top-k ads. Scorer, Final ranker
Scorer Combines ad and query representations to output click-propensity relevance scores. Ad encoder, Query encoder, Vector database, Final ranker
Final ranker Combines neural re-ranker scores with ElasticSearch scores and emits the final displayed listing. ElasticSearch retriever, Scorer

Data flow

The system builds training data from click-model signals, trains a two-tower ad/query encoder with a scorer, embeds the ad catalog offline through the ad encoder, retrieves an initial pool with ElasticSearch at query time, fetches top-k ad vectors, computes the query embedding and click-propensity scores, combines neural and ElasticSearch scores, and displays the re-ranked top-k ahead of unre-ranked residual ads.

5 supporting quotes
“We used statistical filtering [1] and example weighting [2] approaches to leverage our users’ implicit feedbacks to build a multimodal dataset for a contrastive learning task”article, stated
“The two encoders, made of a large language model (LLM) [3] and custom layers are jointly trained to produce both an Ad and Query representation”article, stated
“the first step is to trigger the embed_ad entrypoint of our Re-Ranker model (which only triggers the Ad Encoder brick) and compute a representation of all the ads available in our catalogue.”article, stated
“a pool of ads is first retrieved and ranked by our ElasticSearch (with a TF-IDF like algorithm and custom functions).”article, stated
“Only the top k of the pool of retrieved ads are sent to the Re-Ranker to compute a relevance score. Then, those new Re-Ranker’s scores are combined with the ElasticSearch’s ones”article, stated

Why this architecture

LeBonCoin chose a bi-encoder and top-k re-ranking architecture because full neural scoring of all ads at request time would not fit search latency and throughput constraints. Offline ad embedding moves the expensive catalog-side work out of the request path, while ElasticSearch preserves high-recall first-stage retrieval and the neural scorer improves ordering where users look first.

4 supporting quotes
“a search engine must not only be relevant, it must also be blazing fast. More precisely, being able to answer our users’ queries within low latencies time window”article, stated
“having a two-towers model architecture allows us to compute the ads and queries representations at different times.”article, stated
“There is no need to overload the real-time serving with computation that can be made before.”article, stated
“Retriever and ranker are complementary to each other, while the retriever focuses on the recall, the ranker purpose is to sort the retrieved items by their relative relevance to a query.”article, stated

Models used: DistilBERT · bi-encoder · custom MLP layers

Scale

Alternatives considered (roads not taken)

Rely only on ElasticSearch ranking

Rejected because: ElasticSearch remains the retriever, but LeBonCoin added the neural re-ranker because the goal was to improve the ordering of ads for a query.

“a pool of ads is first retrieved and ranked by our ElasticSearch (with a TF-IDF like algorithm and custom functions).”article, stated
“the Re-Ranker takes a list of ads and re-sort it.”article, stated

Compute all ad representations in the online request path

Rejected because: The catalog-side computation can be done before serving, avoiding unnecessary load on the real-time path.

“There is no need to overload the real-time serving with computation that can be made before.”article, stated

Re-rank the entire retrieved result set

Rejected because: The production design limits neural scoring to the top-k candidates and appends residual ads afterward.

“Only the top k of the pool of retrieved ads are sent to the Re-Ranker to compute a relevance score.”article, stated
“The residual ads (which were not sent to the Re-Ranker) are simply appended after the top k that have been re-ranked to produce the final listing displayed to our user.”article, stated

Patterns

multi-stage-retrieval (retrieval)

ElasticSearch performs first-stage retrieval, and the neural re-ranker only rescored top-k candidates before final ranking.

“a pool of ads is first retrieved and ranked by our ElasticSearch (with a TF-IDF like algorithm and custom functions).”article, stated
“Only the top k of the pool of retrieved ads are sent to the Re-Ranker to compute a relevance score.”article, stated

latency-aware-model-routing (serving)

The architecture routes expensive ad encoding to offline batch computation and keeps only query encoding and scoring in the online path.

“having a two-towers model architecture allows us to compute the ads and queries representations at different times.”article, stated
“the first step is to trigger the embed_ad entrypoint of our Re-Ranker model (which only triggers the Ad Encoder brick) and compute a representation of all the ads available in our catalogue.”article, stated

eval-driven-development (evaluation)

LeBonCoin evaluated the re-ranker through business and user-experience ranking metrics before presenting it as the first successful production iteration.

“This was our first iteration of the Re-Ranker project, which showed great results, improving both our business targets (click & contact rate up to +5%) and user experience KPIs”article, stated

Tradeoffs

Use a bi-encoder with offline ad embeddings

Chose separate ad and query encoders with precomputed ad vectors over jointly processing every query-ad pair online.

Rationale: The chosen architecture fits the latency and throughput constraints by moving catalog-side computation out of the request path.

“having a two-towers model architecture allows us to compute the ads and queries representations at different times.”article, stated
“There is no need to overload the real-time serving with computation that can be made before.”article, stated

Use staged re-ranking rather than neural full-corpus ranking

Chose ElasticSearch retrieval plus top-k neural re-ranking over running the neural scorer over all retrieved or catalog ads.

Rationale: The neural stage focuses compute on candidates most likely to affect the visible result list while preserving a complete listing.

“Only the top k of the pool of retrieved ads are sent to the Re-Ranker to compute a relevance score.”article, stated
“The residual ads (which were not sent to the Re-Ranker) are simply appended after the top k that have been re-ranked to produce the final listing displayed to our user.”article, stated

Gotchas (what bit them)

Initial retrieval bounds what the neural re-ranker can improve.

Root cause: Only top-k candidates from ElasticSearch are sent to the re-ranker, so missed candidates remain outside the neural stage.

Resolution: Use ElasticSearch as a recall-focused retriever and reserve neural scoring for the most visible candidates.

“Retriever and ranker are complementary to each other, while the retriever focuses on the recall, the ranker purpose is to sort the retrieved items by their relative relevance to a query.”article, stated
“Only the top k of the pool of retrieved ads are sent to the Re-Ranker to compute a relevance score.”article, stated

Real-time neural ranking can overload a search serving path.

Root cause: Deep neural networks must serve within dozens of milliseconds while handling thousands of requests per second.

Resolution: Precompute ad embeddings offline and run only query-side encoding plus scoring online.

“being able to answer our users’ queries within low latencies time window (few dozens of milliseconds allowed) while facing high throughput”article, stated
“There is no need to overload the real-time serving with computation that can be made before.”article, stated

Click-derived training labels inherit search-position and exposure bias.

Root cause: The dataset relies on implicit user feedback rather than explicit unbiased relevance judgments.

Resolution: Use statistical filtering and example weighting when building the contrastive learning dataset.

“We used statistical filtering [1] and example weighting [2] approaches to leverage our users’ implicit feedbacks to build a multimodal dataset”article, stated

Evaluation

LeBonCoin assessed the first production re-ranker iteration through business targets and search quality KPIs after deployment.

Metrics: click rate · contact rate · nDCG · average clicked position · average contacted position

“This was our first iteration of the Re-Ranker project, which showed great results, improving both our business targets (click & contact rate up to +5%)”article, stated
“and user experience KPIs (nDCG and average clicked & contacted positions up to +10%).”article, stated

Outcomes

The deployed search architecture served nearly 30 million monthly active users and more than 60 million ads under peak loads of up to a few thousand requests per second.

3 supporting quotes
“we successfully deployed in production, facing highly restrictive conditions specific to the search engine industry, large neural networks to facilitate users’ contact and improve their search experience”article, stated
“This was our first iteration of the Re-Ranker project, which showed great results, improving both our business targets (click & contact rate up to +5%)”article, stated
“and user experience KPIs (nDCG and average clicked & contacted positions up to +10%).”article, stated