Senior interview question
Your integration tests call a hosted model at temperature 0 and compare the output with an exact string. They fail now and then. What's going on, and what do you change?
Model answer
The test assumes a determinism a hosted API doesn't promise. Temperature 0 is greedy and uses no random numbers, and our sampling script gave byte-identical output across two runs, but on one machine. AI Engineering notes that even with temperature, top-p, top-k and seed fixed, hardware can change the output, and with an API the hardware is the provider's choice.
So stop asserting exact text from live calls: cache known answers where you need exact strings, or parse the output and compare fields, labels or structure. A seed won't fix it.
Practise the rest
9 Sampling questions, 492 in all, each with a model answer. Free.
More Sampling interview questions
- What are logits, and how does a model go from them to a whole sentence of output?
- Explain temperature, top-k and top-p. Why would you usually reach for top-p rather than a fixed k?
- Greedy decoding on a small model gives fluent text that soon repeats itself word for word. Why does that happen?
- A PM wants to show users a 'confidence' percentage computed from the answer's token probabilities. What's your position, and what would you build instead?
- Write beam search that returns each sentence with its probability. How does it differ from greedy decoding?
- Build a bigram next-word predictor that samples the next word in proportion to how often it followed.