1/16
Learn

A checker from Yes and No, the way the coding round asks

A PracHub report from an Anthropic coding round: the candidate got a helper that returns a token probability for each input in a batch, and had to build a binary classifier with it (1 report). Pointed at an answer and its source, that classifier is a hallucination check. This lesson's practice problem builds it, in three levels:

  1. yes_probability(logprob_yes, logprob_no) and classify(probs, threshold): a score from the checker's two tokens, and a decision from the score.
  2. best_threshold(probs, labels, min_precision): the threshold that sends the most supported answers while staying precise enough.
  3. ece(probs, labels) and fit_temperature(logits, labels, grid): how far the scores are from honest, and the one number that fixes them.
CallReturns
yes_probability(-1.2, -0.4)0.310
best_threshold on ten checked answers, at 95% precision0.91
ece of an overconfident checker0.088
fit_temperature on the same checker1.5, which brings the error to 0.047

The lesson follows the outdoor shop's assistant, which told a customer that returns take 60 days when its policy says 30: what hallucinations are, quotes checked in code, a checker's Yes and No, calibration, and asking several times. Seven steps end with a small task in the editor.