Improving Large Language Model Safety with Contrastive Representation Learning
On the map: Mechanistic interpretability → Steering and probing for LLM safety
Abstract (arXiv)
Large Language Models (LLMs) are powerful tools with profound societal impacts, yet their ability to generate responses to diverse and uncontrolled inputs leaves them vulnerable to adversarial attacks. While existing defenses often struggle to generalize across varying attack types, recent advancements in representation engineering offer promising alternatives. In this work, we propose a defense framework that formulates model defense as a contrastive representation learning (CRL) problem. Our method finetunes a model using a triplet-based loss combined with adversarial hard negative mining to encourage separation between benign and harmful representations. Our experimental results across multiple models demonstrate that our approach outperforms prior representation engineering-based defenses, improving robustness against both input-level and embedding-space attacks without compromising standard performance. Our code is available at https://github.com/samuelsimko/crl-llm-defense
Key facts. Cited by 8 papers in the map (data through 14 Oct 2026). Placed in Steering and probing for LLM safety, one of 13 directions in Mechanistic interpretability. Builds on 55 of its 81 references that are in the map. First posted on arXiv 13 Jun 2025.
Builds on
55 of 81 references.
References · 55
- 2017Attention Is All You Needcited by 60,361
- 2014Adam: A Method for Stochastic Optimizationcited by 37,240
- 2021Learning Transferable Visual Models From Natural Language Supervisioncited by 33,744
- 2020A Simple Framework for Contrastive Learning of Visual Representationscited by 12,049
- 2021Training Verifiers to Solve Math Word Problemscited by 10,109
- 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,170
- 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 8,065
- 2020Measuring Massive Multitask Language Understandingcited by 7,963
- 2018Representation Learning with Contrastive Predictive Codingcited by 7,777
- 2018Think you have Solved Question Answering? Try ARC, the AI2 Reasoning Challengecited by 4,886
- 2013Efficient Estimation of Word Representations in Vector Spacecited by 4,375
- 2019HellaSwag: Can a Machine Really Finish Your Sentence?cited by 4,100
38 more
- 2022Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedbackcited by 3,720
- 2021TruthfulQA: Measuring How Models Mimic Human Falsehoodscited by 2,975
- 2015FaceNet: A Unified Embedding for Face Recognition and Clusteringcited by 2,849
- 2020Supervised Contrastive Learningcited by 2,829
- 2020Learning to summarize from human feedbackcited by 2,588
- 2024HarmBench: A Standardized Evaluation Framework for Automated Red Teaming and Robust Refusalcited by 1,429
- 2023Jailbreaking Black Box Large Language Models in Twenty Queriescited by 1,420
- 2024Refusal in Language Models Is Mediated by a Single Directioncited by 1,032
- 2023A General Theoretical Paradigm to Understand Learning from Human Preferencescited by 912
- 2023Enhancing Chat Language Models by Scaling High-quality Instructional Conversationscited by 839
- 2023Baseline Defenses for Adversarial Attacks Against Aligned Language Modelscited by 651
- 2020Contrastive Learning with Hard Negative Samplescited by 628
- 2024How Johnny Can Persuade LLMs to Jailbreak Them: Rethinking Persuasion to Challenge AI Safety by Humanizing LLMscited by 573
- 2024Large Language Models: A Surveycited by 525
- 2023Zephyr: Direct Distillation of LM Alignmentcited by 506
- 2024Negative Preference Optimization: From Catastrophic Collapse to Effective Unlearningcited by 504
- 2024WildGuard: Open One-Stop Moderation Tools for Safety Risks, Jailbreaks, and Refusals of LLMscited by 496
- 2024Jailbreaking Leading Safety-Aligned LLMs with Simple Adaptive Attackscited by 486
- 2023SmoothLLM: Defending Large Language Models Against Jailbreaking Attackscited by 469
- 2023GPT-4 Is Too Smart To Be Safe: Stealthy Chat with LLMs via Ciphercited by 423
- 2023Toxicity in ChatGPT: Analyzing Persona-assigned Language Modelscited by 360
- 2020Keystroke Dynamics as Part of Lifeloggingcited by 334
- 2024Improving Alignment and Robustness with Circuit Breakerscited by 322
- 2023A Survey of Reinforcement Learning from Human Feedbackcited by 264
- 2024WildTeaming at Scale: From In-the-Wild Jailbreaks to (Adversarially) Safer Language Modelscited by 223
- 2024Latent Adversarial Training Improves Robustness to Persistent Harmful Behaviors in LLMscited by 173
- 2024AutoDefense: Multi-Agent LLM Defense against Jailbreak Attackscited by 145
- 2023A Survey of Large Language Models in Medicine: Progress, Application, and Challengecited by 124
- 2024Efficient Adversarial Training in LLMs with Continuous Attackscited by 113
- 2024Attacking Large Language Models with Projected Gradient Descentcited by 94
- 2024Soft Prompt Threats: Attacking Safety Alignment and Unlearning in Open-Source LLMs through the Embedding Spacecited by 91
- 2024Coercing LLMs to do and reveal (almost) anythingcited by 89
- 2024Defending Against Unforeseen Failure Modes with Latent Adversarial Trainingcited by 88
- 2024Defending Large Language Models Against Jailbreak Attacks via Layer-specific Editingcited by 79
- 2024RigorLLM: Resilient Guardrails for Large Language Models against Undesired Contentcited by 68
- 2024Robust LLM safeguarding via refusal feature adversarial trainingcited by 64
- 2025Model Tampering Attacks Enable More Rigorous Evaluations of LLM Capabilitiescited by 39
- 2025Representation Bending for Large Language Model Safetycited by 30
50 most cited of 55 All 55 (JSON)
Built on by
Citing papers per year: 2025: 1; 2026: 7.
8 papers.
- 2026Adversarial Contrastive Learning for LLM Quantization Attackscited by 5
- 2026TamperBench: Systematically Stress-Testing LLM Safety Under Fine-Tuning and Tamperingcited by 2
- 2025MENTOR: A Metacognition-Driven Self-Evolution Framework for Uncovering and Mitigating Implicit Domain Risks in LLMscited by 1
- 2026TrojanPraise: Jailbreak LLMs via Benign Fine-Tuningcited by 1
- 2026Decoy Direction Optimization: A Post-Hoc Defense Against LLM Abliterationcited by 1
- 2026Do Encoders Suffice? A Systematic Comparison of Encoder and Decoder Safety Judges for LLM Adversarial Evaluationcited by 0
- 2026Mood Matters: How Syntactic Sensitivity Undermines Safety Alignmentcited by 0
- 2026AnchorRep: Defending LLMs Against Cross-Model Adversarial Transfer via Representation Repulsioncited by 0
- 2026AnchorRep: Defending LLMs Against Cross-Model Adversarial Transfer via Representation Repulsion26 Sep 2026
- 2026Decoy Direction Optimization: A Post-Hoc Defense Against LLM Abliteration14 Sep 2026
- 2026Mood Matters: How Syntactic Sensitivity Undermines Safety Alignment5 Aug 2026
- 2026Do Encoders Suffice? A Systematic Comparison of Encoder and Decoder Safety Judges for LLM Adversarial Evaluation24 Jun 2026
- 2026TamperBench: Systematically Stress-Testing LLM Safety Under Fine-Tuning and Tampering6 Feb 2026
- 2026TrojanPraise: Jailbreak LLMs via Benign Fine-Tuning18 Jan 2026
- 2026Adversarial Contrastive Learning for LLM Quantization Attacks6 Jan 2026
- 2025MENTOR: A Metacognition-Driven Self-Evolution Framework for Uncovering and Mitigating Implicit Domain Risks in LLMs10 Nov 2025
Similar, not cited
Close in wording, no citation either way
- 2025Attack and defense techniques in large language models: A survey and new perspectives
- 2024Breaking Down the Defenses: A Comparative Survey of Attacks on Large Language Models
- 2024Recent Advances in Attack and Defense Approaches of Large Language Models
- 2024Representation Noising: A Defence Mechanism Against Harmful Finetuning
- 2025Semantic Representation Attack against Aligned Large Language Models
- 2024Scaling Trends in Language Model Robustness
- 2023Survey of Vulnerabilities in Large Language Models Revealed by Adversarial Attacks
- 2024Large Language Model Sentinel: LLM Agent for Adversarial Purification