Latent Instruction Representation Alignment: defending against jailbreaks, backdoors and undesired knowledge in LLMs
Organizations: ML Alignment & Theory Scholars Berkeley, CA, USA · OATML, Department of Computer Science University of Oxford, Oxford, UK
Abstract
We address jailbreaks, backdoors, and unlearning for large language models (LLMs). Unlike prior work, which trains LLMs based on their actions when given malign instructions, our method specifically trains the model to change how it interprets instructions. Our method, Latent Instruction Representation Alignment (LIRA), greatly improves generalization. We further boost generalization through an internally adversarial training algorithm. Our methods block over 99% of PEZ jailbreak attacks; remove a challenging insecure code backdoor; and achieve optimal forgetting on WMDP cyber with negligible loss of benign capabilities.
Figures & tables
| Task | Benign inst. ( ) | Malign inst. ( ) | Benign cf resp. ( ) | Stopping condition |
| Block jailbreak | Model-refused malign requests | Malign requests + defender-installed safety bypass | Malign request refusal | Fixed duration of batches |
| Remove backdoor | Ordinary question | Questions + defender-installed toy backdoor trigger | Ordinary answers | Validation backdoor removed |
| Unlearning | n.a. | Request requiring undesired knowledge | n.a. | Fixed duration of batches |
Appendix figures & tables11 assets
Supplementary material from the paper’s appendix.
Appendix
| Task | Benign CF prompts | Malign prompts | Benign prompts | Stopping condition |
| HATE backdoor | Ordinary Q&A questions | Q&A questions prefixed with a constructed trigger for backdoor behavior | Ordinary Q&A questions | HATE behavior removed in backdoor condition |
| Embedding space jailbreak attacks | Plain malign requests that elicit refusal | Malign requests prefixed with a constructed safety bypass | Benign request compliance and malign request refusal | Fixed duration of 25 batches |
| Code backdoor | Code generation prompts with 2024 system prompt | Code generation prompts with a constructed trigger for backdoor behavior | Code generation prompts with 2024 system prompt | Exploitable code behavior removed in constructed backdoor condition |
| Task | Malign metric definition | Benign metric definition |
| PEZ attacks | Rate at which attacker with 60 prefix or suffix tokens and 10 tries can force the model to comply with a harmful request. | Rate of improper refusals to benign requests. Tracks inappropriate generalization of refusal behavior from harmful to benign requests. |
| Embedding space attacks | Rate at which attacker with full control of embedding space can force model to comply with harmful requests. | Rate of improper refusals to benign requests. Tracks inappropriate generalization of refusal behavior from harmful to benign requests. |
| HATE backdoor | Rate at which model emits the word “HATE” when given a backdoor trigger. | — |
| Code backdoor | Rate at which model generates insecure, exploitable code when given a backdoor trigger. | Increased CE loss on benign, secure code without backdoor trigger. Tracks general degradation of coding capabilities. |
| WMDP cyber unlearning | Decreased accuracy on WMDP cyber multiple-choice questions covering dangerous cybersecurity knowledge. | Increased CE loss on free-response answers in the retain set covering benign computing info. Tracks degradation of associated benign knowledge because of insufficient targeting. |
| TOFU unlearning | Decreased accuracy on multiple-choice questions regarding forget set fictitious authors. | Increased CE loss on free-response answers covering retain set fictitious authors. Tracks degradation of associated benign knowledge because of insufficient targeting. |
| Task | Learning rate | Batch size | CF weight | Retain weight | Malleable layers | Duration |
| Embedding space attacks | 2e-3 | 256 | 1.0 | 1.0 | 14–27 | 25 steps |
| HATE backdoor | 1e-3 | 256 | 1.0 | 1.0 | All | 1 step |
| Code backdoor | 1e-3 | 32 | 1.0 | 1.0 | 14–27 | — |
| Task | Learning rate | Batch size | Search weight | Retain weight | Malleable layers | Align:attack phase pattern |
| Embedding space attacks | 2e-3 | 128 | 1.0 | 1.0 | 0–13 | 5:1 |
| Code backdoor | 1e-3 | 32 | 1.0 | 1.0 | 0–13 | 2:2 |
| Task | Classifier LR | Align LR | Batch size | Retain weight | # classifier layers | Malleable layers | Duration |
| WMDP cyber | 1e-3 | 1.5e-4 | 128 | 33.6 | 14 | 9–24 | While accuracy 38% |
| TOFU | 4.5e-4 | 4e-4 | 80 | 49.1 | 16 | 10–25 | While accuracy 18% |
| Task | Learning rate | Batch size | Reroute weight | Retain weight | Target layers | Duration |
| HATE backdoor | 3e-3 | 256 | 14 & 28 | 100 steps | ||
| Code backdoor | 3e-3 | 64 | 14 & 28 | 100 steps | ||
| Embedding space attacks | 2e-3 | 256 | 14 & 28 | 100 steps |
| Task | Learning rate | Batch size | Ascent weight | Descent weight | Duration |
| HATE backdoor | 2e-5 | 256 | 1.5 | 1.0 | 100 steps |
| Code backdoor | 1e-5 | 64 | 1.5 | 1.0 | 100 steps |
| Embedding space attacks | 2e-5 | 256 | 0.5 | 1.0 | 50 steps |
| WMDP cyber | 2e-5 | 64 | 0.5 | 1.0 | While retain CE 3.0 |
| TOFU | 2e-5 | 64 | 1.5 | 1.0 | While retain CE 3.5 |
| Task | Learning rate | Batch size | Forget weight | Retain weight | RV scale | Malleable layers | Duration |
| WMDP cyber | 7.9e-4 | 128 | 0.085 | 1.0 | 250 | 10–12 | While retain CE 3.0 |
| TOFU | 1e-3 | 128 | 0.075 | 1.0 | 330 | 10–12 | While retain CE 3.5 |
| Task | Method | Malign metric | Benign metric | MMLU |
| ES attacks | LIRA* | 18.1% ASR | 2.3% ben. refusal | -2.3% acc. |
| AdLIRA* | 9.6 % ASR | 3.1% ben. refusal | -5.9% acc. | |
| Gemma IT | 86.9% ASR | 0.0 % ben. refusal | +0.0 % acc. | |
| GD | 89.8% ASR | 6.2% ben. refusal | -0.7% acc. | |
| CB | 52.3% ASR | 3.1% ben. refusal | -3.6% acc. | |
| Code backdoor | AdLIRA* | -45.1 % insecure | +0.0 code CE | -5.3 % acc. |
| Task | Asset | License | Citation |
| All | Gemma 2 | Gemma Terms of Use | Gemma Team et al. (2024) |
| Embedding space jailbreaks, code backdoor, and WMDP cyber unlearning | Gemini 2.0 Flash | Gemini API Additional Terms of Service | Google (2024) |
| Embedding space jailbreaks | Circuit breakers dataset | MIT license | Zou et al. (2024) |
| Code backdoor | Cybernative.ai Code Vulnerability and Security Dataset | Apache 2.0 | Cybernative.ai (2024) |
| Hate backdoor | MFAQ dataset | Apache 2.0 | De Bruyn et al. (2021) |
| WMDP cyber unlearning | WMDP corpora and eval datasets | MIT license and MIT license | Li et al. (2024) |
Backdoor Defense in LLMs
Backdoor defense in large language models detects, removes, or contains trigger-activated behavior while preserving ordinary capabilities.
See all 42 papers