How to Make an LLM Work for You: Product Matching on a Marketplace as an Example

Ivan Mordovets21 Nov 2024

Problem

A marketplace wants to find the same product at competitors. Its matcher is a cascade of image and text candidate models, a cross-encoder and a gradient-boosting final model. It still misses real matches in hard categories such as clothing. Duplicate listings of one product also get both 1 and 0 labels in training and mislead the models. The team wants higher recall at a fixed precision.

Example from the article: in clothing the size is written "S" in one listing and "46" in another, so the cascade rejects a true match.

Solution in brief

The cascade covers the catalog. Rejected pairs from problem categories get a second pass through a fine-tuned LLM. Mistral-Nemo 12B, tuned with QLoRA, adds about 30% more matches than were already found, and its multimodal version Pixtral raises that to 37%. Flash Attention, smart batching, a candidate threshold and half precision make the cascade over 8 times faster.

Questions this case answers
  • How to recover true matches that a cascade entity-matching pipeline rejects in categories with ambiguous attributes, without running an expensive model on the whole catalog
  • How to adapt a small open LLM to a pairwise identity-judgment task on non-English text with a modest GPU budget
  • How to measure and threshold an entity-matching pipeline end to end when only a small labeled sample exists
  • How to find the identical products of competitors in a marketplace assortment when the cascade matcher misses real matches in hard categories like clothing?

Tools and methods

  • QLoRA — fine-tunes Mistral-Nemo with frozen, int4-quantized weights
  • Mistral-Nemo 12B — compact LLM with native Russian support, the text judge
  • Pixtral — Mistral-Nemo plus a ViT image encoder, adds images
  • Llama-3.1 70B — zero-shot baseline, acceptable but not reliable
  • Flash Attention — faster self-attention through better use of GPU memory
  • Smart batching — sorts sequences by length to cut pad tokens
  • Recall at 90% precision — end-to-end matcher metric
Continue reading — it's free

Google or a one-time email code. No password.