← Walmart Labs Interview Insights
I knew the surface-level answer but fumbled when they pushed on the interaction between temperature and top-p.
Start by explaining that randomness in LLM inference comes from the sampling strategy applied to the model's output logits. Then describe how temperature, top-k, and top-p modify the probability distribution, and contrast with greedy decoding which is deterministic. Use a concrete example to illustrate the effect of each parameter.
Pro tip: Mention that in production systems like Walmart Labs, you often need to balance creativity and consistency; for example, using temperature=0 for deterministic outputs in A/B tests, or top-p for diverse recommendations. Also note that even with greedy decoding, floating-point non-determinism can cause slight variations across runs.
Explain that LLMs output a probability distribution over the vocabulary at each step. Randomness is introduced when we sample from this distribution instead of always picking the most likely token.
Describe how temperature divides the logits before softmax. Lower temperature (e.g., 0.1) makes the distribution sharper (more deterministic), while higher temperature (e.g., 1.5) flattens it, increasing diversity.
Explain that top-k restricts sampling to the k most likely tokens, while top-p (nucleus) sampling restricts to the smallest set of tokens whose cumulative probability exceeds p. Both truncate the distribution to avoid unlikely tokens.
Contrast with greedy decoding, which always selects the token with the highest probability (argmax). This is deterministic (temperature effectively 0) and produces the same output for the same input, but can lead to repetitive or bland text.
Discuss when to use each method: greedy for tasks requiring consistency (e.g., factual QA), temperature for creative tasks, top-k/top-p for balancing coherence and diversity. Mention that these can be combined (e.g., temperature with top-p).
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.