LLM & Transformer Fundamentals·Question 33 of 109Intermediate

What are logprobs, and what are they useful for in production systems?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

A logprob is the log of the probability the model assigned to a token - log softmax(z) - at a given step. APIs (e.g. OpenAI's logprobs/top_logprobs) can return, per output token, its logprob plus the top-k alternative tokens and theirs. They're the closest thing you get to the model's internal confidence, and they're free - no extra forward pass.

Full worked answer

A logprob is the log of the probability the model assigned to a token - log softmax(z) - at a given step. APIs (e.g. OpenAI's logprobs/top_logprobs) can return, per output token, its logprob plus the top-k alternative tokens and theirs. They're the closest thing you get to the model's internal confidence, and they're free - no extra forward pass.

Production uses:

  • Classification with confidence. Frame the task so the answer is a single token ("yes"/"no", "A" - "D"); the logprob is a confidence score. Route low-confidence cases to a bigger model, a human, or an abstention path. This is the cleanest way to get calibrated-ish scores out of an LLM classifier, and to set precision/recall thresholds like a normal ML system.
  • Hallucination/uncertainty heuristics. Low or entropy-spread logprobs on content-bearing spans (names, numbers, dates) flag likely fabrications. Not a guarantee - models can be confidently wrong - but a usable signal for triggering verification or citation checks.
  • Reranking and scoring. Score candidate completions, retrieval passages, or MCQ options by total/average logprob; perplexity of a document under the model is a fluency/anomaly signal (also used heavily in pretraining data filtering).
  • Evals. Perplexity-based evaluation; MCQ benchmarks (score each option, pick the max - the standard trick behind many benchmark harnesses) - cheaper and lower-variance than parsing generated answers.
  • Debugging. When output goes weird at a specific point, per-token logprobs show exactly where the model got uncertain, and top-k alternatives show what it almost did - invaluable for prompt debugging and for spotting tokenizer artifacts.
  • Distillation/data work. Soft targets for training smaller models; confidence-based filtering of synthetic data.

Going further: follow-up territory

Caveats a strong candidate raises: RLHF-tuned models are notoriously miscalibrated relative to base models (alignment sharpens distributions), so treat logprobs as relative signals, tune thresholds on your own data; sequence-level probability ≠ answer correctness (many phrasings share the same answer - its true probability is spread across paraphrases); and closed APIs may not expose logprobs on all endpoints/models, sometimes for distillation-prevention reasons (GPT-6 Astra, for example, returns none). Some providers now offer a purpose-built alternative for the classification use case: OpenAI's Decisions API, on gpt-6-luna only, returns a probability for yes/no predicates and a distribution over choices, without you reading token logprobs yourself.

What a good answer covers

  • A logprob is the log of the probability the model assigned to a token - log softmax(z) - at a given step
  • OpenAI's logprobs/top_logprobs) can return, per output token, its logprob plus the top-k alternative…
  • They're the closest thing you get to the model's internal confidence, and they're free - no extra…
  • Classification with confidence
  • Hallucination/uncertainty heuristics

Key terms: Classification with confidence · Hallucination/uncertainty heuristics · Reranking and scoring · Evals · Debugging · Distillation/data work

Interviewer follow-ups to expect

  1. Why does RLHF hurt calibration?

  2. Design a confidence-thresholded router using logprobs - what would you validate?

  3. Why is the probability of an answer not the same as the probability of a sequence?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep