Mid-level interview questionAsked at Google · interview write-up
Explain KL divergence for language models: which direction is which, what happens when supports don't match, and how it's used as a regulariser.
Model answer
KL(P‖Q) is the expected extra log-loss from using Q when data comes from P, and it's asymmetric. Cross-entropy training minimises forward KL from data to model, which punishes missing anything the data covers, so it's mass-covering; reverse KL is mode-seeking. If Q gives zero probability where P doesn't, KL is infinite. In RLHF, a penalty on KL from policy to reference keeps the policy close and limits reward hacking.
Practise the rest
35 Training questions, 492 in all, each with a model answer. Free.
More from Google interview questions.
More Training interview questions
- Implement masked cross-entropy in NumPy that stays numerically stable, with label smoothing and a temperature.
- Build a pipeline that finds math documents in web crawls and scores their quality.
- When would you use mean squared error versus cross-entropy? And what is LoRA?
- Explain Adam and its bias correction, and why AdamW decouples weight decay.
- Explain policy types in RL and modern policy-gradient methods such as TRPO, PPO and GAE, then compare linear attention and grouped-query attention.
- Predict whether an ad impression is clicked within 24 hours at a 0.7% positive rate, with high-cardinality IDs and delayed labels: how do you build and assess the model?