Improving Multilingual Search with Few-Shot LLM Translations

delivery_hero · E-commerce · 2024 · 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: Multilingual marketplace search translation and hybrid retrieval

Delivery Hero needed a globally served search system to understand food and grocery queries across languages, dialects, transliterations, typos, and markets. Traditional machine translation and keyword search struggled with intent and contextual nuance, so the company needed more accurate LLM translations that could feed both Elastic Search and vector search without excessive cost, hallucination, or latency.

Constraints:

Architecture

Delivery Hero evaluates translation options, selects Gemini for the balance of accuracy and cost, and uses few-shot prompting to handle dialects, transliteration, spelling corrections, and context-aware translation. The prompt is tuned with deterministic parameters and a small curated set of edge cases; ChatGPT is used to generate initial Arabic examples when labeled data is scarce, and the model itself helps clarify prompt instructions. At runtime, each query is translated three times and the majority response is selected to reduce outliers. Translations are used in two retrieval paths: Elastic Search considers the original query plus translations, while Vector Search enriches training data with LLM-generated translations so regional variations and synonyms retrieve similar products.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  User_search_query["User search query"] --> Few_shot_Gemini_translation_prompt["Few-shot Gemini translation prompt"]
  Prompt_example_dataset["Prompt example dataset"] --> Few_shot_Gemini_translation_prompt
  ChatGPT_generated_samples["ChatGPT-generated samples"] --> Prompt_example_dataset
  Few_shot_Gemini_translation_prompt --> Gemini["Gemini"]
  Gemini --> Majority_voting["Majority voting"]
  Majority_voting --> LLM_generated_translation["LLM-generated translation"]
  User_search_query --> Elastic_Search["Elastic Search"]
  LLM_generated_translation --> Elastic_Search
  LLM_generated_translation --> Vector_Search_training_data["Vector Search training data"]
  Vector_Search_training_data --> Vector_Search["Vector Search"]
  Elastic_Search --> Hybrid_result_mixer["Hybrid result mixer"]
  Vector_Search --> Hybrid_result_mixer
  Hybrid_result_mixer --> Search_results["Search results"]
  Local_user_evaluators["Local user evaluators"] --> Offline_translation_evaluation["Offline translation evaluation"]
  Offline_translation_evaluation --> Model_selection["Model selection"]
  Model_selection --> Few_shot_Gemini_translation_prompt
  Search_results --> A_B_testing["A/B testing"]
  A_B_testing --> Talabat_and_Hungerstation_rollout["Talabat and Hungerstation rollout"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
User search query Food or grocery search text containing dialects, transliterations, typos, or language variation. Few-shot Gemini translation prompt, Elastic Search
Prompt example dataset Small set of edge cases covering transliteration, dialectal variation, misspellings, and food terms. Few-shot Gemini translation prompt, ChatGPT-generated samples
ChatGPT-generated samples Bootstraps candidate Arabic query examples when labeled data is scarce. Prompt example dataset
Few-shot Gemini translation prompt Context-aware translation prompt configured for deterministic Arabic-to-English search translations. User search query, Prompt example dataset, Majority voting
Gemini Preferred production translation model balancing cost and accuracy. Few-shot Gemini translation prompt, Majority voting
Majority voting Runs the translation three times and selects the most frequent response. Gemini, LLM-generated translation
LLM-generated translation Context-aware normalized translation used by search systems. Elastic Search, Vector Search training data
Elastic Search Existing core search infrastructure that retrieves using original queries and translations. User search query, LLM-generated translation, Hybrid result mixer
Vector Search training data Training/enrichment data augmented with LLM translations for spelling, dialect, and synonym handling. LLM-generated translation, Vector Search
Vector Search Retrieves semantically similar products when vectors are fine-tuned with translated variants. Vector Search training data, Hybrid result mixer
Hybrid result mixer Combines results retrieved from Elastic Search and Vector Search. Elastic Search, Vector Search, Search results
Local user evaluators Validate whether translations capture Arabic user intent. Offline translation evaluation
Offline translation evaluation Compares translation systems on popular queries and validates top-query translations. Local user evaluators, Model selection
Model selection Compares Google Translate, DeepL, ChatGPT-Turbo, and Gemini across accuracy/cost tradeoffs. Offline translation evaluation, Few-shot Gemini translation prompt
A/B testing Measures search-query-level engagement changes before rollout. Search results, Talabat and Hungerstation rollout
Talabat and Hungerstation rollout Production deployment targets in Arabic-speaking markets. A/B testing

Data flow

A user search query enters the multilingual search system. The few-shot Gemini translation prompt handles dialect, typo, transliteration, and regional context; the system runs the query three times and selects the most frequent translation. Elastic Search then retrieves using the original query and available translations, while Vector Search uses LLM-generated translations in its enriched training data to retrieve semantically similar products. Evaluation happens both offline, with local users validating translations for the top 1,000 queries from nine Arabic-speaking countries, and online through A/B tests at the search-query level.

3 supporting quotes
“Using few-shot learning enables the LLM to understand context better, recognize regional language variations, and correct typos”article, stated
“we ran each query through the model three times and selected the most frequent response as the final translation.”article, stated
“we enhance retrieval by considering the original query and its translations (if available).”article, stated

Why this architecture

The architecture keeps mature search systems in place and uses LLM translation as an augmentation layer. Gemini was chosen over ChatGPT-Turbo because it was cheaper with acceptable accuracy, few-shot prompting avoided expensive fine-tuning, majority voting reduced unreliable outputs, and the translations improved both Elastic Search recall and vector-search semantic equivalence.

3 supporting quotes
“Because of Gemini’s good balance of performance and cost, we prefer Gemini over ChatGPT for our multilingual search needs.”article, stated
“Instead, we use few-shot learning by providing a small number of example queries and translations to guide the model.”article, stated
“we are transitioning to a Hybrid Search approach, where search results are retrieved from both ES and a Vector Search database, and the results are mixed.”article, stated

Models used: Gemini · ChatGPT-Turbo · Google Translate · DeepL · ChatGPT for sample query generation

Scale

— article, stated

Alternatives considered (roads not taken)

Traditional machine translation

Rejected because: It frequently missed intent, typos, dialects, and context-specific meaning.

“Traditional machine translation systems often struggle with user intent and contextual nuances, leading to inaccurate results.”article, stated
“machine translation (MT) can overcome language barriers, it frequently fails when understanding the nuances of user intent, spelling mistakes, and dialects.”article, stated

ChatGPT-Turbo for production translation

Rejected because: It was the most accurate in the test but too expensive relative to Gemini.

“While ChatGPT-Turbo provides the most accurate translations (86% accuracy), it is also more expensive.”article, stated
“Because of Gemini’s good balance of performance and cost, we prefer Gemini over ChatGPT for our multilingual search needs.”article, stated

Fine-tune a model

Rejected because: Fine-tuning was not feasible with a large/diverse dataset and limited labeled data.

“While fine-tuning a model could improve performance, it’s not always feasible—especially with a large and diverse dataset.”article, stated
“Initially, we lacked labeled data for Arabic search queries, with only a few examples available.”article, stated

Add many few-shot examples

Rejected because: Too many examples caused hallucination and unnecessary token cost.

“adding too many examples caused the model to “hallucinate” (i.e., generate irrelevant or inaccurate responses), unnecessarily increasing the token count.”article, stated
“By providing only a small number of edge cases (e.g., transliterations, dialectal variations), we avoided this issue”article, stated

Replace search with LLM translation alone

Rejected because: The production system uses LLM translations to enhance existing Elastic Search and Vector Search pathways.

“Elastic Search (ES) has been the core of our search infrastructure for many years and continues to be a key part of our architecture.”article, stated
“we are transitioning to a Hybrid Search approach, where search results are retrieved from both ES and a Vector Search database, and the results are mixed.”article, stated

Patterns

rag-retrieval (retrieval)

LLM-generated translations expand search recall by feeding both Elastic Search and vector-search retrieval.

“we enhance retrieval by considering the original query and its translations (if available).”article, stated
“We enrich our training data by adding LLM-generated translations, enabling the system to handle different spellings, local dialects, and synonyms”article, stated

retrieval-ranking (retrieval)

The hybrid system mixes Elastic Search and vector-search results so equivalent queries retrieve similar products.

“search results are retrieved from both ES and a Vector Search database, and the results are mixed.”article, stated
“queries with similar meanings—despite different wording—are treated as equivalent, improving both the quality and recall of search results.”article, stated

prompt-chaining (workflow-orchestration)

Prompt examples, deterministic parameters, LLM-assisted prompt refinement, and majority voting form a multi-step translation workflow before search.

“we optimized the prompt to ensure the most confident translation.”article, stated
“We could fine-tune the prompt structure by prompting the model to clarify its understanding of our original instructions.”article, stated

eval-driven-development (quality)

Delivery Hero compared translation tools offline, used local evaluators for top queries, and ran query-level A/B tests before rollout.

“we compared Google Translate, DeepL, ChatGPT-Turbo, and Gemini (our preferred translation model) on 100 popular grocery-related search queries.”article, stated
“A/B testing at the search query level revealed positive improvements in user engagement.”article, stated

data-quality-loop (data)

The team generated and curated prompt/evaluation examples for Arabic dialects, misspellings, transliterations, and local food terms.

“we turned to ChatGPT to generate potential queries. By asking it to create sample queries that included standard dialects, misspellings, and transliterations related to food”article, stated
“By providing only a small number of edge cases (e.g., transliterations, dialectal variations), we avoided this issue”article, stated

latency-optimization (operations)

The prompt limits output tokens and example count to control token costs and response overhead.

“Max output tokens: Limited to 100 to avoid unnecessarily long or convoluted responses.”article, stated
“adding too many examples caused the model to “hallucinate” (i.e., generate irrelevant or inaccurate responses), unnecessarily increasing the token count.”article, stated

Tradeoffs

Model choice

Chose Gemini over ChatGPT-Turbo.

Rationale: ChatGPT-Turbo was more accurate in the sample, but Gemini had a better cost/performance balance for production search.

“While ChatGPT-Turbo provides the most accurate translations (86% accuracy), it is also more expensive.”article, stated
“Because of Gemini’s good balance of performance and cost, we prefer Gemini over ChatGPT for our multilingual search needs.”article, stated

Few-shot prompting

Chose small example set over fine-tuning on a large diverse dataset.

Rationale: Few-shot learning avoided infeasible fine-tuning while still guiding dialect, transliteration, and typo handling.

“While fine-tuning a model could improve performance, it’s not always feasible—especially with a large and diverse dataset.”article, stated
“Instead, we use few-shot learning by providing a small number of example queries and translations to guide the model.”article, stated

Reliability mechanism

Chose majority voting over three model calls over single translation call.

Rationale: The extra calls increase cost but filter out outlier translations and improve confidence.

“we ran each query through the model three times and selected the most frequent response as the final translation.”article, stated
“This method helped to filter out outliers and ensure a higher level of accuracy.”article, stated

Search integration

Chose hybrid Elastic Search plus Vector Search over LLM-only search replacement.

Rationale: Translations improve both the existing lexical retrieval path and the vector semantic path.

“Elastic Search (ES) has been the core of our search infrastructure for many years and continues to be a key part of our architecture.”article, stated
“we are transitioning to a Hybrid Search approach, where search results are retrieved from both ES and a Vector Search database, and the results are mixed.”article, stated

Gotchas (what bit them)

The same written query can mean different foods in different dialects.

Root cause: Regional Arabic variants map identical strings to different concepts such as bread versus rice.

Resolution: Use context-aware LLM translations that incorporate regional dialect information.

“in Egyptian Arabic, the word “عيش” means bread, but in Gulf Arabic, it means rice!”article, stated
“Context also enables LLMs to recognize regional language variations, ensuring more accurate translations based on the user’s location.”article, stated

Transliteration and abbreviations break literal search.

Root cause: Users write non-Latin names phonetically or use local shortcuts.

Resolution: Include transliteration edge cases in the few-shot prompt and LLM translation workflow.

“Arabic**, people might search for “McDonald’s” as “ماكدونالدز” (makdunaldiz).”article, stated
“The search engine needs to be smart enough to know that “ماكدونالدز” and “ماك” both mean McDonald’s!”article, stated

Few-shot prompts can become too large and less reliable.

Root cause: Too many examples caused hallucination and increased token count.

Resolution: Use only a small number of representative edge cases.

“adding too many examples caused the model to “hallucinate” (i.e., generate irrelevant or inaccurate responses), unnecessarily increasing the token count.”article, stated
“By providing only a small number of edge cases (e.g., transliterations, dialectal variations), we avoided this issue”article, stated

LLM translations can be creative but unreliable.

Root cause: Generative models sometimes produce outlier translations despite deterministic prompt tuning.

Resolution: Run each query three times and choose the most frequent translation.

“Given that LLMs can sometimes produce creative but unreliable responses, we ran each query through the model three times”article, stated
“This method helped to filter out outliers and ensure a higher level of accuracy.”article, stated

Translation quality must be judged by local meaning, not just dictionary equivalence.

Root cause: User intent depends on dialect, market, food domain, and local spelling conventions.

Resolution: Have local users evaluate translations from top queries in Arabic-speaking countries.

“The correct translations are collected from the local Arabic-speaking people.”article, stated
“local users then evaluated for accuracy.”article, stated

Evaluation

Delivery Hero compared Google Translate, DeepL, ChatGPT-Turbo, and Gemini on 100 popular grocery-related queries with correct translations from local Arabic speakers. It then translated the top 1,000 most popular queries from nine Arabic-speaking countries, had local users evaluate accuracy, and ran A/B tests at the search-query level before rolling out to Talabat and Hungerstation.

Metrics: 100 popular grocery-related search queries for initial comparison · ChatGPT-Turbo: 86% accuracy · Gemini: about 82% accuracy · commercial translation tools: generally under 80% accuracy · top 1,000 queries from nine Arabic-speaking countries · over 90% restaurant-translation accuracy · positive A/B test movement in user engagement

4 supporting quotes
“we compared Google Translate, DeepL, ChatGPT-Turbo, and Gemini (our preferred translation model) on 100 popular grocery-related search queries.”article, stated
“The correct translations are collected from the local Arabic-speaking people.”article, stated
“We translated the top 1,000 most popular queries from nine Arabic-speaking countries using a few-shot learning approach”article, stated
“A/B testing at the search query level revealed positive improvements in user engagement.”article, stated

Outcomes

The article gives strong architectural detail but limited quantitative A/B business metrics. The reported success should be treated as company-reported, with the key reusable pattern being LLM translation as an augmentation layer for hybrid search rather than a replacement for search infrastructure.

4 supporting quotes
“The results showed over 90% accuracy for restaurant-related translations.”article, stated
“A/B testing at the search query level revealed positive improvements in user engagement.”article, stated
“the translations are being produced for our lovely brands, Talabat and Hungerstation.”article, stated
“This multi-faceted approach helps improve recall by capturing a wider range of relevant results.”article, stated