LearnQuestion bank

You have a helper that returns token log-probabilities from an LLM for a batch of prompts. Build a binary classifier on top of it: write the prompt, turn log-probs into a calibrated score rather than a hard label, then improve it.

Applied LLMCodingMedium

Answer it yourself first, out loud or on paper, then compare.

Answer

Model answer, written in a candidate's voice

In short

  • Prompt asks for exactly one label token; verify tokenisation/casing and use few-shot examples only if they help.
  • Score is softmax over the label tokens’ first-token log-probs, renormalised, not argmax or raw log-prob.
  • Choose threshold on a labelled validation set for the target precision/recall; check reliability curve and recalibrate if needed.
  • Improve by trying label-token variants, prompt wording, few-shot examples, ensembling prompts/samples, and an abstain/other class for mass outside labels.
  • Batch requests, retry/timeout, and treat missing or failed logprobs as unknown/abstain rather than silently negative.

In full

I would make the prompt end with a strict instruction like “Answer with exactly one token: Yes or No,” then verify that “Yes” and “No” are single tokens in the model’s tokeniser (including leading spaces and casing), adding few-shot examples only if they improve validation behaviour. The classifier score is softmax over those label tokens’ first-token log-probabilities, renormalised so the two label probabilities sum to 1, rather than a raw log-prob or an argmax string; if the labels are not single tokens, I would use constrained decoding or sequence-level scoring instead of pretending they are. I would pick the decision threshold on a labelled validation set to hit the target precision/recall, then plot a reliability curve and apply temperature scaling or isotonic calibration if the probabilities are miscalibrated. To improve it, I would compare label-token choices (“Yes/No” vs “yes/no” vs “positive/negative”), prompt wording, few-shot examples, and averaged probabilities across multiple prompts or samples, while explicitly handling mass outside the label tokens with an abstain/other class or low-confidence rejection. In code I would batch prompts, set timeouts/retries, and mark missing logprobs or failed calls as unknown/abstain rather than silently treating them as negative, keeping the validation/test split clean so the threshold and calibration are not tuned on test data.

Corrected by an independent AI reviewer.

What a strong answer covers

  • Prompt constrains the answer to single label tokens (watch tokenisation: leading spaces, casing); few-shot if helpful
  • Score = softmax over the label tokens’ log-probs (renormalised), not a raw log-prob or an argmax string
  • Threshold chosen on a labelled validation set for the target precision/recall; calibration check (reliability curve)
  • Improvements: prompt refinement, label-token choice, ensembling multiple prompts/samples, handling mass outside label tokens
  • Batching and error handling in the code

Common mistakes

  • Comparing un-normalised log-probs across labels
  • ignoring probability mass on other tokens