Projects / Finding the right product in a shopping conversation

Finding the right product in a shopping conversation

Jorge Tyrakowski

Applied Deep Learning, National Taiwan University

Abstract

Given a conversation between a customer and a sales assistant, the system must find the product the customer wants among 75,000 to 100,000, and an LLM judge decides which retrieved products count as relevant. I built a three-stage retrieve-and-rerank pipeline: reciprocal-rank fusion [2] of a fine-tuned dense retriever and BM25, a fine-tuned cross-encoder, and a second fine-tuned reranker on the top 30. All three models are trained only on the training dialogues, with hard negatives and soft positives labelled by the official judge. The pipeline reaches judged Recall@10 0.987 and MRR@10 0.911 on the public set (BM25: 0.865 and 0.689). In a second part I study how retrieval quality and the prompt shape the replies of a small generator.

What I did

What the data called for

Before choosing a model I explored the data and the judge. Finding the product type is easy: BM25’s first result already has the right top-level category 97.5% of the time. Ordering within the type is hard: the gold’s leaf category holds a median of 46 near-duplicates (same product, another size, flavour or brand), and the customer’s constraints are spread over several turns. The judge is strict, accepting only about 5% of the non-gold products, so ranking the gold first is what matters for MRR. Half of the public golds are products never seen in training.

Three stages

Pipeline diagram: the dialogue goes to a dense retriever and BM25, fused by RRF into a top 100, reranked by a fine-tuned gte reranker and then by a Qwen3 reranker on the top 30.

The submitted pipeline. z(⋅)z(\cdot) is a per-query z-score over the candidates, which puts the scores of different models on a common scale before they are fused.

The dense retriever (harrier-0.6B with LoRA) is trained with an in-batch contrastive loss over 64 dialogues and their hard negatives, 256 products per batch. GradCache [1] keeps the gradient of the full batch at the memory cost of 8 examples, which matters under the 8 GB limit:

L=−1B∑i=1Blog⁡exp⁡(scos⁡(qi,pi))∑d∈Cexp⁡(scos⁡(qi,d)),s=20.\mathcal{L} = -\frac{1}{B}\sum_{i=1}^{B}\log\frac{\exp\big(s\cos(\mathbf{q}_i,\mathbf{p}_i)\big)}{\sum_{d\in\mathcal{C}}\exp\big(s\cos(\mathbf{q}_i,\mathbf{d})\big)}, \qquad s = 20.

Both rerankers are trained with binary cross-entropy. To reuse one training loop for both, I turned Qwen3-Reranker, a language model that answers “yes” or “no”, into a one-logit classifier whose head is the difference of the two output rows; its scores stay identical.

Training data from the judge

For every training dialogue I mined the top 30 candidates with zero-shot models and labelled each one with the official judge, about 145k pairs (the TAs confirmed this is allowed, since it uses training data only). The gold is a positive; products the judge accepts become soft positives (label 0.5), never negatives; the rest are the pool of hard negatives. Every decision was taken on a validation split held out by gold product, and a change was kept only if it beat the 0.5-point noise floor of the judge without hurting any category.

Results

Final results (judged Recall@10 / MRR@10). Val: 543 held-out training dialogues, 50k products; public: 1,000 dialogues, 75k products.

SystemVal R@10Val MRR@10Public R@10Public MRR@10
BM25 baseline (mine)0.8600.6980.8650.689
Given baseline––0.9500.800
Submitted pipeline0.9850.9220.9870.911
Judged Recall@10 and MRR@10 on validation rising from BM25 to the final pipeline as each change is added.

Judged validation metrics as each accepted change is added, from BM25 (left) to the submitted pipeline (right).

Gold Recall at K from 1 to 100 for zero-shot and fine-tuned retrievers.

Gold Recall@K of the first-stage retrievers on val. Zero-shot dense models lose to BM25; the fine-tuned retriever fused with BM25 reaches 99.3% at K = 100.

The pipeline runs the public set in 32 minutes on an RTX 4090 clocked down to match the grader’s RTX 3070, with 4.7 GB of GPU memory.

Findings

  • Zero-shot dense models lose to BM25: product search depends on literal brands, sizes and attributes. Fine-tuning fixes this (MRR .538 to .838) and was the largest single gain in candidate quality.
  • Mined hard negatives are essential: replacing them with random products costs 3.1 MRR points, because random products are trivially wrong and the model never learns the within-type distinctions.
  • Pointwise BCE beat LambdaLoss [3] by 1.6 MRR points, and how the judge-accepted alternatives are labelled mattered less than the noise floor.
  • Real data scales, synthetic data does not: doubling the real dialogues gives about +1.4 MRR each time, but four times as many synthetic dialogues from Qwen3-8B gave +0.1, so the submission uses none (Figure 4).
  • For generation, retrieval matters more than the prompt. The 1.5B generator recommends the first product in 80 to 90% of its replies whatever it says, so a better rank 1 raised relevant recommendations by 4 to 14 points for every prompt, and a short, concrete prompt gave the most faithful replies.
Judged Recall@10 and MRR@10 against the number of real training dialogues on a log axis, with the synthetic-data result as a star.

Learning curve of the first reranker on real dialogues, and the result with 6,959 added synthetic dialogues (star).

References

  1. L. Gao, Y. Zhang, J. Han and J. Callan. Scaling deep contrastive learning batch size under memory limited setup. RepL4NLP, 2021.
  2. G. V. Cormack, C. L. A. Clarke and S. Büttcher. Reciprocal rank fusion outperforms Condorcet and individual rank learning methods. SIGIR, 2009.
  3. X. Wang et al. The LambdaLoss framework for ranking metric optimization. CIKM, 2018.