Abstract
The emergence of Large Reasoning Models (LRMs) has introduced sophisticated Chain-of-Thought (CoT) capabilities, yet these models remain vulnerable to complex adversarial prompts. We present SafeKey, a framework designed to identify and amplify the internal "aha moment"—the specific point in a model's reasoning where it recognizes a query's harmful intent. By integrating a Dual-Path Safety Head and a Query-Mask Modeling objective during fine-tuning, SafeKey bridges the gap between internal safety recognition and final response generation. Our results demonstrate a significant reduction in successful jailbreaks while maintaining high performance on standard intelligence benchmarks.
Introduction
Modern LRMs, such as OpenAI’s o1 and DeepSeek-R1, utilize extensive reasoning traces to solve complex tasks. However, this increased reasoning capacity also provides new surfaces for "multi-turn" or "crescendo" attacks, where an adversary gradually nudges the model toward generating harmful content. Research indicates that even when successfully jailbroken, an LRM's internal "understanding" phase often correctly identifies the malicious nature of a prompt. The failure occurs when the model fails to translate this internal insight into a safe reasoning path.
Methodology: The SafeKey Framework
SafeKey introduces two primary training objectives to standard Supervised Fine-Tuning (SFT) to ensure internal safety signals are prioritized:
1. Dual-Path Safety Head (DPSH)
During training, two linear safety heads are attached to the model's hidden states. One head monitors the full context, while the second focuses exclusively on the model's internal "query understanding" (U). This dual-path approach forces the model to encode robust safety signals directly into its internal representations of the reasoning process.
2. Query-Mask Modeling (QMM)
To prevent the model from mindlessly following adversarial prompts, QMM masks the original user query during training. The model must then generate its "key sentence" (K)—the first sentence of its reasoning—based solely on its internal summary of the query. This "blindfold" test ensures the model relies on its own safety-aware understanding.
The "Aha Moment" and Key Sentences
A central finding of this work is the importance of the "Key Sentence" (K). This is the first sentence following the model's internal query understanding. If the model generates a safety-oriented key sentence (e.g., "Hmm, this is concerning..."), it is highly likely to produce a safe response. Conversely, a purely procedural key sentence (e.g., "First, I need to think about...") often leads to a safety failure. SafeKey acts as a bridge, ensuring the "aha moment" in the understanding phase (U) successfully triggers a safe trajectory in the key sentence (K).
Evaluation and Results
SafeKey was evaluated using the STAR-1 dataset and a suite of adversarial benchmarks, including StrongReject, WildChat, and complex multi-turn attacks.
- Safety Performance: SafeKey reduced the average harmfulness rate by 9.6% across models ranging from 7B to 14B parameters. Resistance to specific jailbreak attacks improved by an average of 10.3%.
- Intelligence Preservation: Performance on MMLU-Pro, HumanEval, and Math500 remained stable, confirming that SafeKey enhances safety without compromising the model's core reasoning capabilities.
- Mechanistic Insights: Analysis of attention patterns revealed that SafeKey-trained models show increased attention from the key sentence back to the internal safety-aware reasoning, rather than the adversarial prompt.
Conclusion
SafeKey provides a robust method for aligning the internal reasoning of LRMs with safety requirements. By amplifying the "aha moment" where a model recognizes harm, we can significantly harden these models against sophisticated attacks. Future work will focus on scaling these insights to even larger datasets and further refining defenses against multi-turn adversarial strategies.
Summary updated