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
November 29, 20260
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
How to Approach This
- Define your hypotheses (H0 and H1) clearly before performing any test.
- Calculate required sample size BEFORE running an experiment, using power analysis.
- Remember the Central Limit Theorem: sample means become approximately normal with large n.
- Watch for Simpson's paradox. Always segment data by key dimensions.
- 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 QuestionsSample Answer
Clarify
Priors: , , . Word likelihoods (per token):
| word | en | es | pt |
| casa | 0.001 | 0.02 | 0.02 |
| tarde | 0.002 | 0.03 | 0.015 |
| obrigado | 0.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....