← Google Interview Insights

Google·Machine Learning Engineer·Onsite - System Design / Architecture·Senior

Senior
May 2026

Summary

Google ML engineer interview with a system design question on language detection. Pretty open-ended, which I wasn't fully prepared for.

Questions Asked (1)

Q1

Design a system that can automatically detect the language of a given piece of text.

System DesignTechnical Trade-offs
Author's notes

I jumped straight into n-gram models and character frequency distributions, which felt right, but I didn't think about scale until the interviewer nudged me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements such as the number of languages, input length, latency, and accuracy targets. Then propose a hybrid approach using character n-gram models for short texts and neural models for longer texts, and discuss trade-offs between accuracy, latency, and resource usage.

Pro tip: Emphasize the importance of handling code-switching and mixed-language texts, and suggest a confidence threshold to fall back to a more expensive model or human review when uncertain.

1. Clarify Requirements

Ask about the number of languages, typical text length, latency constraints, and required accuracy. This shapes the choice of model and infrastructure.

2. Propose Baseline Approach

Suggest a simple, fast method like character n-gram profiles with cosine similarity or a Naive Bayes classifier as a baseline for short texts.

3. Design Advanced Model

For higher accuracy, propose a neural approach such as a CNN/RNN over character embeddings or a fine-tuned transformer model like XLM-R.

4. Address Scalability and Trade-offs

Discuss serving infrastructure, model size, latency, and how to handle code-switching. Consider a cascade where a fast model handles easy cases and a complex model handles ambiguous ones.

5. Evaluate and Iterate

Define metrics (accuracy, F1, latency), plan for continuous evaluation, and mention handling of low-resource languages and domain adaptation.

Key Points to Mention

  • Character n-gram models are effective for short texts and low-resource languages.
  • Neural models like transformers (e.g., XLM-R) provide state-of-the-art accuracy but are heavier.
  • Trade-offs between latency, accuracy, and model size; consider a cascade or ensemble.
  • Handling code-switching and mixed-language inputs is a key challenge.
  • Use a confidence threshold to route uncertain cases to a more expensive model or human review.
  • Evaluation should include per-language metrics and consider domain shift.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.