Know-When-You-Don't-Know

A linear probe on the last-prompt-token hidden state of Qwen/Qwen2.5-3B-Instruct that predicts, before any answer is generated, whether the model's greedy answer to a factual question will be wrong. When the risk score exceeds a frozen threshold, the system abstains.

Method

  • Probe input: hidden state at the last prompt token, hidden-state index 27 (of 37; index 0 is the embedding output), dimension 2048.
  • Label: y=1 if the greedy answer does not match any gold answer alias (wrong); y=0 if it does.
  • Model: standardization followed by logistic regression (C=0.001).
  • Selection: layer and C were chosen by validation AUROC over 37 hidden-state indices × 6 values of C. Validation AUROC (0.841) is therefore optimistic; the test and OOD numbers below are held out.
  • Threshold: the 70th percentile of validation risk (targeting 70% coverage), frozen before evaluating held-out data.
  • Evaluation sets: TriviaQA test (n=1000) and NQ-Open out-of-distribution (n=1000).

Results

95% confidence intervals for AUROC come from a bootstrap.

TriviaQA test

Scorer AUROC (95% CI) Base acc Acc@70% Realised cov Wrong caught
Probe 0.818 (0.793, 0.844) 0.397 0.530 0.675 0.488
−mean log-prob 0.826 (0.799, 0.852) 0.397 0.533 0.667 0.502
1 − max prob 0.786 (0.758, 0.814) 0.397 0.520 0.697 0.448

NQ-Open (out of distribution)

Scorer AUROC (95% CI) Base acc Acc@70% Realised cov Wrong caught
Probe 0.790 (0.756, 0.822) 0.191 0.263 0.440 0.645
−mean log-prob 0.785 (0.751, 0.822) 0.191 0.254 0.654 0.408
1 − max prob 0.734 (0.696, 0.772) 0.191 0.249 0.649 0.404

How to read the columns. Base acc is accuracy with no abstention. Acc@70% is accuracy on the 70% of questions the scorer ranks as lowest risk (rank-based, exactly 70% coverage). Realised cov and Wrong caught use the threshold frozen on TriviaQA validation data: the share of questions answered, and the share of wrong answers that were abstained on.

Summary

On TriviaQA test the probe's AUROC differs from the −mean log-prob baseline by -0.007 and from the 1 − max prob baseline by +0.033. On NQ-Open the differences are +0.005 and +0.057. Does the probe beat both baselines with a paired-bootstrap interval that excludes zero? TriviaQA test: no; NQ-Open: no.

The probe's practical advantage is timing, not accuracy: it needs only the question, so abstention can happen before spending any generation. If the answer is generated anyway, mean log-prob ranks questions about as well.

Label heuristic

Labels come from string matching against gold aliases:

  • Answers and aliases are normalized (lowercase, strip articles, remove punctuation).
  • An answer is correct if it equals an alias, if an alias contains the answer as a whole-word span, or if the answer contains an alias as a whole-word span.
  • Aliases shorter than 2 characters after normalization are ignored.

Label noise runs in both directions. Valid paraphrases can be labelled wrong, and short answers can be labelled correct through partial matches with long aliases (for example, "Australia" matching an alias "Philosophy in Australia"). NQ-Open has far fewer gold aliases per question than TriviaQA, which inflates its wrong rate. The probe inherits all of this noise.

Usage

The probe expects the activation produced by the same prompt template used in training. This snippet is a sketch and has not been run in every environment; check it against your versions.

import json, joblib, torch
from huggingface_hub import hf_hub_download
from transformers import AutoModelForCausalLM, AutoTokenizer

REPO = "aijadugar/know-when-you-dont-know"
probe = joblib.load(hf_hub_download(REPO, "probe.joblib"))
meta = json.load(open(hf_hub_download(REPO, "probe_meta.json")))

tok = AutoTokenizer.from_pretrained(meta["model_id"])
model = AutoModelForCausalLM.from_pretrained(
    meta["model_id"], torch_dtype=torch.float16, device_map="auto"
).eval()

question = "Who wrote the novel The Da Vinci Code?"
prompt = tok.apply_chat_template(
    [{"role": "system", "content": meta["system_prompt"]},
     {"role": "user", "content": question}],
    tokenize=False, add_generation_prompt=True,
)
inputs = tok(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
    hidden = model(**inputs, output_hidden_states=True).hidden_states
h = hidden[meta["hidden_state_index"]][0, -1].float().cpu().numpy()

risk = probe.predict_proba(h.reshape(1, -1))[0, 1]
print("abstain" if risk > meta["threshold"] else "answer", round(float(risk), 3))

probe.joblib is a pickled scikit-learn pipeline. Load it only from a source you trust, and use a compatible scikit-learn version.

Limitations

  • Trained and evaluated on short-answer factual QA only (TriviaQA, NQ-Open).
  • One base model (Qwen/Qwen2.5-3B-Instruct) and one prompt template; a different prompt changes the activations.
  • The threshold was frozen on TriviaQA validation data and does not transfer: on NQ-Open the realised coverage was 0.440 against a 70% target (OOD AUROC gap to TriviaQA test: -0.028).
  • Label noise from the matching heuristic, in both directions (see above).
  • Layer and C were selected on one validation set from a single training run; no variance across seeds or data splits was measured.
  • The base model's license applies to use of its activations; check the Qwen/Qwen2.5-3B-Instruct model page.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for aijadugar/know-when-you-dont-know

Base model

Qwen/Qwen2.5-3B
Finetuned
(1,697)
this model

Collection including aijadugar/know-when-you-dont-know