LightDefense: A Lightweight Uncertainty-Driven Defense against Jailbreaks via Shifted Token Distribution
Zhuoran Yang, Yanyong Zhang
TL;DR
LightDefense tackles jailbreak defenses for white-box LLMs by shifting the initial token distribution toward a safety-oriented direction, without requiring training or auxiliary models. It identifies a safety direction from the contrast between safe and unsafe token distributions and applies a decoded-time distribution shift, controlled by an uncertainty-based strength parameter. The method achieves strong defense across multiple jailbreak attacks and models while preserving benign utility, evidenced by near-zero attack success rates and high helpfulness benchmarks, and it remains computationally efficient. This approach offers a practical, resource-efficient defense that can be deployed at inference time to bolster AI safety without sacrificing usefulness.
Abstract
Large Language Models (LLMs) face threats from jailbreak prompts. Existing methods for defending against jailbreak attacks are primarily based on auxiliary models. These strategies, however, often require extensive data collection or training. We propose LightDefense, a lightweight defense mechanism targeted at white-box models, which utilizes a safety-oriented direction to adjust the probabilities of tokens in the vocabulary, making safety disclaimers appear among the top tokens after sorting tokens by probability in descending order. We further innovatively leverage LLM's uncertainty about prompts to measure their harmfulness and adaptively adjust defense strength, effectively balancing safety and helpfulness. The effectiveness of LightDefense in defending against 5 attack methods across 2 target LLMs, without compromising helpfulness to benign user queries, highlights its potential as a novel and lightweight defense mechanism, enhancing security of LLMs.
