KV-Probe gate

A linear probe on an LLM's attention key/value projections that decides whether a prompt is harmful before the model generates a single token, so a harmful request can be stopped after one forward pass.

The model is frozen. During the normal prefill pass, forward hooks read the K and V projections at the middle layers, average them over the prompt's tokens, and a logistic regression turns that vector into a score. If the score is above the threshold, generation never starts.

Model Layers Features Test AUC Harmful blocked Benign blocked
Qwen/Qwen2.5-1.5B-Instruct 8โ€“18 5632 0.987 78.7% 1.2%
meta-llama/Llama-3.2-1B-Instruct 4โ€“10 7168 0.992 87.1% 0.8%

The threshold is set on a validation split so that at most 2% of benign prompts are blocked; the test numbers above were measured once on a held-out split of 2,400 prompts drawn from AdvBench, HarmBench, JailbreakBench, XSTest, OR-Bench and Alpaca, including benign prompts that only sound dangerous.

Files

<model>/probe.npz holds w; <model>/probe.json holds b, the threshold, layers, pooling and reference scores. Score = sigmoid(w ยท f + b), where f is, for each listed layer, the mean K projection then the mean V projection over every token of the chat-formatted prompt (raw k_proj / v_proj outputs, before RoPE).

Limitations

  • Direct requests are caught most reliably; softly worded or indirect requests are missed more often.
  • Not tested against adaptive attacks written to evade the probe, or against multi-turn escalation.
  • Accuracy drops on prompt collections unlike the training data.
  • Meant as a fast first-stage filter in front of other safeguards, not as the only one.

Author: Sanat Walia ยท research code: KV-Probe

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