mlsanityData to 14 Oct 2026

Improving Large Language Model Safety with Contrastive Representation Learning

arXiv 2506.11938 ↗First posted 13 Jun 2025cs.CL cs.AI cs.LGcited by 8

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

  1. 2017Attention Is All You Needcited by 60,361
  2. 2014Adam: A Method for Stochastic Optimizationcited by 37,240
  3. 2021Learning Transferable Visual Models From Natural Language Supervisioncited by 33,744
  4. 2020A Simple Framework for Contrastive Learning of Visual Representationscited by 12,049
  5. 2021Training Verifiers to Solve Math Word Problemscited by 10,109
  6. 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,170
  7. 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 8,065
  8. 2020Measuring Massive Multitask Language Understandingcited by 7,963
  9. 2018Representation Learning with Contrastive Predictive Codingcited by 7,777
  10. 2018Think you have Solved Question Answering? Try ARC, the AI2 Reasoning Challengecited by 4,886
  11. 2013Efficient Estimation of Word Representations in Vector Spacecited by 4,375
  12. 2019HellaSwag: Can a Machine Really Finish Your Sentence?cited by 4,100
38 more
  1. 2022Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedbackcited by 3,720
  2. 2021TruthfulQA: Measuring How Models Mimic Human Falsehoodscited by 2,975
  3. 2015FaceNet: A Unified Embedding for Face Recognition and Clusteringcited by 2,849
  4. 2020Supervised Contrastive Learningcited by 2,829
  5. 2020Learning to summarize from human feedbackcited by 2,588
  6. 2024HarmBench: A Standardized Evaluation Framework for Automated Red Teaming and Robust Refusalcited by 1,429
  7. 2023Jailbreaking Black Box Large Language Models in Twenty Queriescited by 1,420
  8. 2024Refusal in Language Models Is Mediated by a Single Directioncited by 1,032
  9. 2023A General Theoretical Paradigm to Understand Learning from Human Preferencescited by 912
  10. 2023Enhancing Chat Language Models by Scaling High-quality Instructional Conversationscited by 839
  11. 2023Baseline Defenses for Adversarial Attacks Against Aligned Language Modelscited by 651
  12. 2020Contrastive Learning with Hard Negative Samplescited by 628
  13. 2024How Johnny Can Persuade LLMs to Jailbreak Them: Rethinking Persuasion to Challenge AI Safety by Humanizing LLMscited by 573
  14. 2024Large Language Models: A Surveycited by 525
  15. 2023Zephyr: Direct Distillation of LM Alignmentcited by 506
  16. 2024Negative Preference Optimization: From Catastrophic Collapse to Effective Unlearningcited by 504
  17. 2024WildGuard: Open One-Stop Moderation Tools for Safety Risks, Jailbreaks, and Refusals of LLMscited by 496
  18. 2024Jailbreaking Leading Safety-Aligned LLMs with Simple Adaptive Attackscited by 486
  19. 2023SmoothLLM: Defending Large Language Models Against Jailbreaking Attackscited by 469
  20. 2023GPT-4 Is Too Smart To Be Safe: Stealthy Chat with LLMs via Ciphercited by 423
  21. 2023Toxicity in ChatGPT: Analyzing Persona-assigned Language Modelscited by 360
  22. 2020Keystroke Dynamics as Part of Lifeloggingcited by 334
  23. 2024Improving Alignment and Robustness with Circuit Breakerscited by 322
  24. 2023A Survey of Reinforcement Learning from Human Feedbackcited by 264
  25. 2024WildTeaming at Scale: From In-the-Wild Jailbreaks to (Adversarially) Safer Language Modelscited by 223
  26. 2024Latent Adversarial Training Improves Robustness to Persistent Harmful Behaviors in LLMscited by 173
  27. 2024AutoDefense: Multi-Agent LLM Defense against Jailbreak Attackscited by 145
  28. 2023A Survey of Large Language Models in Medicine: Progress, Application, and Challengecited by 124
  29. 2024Efficient Adversarial Training in LLMs with Continuous Attackscited by 113
  30. 2024Attacking Large Language Models with Projected Gradient Descentcited by 94
  31. 2024Soft Prompt Threats: Attacking Safety Alignment and Unlearning in Open-Source LLMs through the Embedding Spacecited by 91
  32. 2024Coercing LLMs to do and reveal (almost) anythingcited by 89
  33. 2024Defending Against Unforeseen Failure Modes with Latent Adversarial Trainingcited by 88
  34. 2024Defending Large Language Models Against Jailbreak Attacks via Layer-specific Editingcited by 79
  35. 2024RigorLLM: Resilient Guardrails for Large Language Models against Undesired Contentcited by 68
  36. 2024Robust LLM safeguarding via refusal feature adversarial trainingcited by 64
  37. 2025Model Tampering Attacks Enable More Rigorous Evaluations of LLM Capabilitiescited by 39
  38. 2025Representation Bending for Large Language Model Safetycited by 30

50 most cited of 55 All 55 (JSON)

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 1; 2026: 7.

8 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2025Attack and defense techniques in large language models: A survey and new perspectives
  2. 2024Breaking Down the Defenses: A Comparative Survey of Attacks on Large Language Models
  3. 2024Recent Advances in Attack and Defense Approaches of Large Language Models
  4. 2024Representation Noising: A Defence Mechanism Against Harmful Finetuning
  5. 2025Semantic Representation Attack against Aligned Large Language Models
  6. 2024Scaling Trends in Language Model Robustness
  7. 2023Survey of Vulnerabilities in Large Language Models Revealed by Adversarial Attacks
  8. 2024Large Language Model Sentinel: LLM Agent for Adversarial Purification