Don't Walk the Line: Boundary Guidance for Filtered Generation

Sarah Ball, Andreas Haupt

In modern production environments, Large Language Models (LLMs) rarely operate in isolation. They are typically deployed as part of a compound system, paired with a downstream safety classifier (or "filter") designed to block harmful content. Standard safety fine-tuning methods often attempt to minimize the probability of an output being filtered. However, this objective inadvertently pushes the generator to produce "borderline" samples that sit right on the classifier's decision boundary. To address this, researchers propose Boundary Guidance, a reinforcement learning approach that explicitly rewards models for generating outputs far from this boundary, thereby improving both the safety and utility of the overall compound system.

The Problem: "Walking the Line"

When a generator is trained to merely evade a safety filter, it learns to produce outputs that are too safe to be easily rejected but too risky to be confidently passed. This "walking the line" behavior exposes the imperfections of the safety classifier and leads to two major failure modes:

  1. Over-blocking (False Positives): Benign answers are accidentally filtered because they exhibit borderline characteristics.
  2. Under-blocking (False Negatives): Harmful content slips through because the filter is insufficiently confident to trigger a block.

Methodology: Boundary Guidance

To counter this, the authors introduce Boundary Guidance, a fine-tuning framework that optimizes the compound system (generator plus filter) rather than the generator in isolation.

The core algorithm utilizes Group Relative Policy Optimization (GRPO). The key innovation lies in the reward function, which augments a standard helpfulness reward with a margin term based on the safety classifier's score ($t$):

$$R(x, y) = u(x, y) + \lambda |t(x, y) - 0.5|$$

Here, $u(x, y)$ represents the standard utility score, while $|t(x, y) - 0.5|$ acts as the boundary term. This term rewards the model for producing outputs where the safety classifier is highly confident (scores near 0 or 1) and penalizes ambiguous outputs (scores near 0.5). By rewarding "decisiveness," the generator learns to produce completions that the filter can easily and reliably judge.

Experimental Setup

The researchers trained and evaluated their approach using a diverse mix of scenarios to ensure the model remained capable while becoming safer. The training set comprised 7,880 prompts, including:

  • Jailbreaks (4,000): Adversarial attempts to bypass safety training.
  • Alpaca (3,000): General instruction-following prompts to maintain helpfulness.
  • HarmfulQA (880): Explicitly harmful questions to provide negative examples.

Ablation studies also incorporated HotpotQA to test performance on long-context prompts (up to 1,000 words). Performance was evaluated using GPT-4.1 and Gemini 2.5 Flash acting as "LLM-as-a-Judge," scoring helpfulness on a 1–4 scale and harmfulness on a 0–3 scale.

Key Insights and Results

The study reveals several critical insights into system-level optimization:

  • The Boundary is the Danger Zone: Theoretical analysis demonstrates that system utility hits its global minimum at the classifier's threshold. Moving away from this threshold in either direction weakly increases overall system utility.
  • Decisiveness as a Safety Feature: It is safer for a model to be "obviously bad" than "subtly bad." A clearly harmful response is caught by the filter 100% of the time, whereas a borderline response might slip through.
  • Scale Sensitivity: Larger models (7B+) often only need the boundary reward to improve, whereas smaller models (0.5B) benefit more from a combined reward that includes an explicit utility signal to prevent them from collapsing into "universal refusal."

Empirically, Boundary Guidance achieved Pareto improvements—simultaneous gains in safety and helpfulness—across multiple model families, including Qwen2.5 and Gemma-2:

  • Harmfulness Reduction: Across all models, harmfulness scores dropped significantly. For instance, the Qwen2.5-7B model saw its harmfulness score drop from 0.19 to 0.04.
  • Helpfulness Gains: Stricter safety did not compromise utility; in fact, helpfulness often increased. The Qwen2.5-0.5B model experienced a +0.13 boost in helpfulness because the filter stopped over-refusing its benign outputs.
  • Distribution Shift: Post-training, the percentage of outputs in the "uncertain" zone (0.1 to 0.9) dropped drastically. In jailbreak scenarios, the Qwen2.5-14B model shifted from 92% decisive outputs to 100%.

Limitations and Future Directions

While highly effective, Boundary Guidance has limitations. It assumes the classifier satisfies a "monotone likelihood ratio." If a classifier is highly confident but fundamentally wrong about a specific type of harm, the method could inadvertently encourage the model to produce more of that harm (the "confidently wrong" risk).

Furthermore, boundary steering fails when using very weak classifiers (under 1B parameters), which can degrade model helpfulness. The method's success is also sensitive to the prompt mix used during training. Future work will explore using multiple safety classifiers simultaneously and testing the robustness of models deployed with filters different from those they were trained on.

Summary updated

BibTeX
@inproceedings{ball2026don,
  author = {Sarah Ball and Andreas Haupt},
  title = {{Don't Walk the Line: Boundary Guidance for Filtered Generation}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=yTeVcvtkbI},
}
Figure