Safeguarding LLMs via Model-Agnostic Latent Safety Signals from Dark Knowledge
Organizations: UNC Chapel Hill · Kyung Hee University · AIM Intelligence · Yonsei University
Abstract
LLMs have advanced rapidly, raising growing concerns about their safety. Recent work has proposed approaches to detect and defend against attacks including defenses at decoding stage that leverage models' hidden states. However, existing decoding-stage defenses suffer from two limitations. First, they introduce a trade-off between safety and over-refusal, where strengthening safety degrades the model's helpfulness on benign queries. Second, many of these methods rely on internal hidden states and are thus restricted to specific architectures, incurring substantial overhead and limited generalization across models. To address these limitations, we introduce LADE (Latent Safety Signals for Defense), which leverages latent safety signals extracted by contrasting harmful and benign queries from dark knowledge (i.e., information carried by the output probability distribution beyond its argmax) in the first-token output probability distribution. Our key insight is that, beyond surface-level refusal tokens, the dark knowledge in the first-token distribution contains latent safety signals, defined as tokens whose probabilities differ sharply between harmful and benign queries. We show that these signals consistently align across LLMs, forming a model-agnostic direction that emerges from safety alignment. LADE consists of three components: (1) Extracting Latent Safety Signals from Dark Knowledge, which selects top-k safety-discriminative tokens from the first-token probability distribution; (2) Tokenizer Mapping, which maps these tokens across different tokenizers to enable model-agnostic application; and (3) kNN-based Discrimination, which classifies queries via a k-Nearest Neighbors search over the mapped tokens. Across diverse LLMs and benchmarks, LADE is robust against a wide range of jailbreak attacks and lowers attack success rates while maintaining a competitive safety-utility trade-off.
Figures & tables
| Model | Defense | Compliant Responses to Harmful Queries ( ) | Avg. ( ) | ||||
| AutoDAN | DeepInception | GCG | PAIR | LIAR | |||
| Llama-2-7B-Chat | No Defense | 4 | 23 | 1 | 3 | 3 | 6.80 |
| Self-Reminder | 0 | 0 | 0 | 0 | 0 | 0.00 | |
| SafeDecoding | 0 | 0 | 0 | 0 | 0 | 0.00 | |
| SafeInfer | 1 | 14 | 0 | 1 | 0 | 3.20 | |
| RDS | 9 | 30 | 6 | 13 | 4 | 12.40 | |
| Model | Method | Compliance on Harmful Queries ( ) | Refusal on Benign Queries ( ) | Held-out Avg. ( ) | |||||
| AdvBench | Hex-Phi † | StrongReject | MMLU | Alpaca | GSM8K | XSTest † | |||
| Llama-2-7B-Chat | No Defense | 102 | 2 | 8 | 1 | 10 | 0 | 17 | 24.20 |
| Self-Reminder | 0 | 0 | 0 | 372 | 270 | 22 | 130 | 132.80 | |
| SafeDecoding | 8 | 0 | 0 | 393 | 323 | 223 | 211 | 189.40 | |
| SafeInfer | 0 | 0 | 0 | 52 | 17 | 1 | 122 | 14.00 | |
| RDS | 0 | 4 | 0 | 6 | 19 | 0 | 87 | 5.00 | |
| Method | Harmful Queries | Jailbreak Attacks | Benign Queries | Held-out Avg. | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AdvBench | Hex-Phi † | SR | AutoDAN | DI | GCG | LIAR | PAIR | MMLU | Alpaca | GSM8K | XSTest † | ||
| Prompt-Guard-2-86M | 0.481 | 0.110 | 0.090 | 0.727 | 0.420 | 0.613 | 0.137 | 0.280 | 1.000 | 0.999 | 1.000 | 1.000 | 0.575 |
| Llama-Guard-4-12B | 0.931 | 0.933 | 0.914 | 0.730 | 0.900 | 0.917 | 0.865 | 0.297 | 0.966 | 0.998 | 0.998 | 0.928 | 0.852 |
| WildGuard-7B | 0.998 | 0.987 | 0.990 | 0.980 | 1.000 | 0.997 | 1.000 | 0.553 | 0.960 | 0.996 | 1.000 | 0.992 | 0.947 |
| LADE | 0.962 | 0.877 | 0.971 | 0.980 | 1.000 | 1.000 | 1.000 | 0.780 | 1.000 | 0.996 | 1.000 | 0.932 | 0.969 |
| Method | Latency per input (ms) ( ) | Memory (GiB) ( ) |
|---|---|---|
| Prompt-Guard-2-86M | 15.48 | |
| Llama-Guard-4-12B | 37.31 | |
| WildGuard-7B | 28.46 | |
| LADE | 14.96 |
| Model | Harmful Queries | Benign Queries | Avg. | |||||
|---|---|---|---|---|---|---|---|---|
| AdvBench | Hex-Phi | StrongReject | MMLU | Alpaca | GSM8K | XSTest | ||
| Gemma-7B | 0.0000 | 0.9400 | 0.8019 | 1.0000 | 0.6600 | 0.9940 | 0.3896 | 0.6836 |
| Gemma-7B-it | 0.9058 | 0.8700 | 0.9457 | 1.0000 | 1.0000 | 1.0000 | 0.8554 | 0.9396 |
| Gemma-2-9B-it | 0.9808 | 0.9100 | 0.7668 | 1.0000 | 0.9900 | 1.0000 | 0.9839 | 0.9474 |
| Gemma-3-4B-it | 0.9808 | 0.8833 | 0.9489 | 1.0000 | 0.9960 | 1.0000 | 0.9438 | 0.9647 |
| First | Second | Third | Accuracy |
|---|---|---|---|
| ✓ | ✗ | ✗ | 0.9657 |
| ✗ | ✓ | ✗ | 0.9222 |
| ✗ | ✗ | ✓ | 0.8449 |
| ✓ | ✓ | ✗ | 0.9651 |
| ✓ | ✓ | ✓ | 0.9523 |
Appendix figures & tables17 assets
Supplementary material from the paper’s appendix.
Appendix
| Top- | 1 | 10 | 50 | 100 | 500 | 1000 |
|---|---|---|---|---|---|---|
| Accuracy | 0.4505 | 0.8867 | 0.9401 | 0.9611 | 0.9657 | 0.9596 |
| Harmful Set | Benign Set | |||
|---|---|---|---|---|
| Alpaca | GSM8K | MMLU | XSTest | |
| AdvBench | 0.9349 | 0.9259 | 0.9268 | 0.9552 |
| Hex-Phi | 0.9423 | 0.9309 | 0.9317 | 0.9660 |
| StrongReject | 0.9379 | 0.9317 | 0.9325 | 0.9627 |
| Harmful Reference Set | Accuracy |
|---|---|
| AdvBench | 0.9299 |
| StrongReject | 0.9488 |
| Hex-Phi | 0.9657 |
| Threshold Quantile | Accuracy |
|---|---|
| 0.85 | 0.9330 |
| 0.88 | 0.9411 |
| 0.90 | 0.9657 |
| 0.93 | 0.9403 |
| 0.95 | 0.9191 |
| 0.97 | 0.8847 |
| Duplicate mapping statistic | Avg. accuracy |
|---|---|
| No ratio estimation | 0.9649 |
| Harmful-side mean | 0.9655 |
| Benign-side mean (ours) | 0.9660 |
| Overlap of | Harmful ( ) | Benign ( ) | |
|---|---|---|---|
| 87.8% | 96.52% | 0.13% | |
| 93.6% | 96.52% | 0.13% | |
| (observed) | 100.0% | 96.52% | 0.13% |
| 95.0% | 96.64% | 0.13% |
| Target Model | AdvBench | Hex-Phi | StrongReject | Avg. |
|---|---|---|---|---|
| Llama-2-7B-Chat | 1.0000 | 0.9933 | 1.0000 | 0.9978 |
| Llama-3-8B-Instruct | 1.0000 | 1.0000 | 1.0000 | 1.0000 |
| Qwen2-7B-Instruct | 1.0000 | 0.9967 | 0.9936 | 0.9968 |
| Qwen3-8B | 1.0000 | 1.0000 | 1.0000 | 1.0000 |
| Gemma-7B-it | 1.0000 | 0.9967 | 0.9968 | 0.9978 |
| Mistral-7B-Instruct-v0.3 | 1.0000 | 1.0000 | 1.0000 | 1.0000 |
| Method | GCG ( ) | Adaptive attack ( ) |
|---|---|---|
| Prompt-Guard-2-86M Meta AI (2025b) | 0.613 | 0.000 |
| Llama-Guard-4-12B Meta AI (2025a) | 0.917 | 0.000 |
| Llama-Guard-3-8B Meta AI (2024) | 1.000 | 0.020 |
| WildGuard-7B Han et al. (2024) | 0.997 | 0.220 |
| LADE | 1.000 | 0.480 |
| Method | AutoDAN ( ) | Harmful ( ) | Benign ( ) |
|---|---|---|---|
| LADE | 42.00% | 92.67% | 2.22% |
| LADE with evasion reference set | 93.50% | 94.59% | 5.42% |
| Target Model | JBB ( ) | Security ( ) | Medical ( ) | Legal ( ) |
|---|---|---|---|---|
| Llama-2-7B-Chat | 2.00 | 0.00 | 3.10 | 1.22 |
| Llama-3-8B-Instruct | 1.00 | 0.00 | 3.90 | 0.94 |
| Qwen2-7B-Instruct | 22.00 | 8.80 | 13.70 | 1.22 |
| Qwen3-8B | 9.00 | 12.13 | 4.50 | 0.47 |
| Gemma-7B-it | 9.00 | 0.00 | 8.40 | 0.38 |
| Mistral-7B-Instruct-v0.3 | 28.00 | 10.13 | 12.80 | 6.30 |
| Model | Method | Harmful Avg. ( ) | Benign Avg. ( ) | Full Avg. ( ) | Held-out Avg. ( ) |
|---|---|---|---|---|---|
| Llama-2-7B-Chat | No Defense | 37.33 | 7.00 | 20.00 | 24.20 |
| Self-Reminder | 0.00 | 198.50 | 113.43 | 132.80 | |
| SafeDecoding | 2.67 | 287.50 | 165.43 | 189.40 | |
| SafeInfer | 0.00 | 48.00 | 27.43 | 14.00 | |
| RDS | 1.33 | 28.00 | 16.57 | 5.00 | |
| LADE | 1.33 | 14.50 | 8.86 | 1.60 |
| Model | AdvBench | Hex-Phi † | StrongReject | MMLU | Alpaca | GSM8K | XSTest † | Held-out Avg. ( ) |
|---|---|---|---|---|---|---|---|---|
| Beaver-v3 | 0 | 13 | 2 | 0 | 19 | 2 | 21 | 4.60 |
| ThinkSafe-Qwen3-8B | 0 | 0 | 1 | 0 | 8 | 0 | 5 | 1.80 |
| Judge | Compliance judgment (%) | Refusal detection (%) |
|---|---|---|
| HarmBench-Llama-2-13B | 84.80 | 94.44 |
| WildGuard-7B | 91.22 | 95.03 |
| Granite-Guardian-4.1-8B | 90.54 | 94.31 |
| Harmful ( ) | Benign ( ) | Balanced accuracy ( ) | Observed signals | |
|---|---|---|---|---|
| 5 | 2,339/2,499 (93.60%) | 113/4,500 (2.51%) | 95.54% | 3.18 |
| 10 | 2,347/2,499 (93.92%) | 104/4,500 (2.31%) | 95.80% | 5.95 |
| 20 | 2,347/2,499 (93.92%) | 104/4,500 (2.31%) | 95.80% | 11.14 |
| Full | 2,347/2,499 (93.92%) | 105/4,500 (2.33%) | 95.79% | 463.33 |
| Refusal String |
|---|
| I’m sorry |
| I am sorry |
| Sorry |
| I apologize |
| As an |
| As an AI |
| Model | Harmful ( ) | Benign ( ) | Accuracy ( ) |
|---|---|---|---|
| Mistral-7B-Instruct-v0.3 | 95.79% | 38.86% | 0.7599 |
| Qwen2-7B-Instruct | 93.94% | 45.83% | 0.7121 |
| Qwen3-8B | 93.20% | 6.96% | 0.9311 |
| Refusal Strings |
| "I’m sorry" , "Sorry" , "an AI" , "is illegal and unethical" , "I’m really sorry" , "My purpose" , "As a helpful assistant" , "OpenAI" , "unethical" , "positive and uplifting" , "against ethical guidelines" , "not ethical" , "legally" , "illegal" , "My apologies" , "legal ways" , "but I cannot" , "If you have any other non-malicious requests" , "I’m not able to provide" , "I cannot engage" , "I cannot generate" , "I do not generate" , "I cannot create" , "I do not actually" , "a bit unclear" , "I can’t create" , "I cannot support" , "I can’t provide" , "I’m truly sorry" , "I cannot provide" , "I’d prefer not" , "I do not provide" , "I cannot recommend" , "I do not recommend" , "I do not feel comfortable" , "I can’t assist" , "Absolutely not!" , "here’s an alternative" , "here’s a different" , "I cannot assist" , "I will refrain" , "I apologize" , "I will not" , "awesome coffee" , "creativity" , "promote well-being" , "positivity" , "harm reduction" , "self-care" |