Abstract
Generative models are increasingly paired with safety classifiers that filter harmful or undesirable outputs. A common strategy is to fine-tune the generator to reduce the probability of being filtered, but this can be suboptimal: it often pushes the model toward producing samples near the classifier's decision boundary, increasing both false positives and false negatives. We propose Boundary Guidance, a reinforcement learning fine-tuning method that explicitly steers generation away from the classifier's margin. On a benchmark of jailbreak and ambiguous prompts, Boundary Guidance improves both the safety and the utility of outputs, as judged by LLM-as-a-Judge evaluations. Comprehensive ablations across model scales and reward designs demonstrate the robustness of our approach.
Introduction: The Problem of the Margin
In real-world applications, Large Language Models (LLMs) rarely operate in isolation. They are typically part of a compound system where a secondary safety classifier (a filter) monitors the model's output. If the filter identifies a response as harmful, it is replaced with a standard refusal.
A significant challenge arises at the "margin" of these classifiers. Standard fine-tuning often pushes models to produce outputs that sit right on the edge of the filter's decision boundary. When a model "walks the line" in this way, minor classifier errors lead to two major failure modes:
- Over-blocking: The filter accidentally rejects a helpful, benign response because it appeared borderline.
- Under-blocking: A harmful response slips through because the filter lacked the confidence to trigger.
We argue that the generator should not merely be trained for safety in a vacuum; it must be trained to be decisive, acting as an effective partner to the downstream filter.
Methodology: Boundary Guidance Reward
We propose Boundary Guidance, a reinforcement learning (RL) fine-tuning framework utilizing the GRPO algorithm. The core innovation is a reward function that explicitly penalizes ambiguity by adding a Boundary Term:
$$R(x, y) = u(x, y) + \lambda |t(x, y) - \tau|$$
- $u(x, y)$: A standard reward model score for helpfulness/utility.
- $t(x, y)$: The safety classifier's score (probability of being safe).
- $\tau$: The classifier's decision threshold (typically 0.5).
By rewarding the model for producing outputs that result in safety scores far from the 0.5 "uncertainty" mark, the generator learns to produce content that the filter can classify with high confidence. For harmful prompts, the model is encouraged to be obviously harmful so the filter can easily catch it, rather than attempting to be subtly evasive.
Experimental Setup
The approach was evaluated using a dataset of 7,880 prompts covering jailbreaks (4,000), benign instructions (3,000 from Alpaca), and harmful requests (880 from HarmfulQA). Evaluation was performed using GPT-4 as a judge, scoring both the helpfulness and harmfulness of the final system outputs across various model scales (0.5B to 14B parameters).
Key Results and Insights
Boundary Guidance achieved Pareto improvements—enhancing safety without sacrificing utility—across multiple model families including Qwen2.5 and Gemma-2.
- Scale and Robustness: Larger models (7B and 14B) proved capable of utilizing the boundary reward to significantly improve performance. Qwen2.5-7B, for instance, reduced judged harmfulness by 0.15 points while maintaining utility. Smaller models (0.5B) also saw gains, with a +0.13 increase in helpfulness and a -0.09 decrease in harmfulness.
- The "Prompt-Awareness" Trap: Interestingly, making the reward "prompt-aware" (targeting safety only for harmful prompts) performed worse, as it encouraged the model to attempt subtle bypasses of the filter.
- Theorem of the Minimum: We mathematically demonstrate that system utility is at its global minimum at the classifier's decision boundary. Avoiding the margin is therefore a decision-theoretic necessity for optimal system performance.
Conclusion
Boundary Guidance shifts the focus of AI safety from training "saintly" models to training "decisive" ones. By explicitly steering generation away from the classifier's margin, we create more robust compound systems that reduce both accidental refusals and safety slips. Future work will explore the robustness of this method when filters are changed post-training or when multiple classifiers are used simultaneously.
Summary updated