atlas

Research map / Large language models / Language, safety and interpretability

SafeInfer: Context Adaptive Decoding Time Safety Alignment for Large Language Models

AAAI 2025 · Large language models › Language, safety and interpretability · approach: Safety alignment of LLMs · 3 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes SafeInfer, a decoding-time safety alignment method combining a safety amplification vector injected into hidden states from safe demonstrations with a safety-guided decoding step that contrasts against a harmful-finetuned model, and introduces the HarmEval benchmark.

Problem

Safety-aligned LLMs have fragile safety mechanisms that can be broken by jailbreaks, and model editing for knowledge updates can further compromise safety; existing decoding-time defenses trade off safety against over-refusal and utility.

Approach

Couples activation engineering (adding a safety vector built from attention-head activations on safe demonstrations into a middle layer) with controlled-text-generation style decoding that subtracts a union-combined distribution from a harmful-finetuned model, applied at decoding time without retraining the target model.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Combine safety amplification with safety-guided decodingLlama-2 · DangerousQA, AdvBench, HEx-PHI, NicheHazardQA, TechHazardQA, and HarmEval (simple prompt)ASR (%): 12.50 -> 3.00; 20.00 -> 2.69; 49.09 -> 3.64; 31.55 -> 1.94; 43.00 -> 6.14; 21.63 -> 1.09Helped
Remove safety-guided decoding (use safety amplification alone) (ablation)SafeInfer on Llama-2 · DangerousQA and AdvBench (simple prompt)ASR (%): 3.00 -> 4.00; 2.69 -> 14.62Hurt
Remove safety amplification (use safety-guided decoding alone) (ablation)SafeInfer on Llama-2 · DangerousQA and AdvBench (simple prompt)ASR (%): 3.00 -> 5.50; 2.69 -> 1.92Hurt
Combine safety amplification with safety-guided decodingLlama-2 · TechHazardQA (instruction-centric and instruction-centric CoT)ASR (%): 87.71 -> 16.57; 88.57 -> 14.85Helped
Combine safety amplification with safety-guided decodingMistral · TechHazardQA (instruction-centric and instruction-centric CoT)ASR (%): 57.86 -> 46.28; 49.28 -> 34.85Helped
Apply SafeInfer after ROME model editingEdited Llama-2 · TechHazardQA (instruction prompt)ASR (%): 88.29 -> 23.71Helped
Apply SafeInferLlama-2 · XSTestover-safety rate (%): 17.83 -> 20.09Hurt
Apply SafeInferLlama-2 · MMLUscore: 46.90 -> 46.47No clear effect
Apply SafeInferLlama-2 · TruthfulQA (MC1, MC2)score: 0.298, 0.451 -> 0.390, 0.582Helped
Apply SafeInferLlama-2 · GSM8Kscore: 22.29 -> 22.07Hurt
Apply SafeInferLlama-2 · ARCscore: 0.416 -> 0.416No clear effect
Vary the safety-amplification coefficient gamma below 0.5 (ablation)SafeInfer on Llama-2 · Safety evaluationASRNo clear effect

Surprising findings

Limitations

Experimental setup

Datasets: DangerousQA AdvBench HEx-PHI NicheHazardQA TechHazardQA HarmEval XSTest MMLU TruthfulQA ARC OKTest GSM8K

Benchmarks: DangerousQA AdvBench HEx-PHI NicheHazardQA TechHazardQA HarmEval GCG AutoDAN PAIR DeepInception GPTFuzzer XSTest

Metrics: attack success rate over-safety rate accuracy

Baselines: SafeDecoding Self-CD SA (safety amplification only) sGDS (decoding only)

Builds on: SafeDecoding Self-CD ROME in-context vectors (activation patching) controlled text generation (union operator)

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy