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.
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
How to Approach This
- Start by mapping the business objective to a concrete ML objective and metric.
- Cover the full pipeline: data collection, feature engineering, model selection, training, serving.
- Discuss online vs offline evaluation. Plan an A/B test to validate real-world impact.
- Address the serving latency budget and whether batch or real-time inference is needed.
- 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 ProblemsSample 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...