How we improved multilingual search with few-shot LLM translations

Ceren Çoker Turan, Alexander Osipenko17 Dec 2024

Problem

Delivery Hero serves search from Berlin to 68 countries, in English, Spanish, Arabic, Turkish, Greek, Chinese, Thai and more. Queries mix dialects, several languages in one country, transliterated brand names, local abbreviations and typos. Classic machine translation (MT) handles these badly, so the search engine misses relevant products. The team also had almost no labeled Arabic queries to tune anything on.

Example from the article: the Arabic word "عيش" means bread in Egyptian Arabic but rice in Gulf Arabic, and "ماكدونالدز" and "ماك" both mean McDonald's.

Solution in brief

Translate each query into English with an LLM given a few examples of the hard cases (dialects, transliterations, typos). Fix the sampling parameters, run each query three times and keep the most frequent answer. Search then uses both the original query and its translation in Elasticsearch, and the translations also enrich the training data of the vector search.

Questions this case answers
  • How to match short user queries written in different dialects, scripts and spellings to one catalog when no labeled data exists and fine-tuning is too costly
  • How to make a generative model return stable, deterministic output for a high-volume query-normalization task
  • How to make search understand queries written in dialects, transliterations and with typos in many languages?
  • How to choose between machine translation and an LLM for translating search queries?

Tools and methods

  • Gemini — chosen translation model, close to ChatGPT in accuracy at lower cost
  • Few-shot prompting — a handful of edge-case examples instead of fine-tuning
  • Majority voting — three runs per query, most frequent output wins
  • Elasticsearch and vector search — hybrid retrieval over the query and its translations
Continue reading — it's free

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