Abstract
Aligning Large Language Models (LLMs) to be both helpful and safe remains a significant challenge, particularly for developers restricted to black-box API access. Traditional alignment methods like Reinforcement Learning from Human Feedback (RLHF) are computationally expensive and inflexible to changing safety requirements. This paper introduces Safety Game (SG), a model-agnostic framework that performs alignment at inference time. By framing the interaction as a two-player zero-sum game and utilizing a Linear Programming (LP) solver, SG optimizes the trade-off between informativeness and safety without requiring access to internal model weights. Experimental results across major benchmarks, including SafetyBench and TruthfulQA, show that SG consistently outperforms state-of-the-art baselines, offering a scalable solution for black-box AI alignment.
Introduction
The rapid deployment of LLMs has highlighted the "alignment gap": the difficulty of ensuring models remain helpful while adhering to strict safety boundaries. Current state-of-the-art alignment techniques, such as Direct Preference Optimization (DPO), occur during the training phase. This makes them "brittle"; any shift in safety regulations or social norms necessitates a full retraining of the model. Furthermore, these methods often require "white-box" access to model activations, which is unavailable to the vast majority of developers using proprietary APIs.
To bridge this gap, we present the Safety Game (SG) framework. SG treats the dialogue between an AI and a user as a strategic game, ensuring that safety constraints are met at the moment of generation. This approach allows for dynamic safety policy enforcement on any model, regardless of its underlying architecture.
The Safety Game Framework
The Safety Game framework operates through a multi-step inference-time process designed to externalize the decision-making logic from the LLM itself to a dedicated mathematical solver.
1. Candidate Generation and Probing
For any given prompt, the system generates a finite set of potential responses. This set always includes a "safe fallback" (e.g., "I cannot answer that question"). Each candidate is then evaluated by two binary probes:
- Helpfulness Probe: Measures the utility of the response.
- Risk Probe: Measures the potential harm or policy violation.
These scores are normalized to calculate "helpfulness lift" and "extra risk" relative to the safe fallback option.
2. Game-Theoretic Optimization
The core of SG is a constrained optimization problem. The system seeks to maximize the expected helpfulness of the response while ensuring the expected risk remains below a predefined safety threshold ($T$). Unlike standard LLM prompting, which relies on the model's internal (and often flawed) reasoning to stay safe, SG uses an external Linear Programming (LP) solver to find the optimal strategy.
3. The Sigmoid Penalty
To improve stability, the authors introduced a "sigmoid penalty" to the optimization objective. This "softens" the hard risk cap, preventing the system from becoming overly sensitive to minor fluctuations in risk scores near the boundary. This encourages the model to maintain a buffer below the safety cap rather than "cap-hugging."
Experimental Evaluation
The framework was rigorously tested against the "Consensus Game" baseline using several prominent datasets:
- HHH (Helpful, Honest, Harmless): Evaluates high-level quality and alignment guidelines.
- TruthfulQA: Tests the model's tendency to mimic human misconceptions.
- SafetyBench: A comprehensive benchmark of over 11,000 items covering hazardous topics.
Key Results
The Safety Game approach demonstrated superior performance across various model architectures, including Llama-2-7B and GPT-OSS-20B:
- Performance Gains: SG outperformed baselines in 11 out of 15 test scenarios.
- Scalability: On SafetyBench, SG was the top performer in 4 out of 5 model categories, showing improvements of up to 15 percentage points over standard ranking methods.
- Statistical Robustness: McNemar’s tests confirmed that the improvements on SafetyBench were statistically significant, particularly as model intelligence (and thus potential for complex reasoning) increased.
Discussion and Insights
Democratizing Safety
By operating entirely on model outputs and external probes, SG allows smaller organizations to implement custom safety layers around proprietary black-box models. This shifts the burden of alignment from the model provider to the application developer, allowing for more granular control.
Externalizing Reasoning
A critical insight of this work is that LLMs struggle with strict constraint satisfaction. By delegating the final decision to an LP solver, the framework provides mathematical guarantees that the safety boundaries will be respected, even if the underlying LLM is being nudged by adversarial prompts.
Limitations
The current implementation of SG requires a finite set of candidate responses, making it highly effective for multiple-choice tasks or "Best-of-N" reranking. However, it does not yet support real-time, token-by-token generation for open-ended dialogue.
Conclusion and Future Work
Safety Game provides a robust, model-agnostic method for aligning black-box AI. Future research will focus on extending this game-theoretic approach to multi-turn dialogues and integrating it with white-box steering methods to create a layered defense-in-depth architecture for AI safety. Additionally, the authors aim to adapt the LP solver approach to continuous, open-ended text generation by solving the optimization problem at each decoding step.
Summary updated