Inferring a WhatsApp Message's Language From a Few Words

Last updated: November 29, 2026

Quick Overview

A language detector has priors English 60%, Spanish 30%, Portuguese 10%, and word likelihoods for "casa", "tarde", and "obrigado" under each language. Compute the posterior after seeing "casa tarde", then after the message also contains "obrigado", and discuss the naive Bayes assumption.

Meta
Statistics & Math
Machine Learning Engineer
Meta
November 29, 2026
Machine Learning Engineer
Technical Screen
Statistics & Math
Medium

0

0

0 solved


A language detector has priors English 60%, Spanish 30%, Portuguese 10%, and word likelihoods for "casa", "tarde", and "obrigado" under each language. Compute the posterior after seeing "casa tarde", then after the message also contains "obrigado", and discuss the naive Bayes assumption.

Meta products like WhatsApp and Facebook route translation and content review by language, often from very short texts. The interviewer wants a clean naive Bayes calculation in posterior form, awareness of numerical underflow, and a thoughtful critique of independence between words.

What the Interviewer Expects
  • Multiplies prior by per-word likelihoods under conditional independence
  • Normalizes correctly across the three languages
  • Shows how one strongly diagnostic word flips the posterior
  • Works in log space and mentions smoothing for unseen words
  • Critiques independence and discusses calibration
Key Topics to Cover
Naive Bayes
Likelihood products
Log-space computation
Laplace smoothing
Language identification
How to Approach This
  1. Define your hypotheses (H0 and H1) clearly before performing any test.
  2. Calculate required sample size BEFORE running an experiment, using power analysis.
  3. Remember the Central Limit Theorem: sample means become approximately normal with large n.
  4. Watch for Simpson's paradox. Always segment data by key dimensions.
  5. Distinguish between statistical significance and practical significance.
Possible Follow-up Questions
  • What do you do for a word never seen in Portuguese training data?
  • Why are naive Bayes posteriors often overconfident?
  • How would you use the user's country or keyboard setting as a prior?
  • Would character n-grams beat word likelihoods for very short messages?
Sharpen Your Skills on Codemia

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

Browse Statistics Questions
Sample Answer
Clarify

Priors: P(en)=0.6P(en)=0.6, P(es)=0.3P(es)=0.3, P(pt)=0.1P(pt)=0.1. Word likelihoods (per token):

wordenespt
casa0.0010.020.02
tarde0.0020.030.015
obrigado0.0...
Approach

Posterior is proportional to prior times the product of word likelihoods; normalize over languages. In code, sum log probabilities to avoid underflow on long messages....


Submit Your Answer
Markdown supported