One Trigger Token Is Enough: A Defense Strategy for Balancing Safety and Usability in Large Language Models

Haoran Gu, Handing Wang, Yi Mei, Mengjie Zhang, Yaochu Jin

TL;DR

Current safety alignment in Large Language Models (LLMs) is often "shallow," meaning that the first few tokens of a response dictate whether a model successfully refuses a harmful prompt. This paper introduces D-STT (Decoding Safety Trigger Tokens), a lightweight defense strategy that forces the model to generate a single pre-identified safety token (like "I") at the very first step of decoding. This minimal intervention reliably activates the model's internal safety mechanisms to block jailbreak attacks while preserving response speed and usability on benign prompts.

What Problem Does This Paper Address?

While safety alignment techniques like Reinforcement Learning from Human Feedback (RLHF) make LLMs safer, these models remain highly vulnerable to "jailbreak attacks." These attacks use clever adversarial prompting to bypass safety guardrails and manipulate models into generating harmful content.

Recent studies reveal that safety alignment is often "shallow"—the model's safety behavior is heavily concentrated in the first few tokens of its response (e.g., starting with "I cannot fulfill..."). Attackers exploit this by forcing the model to start its response with affirmative phrases like "Sure, here's...". Existing defenses try to counteract this by filtering inputs or dynamically altering token probabilities during inference. However, these methods are often heuristic, introduce significant latency, or suffer from "over-refusal," where they mistakenly block benign, safe prompts and degrade the model's overall usability.

Methods

The authors propose D-STT (Decoding Safety Trigger Tokens), a proactive defense that exploits the underlying mechanism of shallow safety alignment. The method consists of two main phases:

  1. Identifying Safety Trigger Tokens: The authors collect a small set of valid refusal responses from the safety-aligned LLM. They observe that the very first token of a refusal is highly consistent across different harmful prompts (typically the token "I"). From these samples, they construct a safety-aware prior distribution ($P_{safety}$) based on the frequency of these initial tokens.
  2. Decoding Safety Trigger Tokens: During the actual inference phase, D-STT intervenes only at the very first decoding step. Instead of letting the model freely generate the first token—which an adversarial prompt might have compromised—D-STT explicitly samples the first token ($y_1$) from the pre-computed $P_{safety}$ distribution. From the second token onward, the model resumes its normal decoding strategy (such as greedy or top-$p$ sampling).
Figure 1: The framework of D-STT. We first identify the safety trigger tokens by collecting refusal responses from the given safety-aligned LLM prompted with malicious prompts. Then, we construct a safety-aware prior distribution Psafety by computing the frequency of each distinct safety trigger token appearing in the refusal responses. In the inference phase, we decode the safety trigger tokens by sampling from Psafety, and generate the remaining tokens using the normal decoding strategy over the model’s conditional distribution.

By constraining the intervention to exactly a single token, D-STT avoids over-constraining the model's generation, keeping the defense lightweight and preserving usability.

Datasets

The paper evaluates its approach using several established datasets:

  • AdvBench: Used to source 50 representative harmful queries to generate jailbreak prompts via token-level and prompt-level optimization attacks (e.g., GCG, AutoDAN, PAIR).
  • HEx-PHI: Contains 330 malicious prompts across 11 harmful categories to test defense generalizability.
  • Just-Eval: A benchmark of 800 diverse instructions used to evaluate model usability across five dimensions: helpfulness, clarity, factuality, depth, and engagement.
  • XSTest & Held-out set: Consisting of 250 and 100 safe but sensitive queries, respectively, to evaluate the false-positive refusal rate on benign prompts.

Key Insights and Ideas

  • The Leverage of the First Token: Due to the autoregressive nature of LLMs, early tokens exert a dominant influence over the entire generation. Forcing a safe, standard prefix token reliably steers the model's internal attention back onto a safe path, even if the input prompt was adversarial.
  • High Cross-Input Similarity: Safety trigger tokens are remarkably uniform across entirely different malicious prompts. Testing Llama2-7B-chat against harmful queries showed that the first token was "I" 100% of the time. This means a model's safety patterns can be activated using a very simple, generalized prior rather than complex, input-specific logic.
  • The Safety-Usability Sweet Spot: Constraining the safety trigger prefix to a single token provides the best trade-off. The authors experimented with forcing 2-token and 4-token prefixes; while safety improved marginally, usability plummeted (up to a 23.5% drop on Just-Eval). A single token maintains high response quality while keeping the defense robust.

Key Results

  • Robust Jailbreak Defense: D-STT was evaluated against 8 distinct jailbreak attacks across 4 safety-aligned LLMs (Llama2-7B-chat, Vicuna-7B, Qwen2.5-7B-Instruct, Gemma-2-9B-IT). It consistently achieved the strongest robustness, frequently reducing the Attack Success Rate (ASR) to 0% or near 0% where undefended models suffered up to 100% failure.
  • Preserved Usability: On the Just-Eval benchmark, D-STT incurred a minor usability drop of only ~1.46% compared to the no-defense baseline, significantly outperforming other inference-guided methods.
  • Negligible Latency Overhead: D-STT introduces an Average Token Generation Time Ratio (ATGR) of just 1.02x (a mere 2% time overhead). In comparison, advanced competitive defenses like AED slow down generation by nearly 7x (6.94x).
Figure 2: Radar chart of average defense rankings over eight jailbreak attacks on four safety-aligned LLMs, based on harmfulness scores.

Limitations and Future Work

  • Decoding-Level Dependency: The current approach identifies safety trigger tokens based on explicit output vocabulary distributions, which requires collecting refusal samples beforehand. The authors note that future work should explore identifying these triggers directly within the model's internal feature space (e.g., hidden states or attention patterns).
  • Server-Side Restriction: Because D-STT requires intervening in the decoding process (sampling the first token), it cannot be applied by end-users on closed-source, black-box commercial APIs (like OpenAI's API) where inference parameters are hidden. It is strictly a server-side defense strategy for model providers.

Summary updated

BibTeX
@misc{gu2025one,
  author = {Haoran Gu and Handing Wang and Yi Mei and Mengjie Zhang and Yaochu Jin},
  title = {{One Trigger Token Is Enough: A Defense Strategy for Balancing Safety and Usability in Large Language Models}},
  year = {2025},
  eprint = {2505.07167},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.07167},
}
Figure