The interview problem
A messaging product chooses spellcheck and translation tools from detected language. Design routing for short messages, names and code-switched sentences.
Original practice, not a reported company interview. All scenarios and worked numbers are illustrative. Interview date: not applicable. Sources retrieved September 30, 2026.
1. Scope and assumptions
Language identification is not translation. Allow unknown and mixed-language outputs; a user's locale is a prior, not proof of the text's language.
2. Worked approach
message → encoding/script checks → document/span scores → tool route or abstention
Normalize encoding while preserving meaningful script and punctuation. Use a lightweight document-level language classifier as a baseline, then a span-level classifier where enough text exists. Combine adjacent compatible spans and require a margin or calibrated confidence before switching tools.
Cache stable conversation preferences without overwriting per-message evidence. For a two-word name or code snippet, abstain or ask for user selection. Store user corrections as labeled feedback with context and avoid treating a dismissed suggestion as a known language label. Version the supported-language inventory so unsupported languages are not forced into the nearest class.
3. Calculate the example
On 1,000 test messages, suppose the system confidently routes 700 and gets 665 right. Selective accuracy is 665/700 = 95%, coverage is 70%, and confident wrong routing occurs on 35/1,000 = 3.5% of all messages. Reporting only 95% hides the 300 abstentions. If mixed messages contain 400 annotated tokens and 60 receive the wrong language label, token error is 15%; this is a separate metric from whole-message correctness.
4. Failure cases and trade-offs
A dominant-language model may confidently misclassify borrowed words or romanized text. Locale leakage makes offline accuracy optimistic. Tiny spans can lack enough evidence to identify any language reliably, regardless of model size.
One label per message is inexpensive but cannot represent code switching. Span labels offer detail at higher annotation and runtime cost. Routing both candidate tools may increase recall but produce conflicting edits; preserve the original text and prioritize user control.
5. Validate the result
Split by conversation and test short length, mixed scripts, unseen names and unsupported languages. Measure accuracy versus coverage, harmful autocorrections and switching frequency. Benchmark latency on the target device rather than a server only.
6. Interview follow-ups and self-review
Should an English product name change a Spanish sentence's route? How would user overrides persist?
Reward abstention, explicit mixed-language scope, disjoint metrics and protection against locale shortcuts.
Sources and related practice
Technical reference: fasttext.cc — Official pretrained language-identification baseline; span routing and examples are original.
Exact publication/update date not established in this review. Retrieved September 30, 2026. This reference supports the named technical concept; the proposed workflow and examples are original, not a documented vendor implementation or interview report.
Continue with Design cross-language enterprise retrieval; Adapt an AI workflow for a new customer language.
Continue your preparation
Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.