Design Query Spelling Correction for a Search Engine

Last updated: November 29, 2026

Quick Overview

Design the ML system behind "Did you mean" and automatic query correction for web search, including candidate generation, scoring, and when to auto-correct versus only suggest.

Google
ML System Design
Machine Learning Engineer
Google
November 29, 2026
Machine Learning Engineer
System Design Round
ML System Design
Hard

0

0

0 solved


Design the ML system behind "Did you mean" and automatic query correction for web search, including candidate generation, scoring, and when to auto-correct versus only suggest.

Spelling correction is a signature Google Search feature that must work across languages, names, and new slang at search latency. Interviewers check the noisy channel framing, use of query logs, the confidence policy for auto-correction, and evaluation.

What the Interviewer Expects
  • Frame with a noisy channel model: P(intended) times P(typed given intended)
  • Generate candidates by edit distance, phonetics, and query-log rewrites
  • Score with a learned model using language model and context features
  • Define a three-way decision: auto-correct, suggest, or leave
  • Discuss evaluation, latency, and new-term handling
Key Topics to Cover
Noisy channel model
Edit distance
Query logs
Language models
Confidence thresholds
How to Approach This
  1. Start by mapping the business objective to a concrete ML objective and metric.
  2. Cover the full pipeline: data collection, feature engineering, model selection, training, serving.
  3. Discuss online vs offline evaluation. Plan an A/B test to validate real-world impact.
  4. Address the serving latency budget and whether batch or real-time inference is needed.
  5. Think about the data flywheel: how user feedback improves the model over time.
Possible Follow-up Questions
  • How do you avoid correcting a new product name that looks like a typo?
  • How would you handle queries mixing two languages?
  • How would you measure harm from a wrong auto-correction?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice ML System Design Problems
Sample Answer
Requirements

Input: raw query. Output: optional corrected query and a decision (replace results, show suggestion, or nothing). Latency budget about 10 ms. Must handle names, rare terms, many languages. Success: fe...

High-Level Design

Tokenize, then candidate generation per token and for the whole query, then a scorer, then a decision policy. Offline pipelines mine query logs and build a dictionary of terms with frequencies, an err...


Submit Your Answer
Markdown supported