paper-with-me

홈 › Papers

Improving Large Language Model Safety with Contrastive Representation Learning

2025-06-13 · Samuel Simko, Mrinmaya Sachan, Bernhard Schölkopf, Zhijing Jin

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

📄 PDF Abstract BibTeX arXiv:2506.11938

Code (1)

samuelsimko/crl-llm-defense 공식 구현 pytorch

Tasks

Language ModelingLanguage ModellingLarge Language ModelRepresentation LearningTriplet

Similar Papers 제목 키워드 기반

Rethinking Jailbreak Detection of Large Vision Language Models with Representational Contrastive Scoring

2025-12-12 · Peichun Hua, Hao Li, Shanghao Shi, Zhiyuan Yu 외 arxiv

Large Vision-Language Models (LVLMs) are vulnerable to a growing array of multimodal jailbreak attacks, necessitating defenses that are both generalizable to novel threats and efficient for practical deployment. Many cur…

Security Tensors as a Cross-Modal Bridge: Extending Text-Aligned Safety to Vision in LVLM

2025-07-28 · Shen Li, Liuyi Yao, Wujia Niu, Lan Zhang 외 arxiv

Large visual-language models (LVLMs) integrate aligned large language models (LLMs) with visual modules to process multimodal inputs. However, the safety mechanisms developed for text-based LLMs do not naturally extend t…

FALCON: Fine-grained Activation Manipulation by Contrastive Orthogonal Unalignment for Large Language Model

2025-02-03 · Jinwei Hu, Zhenglin Huang, Xiangyu Yin, Wenjie Ruan 외

Large language models have been widely applied, but can inadvertently encode sensitive or harmful information, raising significant safety concerns. Machine unlearning has emerged to alleviate this concern; however, exist…

Language ModelingLanguage ModellingLarge Language ModelMachine Unlearning

Adversarial Contrastive Decoding: Boosting Safety Alignment of Large Language Models via Opposite Prompt Optimization

2024-06-24 · Zhengyue Zhao, Xiaoyun Zhang, Kaidi Xu, Xing Hu 외

With the widespread application of Large Language Models (LLMs), it has become a significant concern to ensure their safety and prevent harmful responses. While current safe-alignment methods based on instruction fine-tu…

Safety Alignment

Athena: Safe Autonomous Agents with Verbal Contrastive Learning

2024-08-20 · Tanmana Sadhu, Ali Pesaranghader, Yanan Chen, Dong Hoon Yi

Due to emergent capabilities, large language models (LLMs) have been utilized as language-based agents to perform a variety of tasks and make decisions with an increasing degree of autonomy. These autonomous agents can u…

Contrastive Learning