Does asking for top-k logprobs add real compute cost per token, or only bytes on the wire?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Explain what happens at the model head when a caller requests top-k logprobs per token. Identify what is essentially free, what genuinely costs something, and how that cost scales with k and with streaming.
Logprobs are near-free on the GPU because the softmax already exists; the real cost is bytes on the wire, JSON serialization per token, and amplified streaming latency.
Imagine a chef who already chops twenty vegetables for every dish but only puts five on the plate. If you ask to see all twenty, the chopping work was already done; the only extra effort is wrapping the extras and shipping a heavier box to your table. That is what logprobs feel like at the model head. Every time the model picks the next word, it has already produced a probability score for every possible candidate word whether you ask for them or not. Pulling out the top few is a quick partial sort. What actually costs something is packing those extra (word, score) pairs into JSON for every single streamed word and sending a fatter package over the network. The bigger your k, the heavier each package, and on a word-by-word stream that adds up to real bandwidth and packaging time.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: softmax already exists + top-k is a free sort + payload grows linearly in k + streaming amplifies serialization + practical guidance on when to disable.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Saying logprobs cost extra GPU compute because the model has to 'compute probabilities for every token.' It already does. The softmax is part of every forward pass; logprobs are a free side effect.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.