Table of Contents
Fetching ...

Certifiable Safe RLHF: Fixed-Penalty Constraint Optimization for Safer Language Models

Kartik Pandit, Sourav Ganguly, Arnesh Banerjee, Shaahin Angizi, Arnob Ghosh

TL;DR

CS-RLHF reframes safe RLHF as a rectified-penalty constrained optimization, replacing dual-variable tuning with a fixed $\lambda$ and a semantically grounded cost model to enforce safety. By training the cost model on jailbreak-focused data and using a ReLU-penalty that activates only when safety is violated, CS-RLHF provides provable safety guarantees at the optimizer and demonstrates strong robustness against jailbreak prompts. Empirically, CS-RLHF achieves significantly higher safety and efficiency than Safe-RLHF (e.g., >5x efficiency on jailbreak prompts, precision ~97% for the cost model) and enables decode-time safety via Best-of-N sampling with formal safety bounds. These results indicate a practical, certifiable safety framework for LLM alignment with meaningful improvements in safety without sacrificing helpfulness, including robust inference-time safeguards and reproducible evaluation datasets.

Abstract

Ensuring safety is a foundational requirement for large language models (LLMs). Achieving an appropriate balance between enhancing the utility of model outputs and mitigating their potential for harm is a complex and persistent challenge. Contemporary approaches frequently formalize this problem within the framework of Constrained Markov Decision Processes (CMDPs) and employ established CMDP optimization techniques. However, these methods exhibit two notable limitations. First, their reliance on reward and cost functions renders performance highly sensitive to the underlying scoring mechanism, which must capture semantic meaning rather than being triggered by superficial keywords. Second, CMDP-based training entails tuning dual-variable, a process that is both computationally expensive and does not provide any provable safety guarantee for a fixed dual variable that can be exploitable through adversarial jailbreaks. To overcome these limitations, we introduce Certifiable Safe-RLHF (CS-RLHF) that introduces a cost model trained on a large-scale corpus to assign semantically grounded safety scores. In contrast to the lagrangian-based approach, CS-RLHF adopts a rectified penalty-based formulation. This design draws on the theory of exact penalty functions in constrained optimization, wherein constraint satisfaction is enforced directly through a suitably chosen penalty term. With an appropriately scaled penalty, feasibility of the safety constraints can be guaranteed at the optimizer, eliminating the need for dual-variable updates. Empirical evaluation demonstrates that CS-RLHF outperforms state-of-the-art LLM model responses rendering at-least 5 times efficient against nominal and jail-breaking prompts

Certifiable Safe RLHF: Fixed-Penalty Constraint Optimization for Safer Language Models

TL;DR

CS-RLHF reframes safe RLHF as a rectified-penalty constrained optimization, replacing dual-variable tuning with a fixed and a semantically grounded cost model to enforce safety. By training the cost model on jailbreak-focused data and using a ReLU-penalty that activates only when safety is violated, CS-RLHF provides provable safety guarantees at the optimizer and demonstrates strong robustness against jailbreak prompts. Empirically, CS-RLHF achieves significantly higher safety and efficiency than Safe-RLHF (e.g., >5x efficiency on jailbreak prompts, precision ~97% for the cost model) and enables decode-time safety via Best-of-N sampling with formal safety bounds. These results indicate a practical, certifiable safety framework for LLM alignment with meaningful improvements in safety without sacrificing helpfulness, including robust inference-time safeguards and reproducible evaluation datasets.

Abstract

Ensuring safety is a foundational requirement for large language models (LLMs). Achieving an appropriate balance between enhancing the utility of model outputs and mitigating their potential for harm is a complex and persistent challenge. Contemporary approaches frequently formalize this problem within the framework of Constrained Markov Decision Processes (CMDPs) and employ established CMDP optimization techniques. However, these methods exhibit two notable limitations. First, their reliance on reward and cost functions renders performance highly sensitive to the underlying scoring mechanism, which must capture semantic meaning rather than being triggered by superficial keywords. Second, CMDP-based training entails tuning dual-variable, a process that is both computationally expensive and does not provide any provable safety guarantee for a fixed dual variable that can be exploitable through adversarial jailbreaks. To overcome these limitations, we introduce Certifiable Safe-RLHF (CS-RLHF) that introduces a cost model trained on a large-scale corpus to assign semantically grounded safety scores. In contrast to the lagrangian-based approach, CS-RLHF adopts a rectified penalty-based formulation. This design draws on the theory of exact penalty functions in constrained optimization, wherein constraint satisfaction is enforced directly through a suitably chosen penalty term. With an appropriately scaled penalty, feasibility of the safety constraints can be guaranteed at the optimizer, eliminating the need for dual-variable updates. Empirical evaluation demonstrates that CS-RLHF outperforms state-of-the-art LLM model responses rendering at-least 5 times efficient against nominal and jail-breaking prompts

Paper Structure

This paper contains 48 sections, 6 theorems, 51 equations, 5 figures, 13 tables.

Key Result

Theorem 1

Suppose that $\hat{\pi}$ is an optimal solution of (eq:csrlhf-obj), $|r(x,y)|\leq R_{max}$, and $\pi_{\theta}^*$ is an optimal solution of (eq:cmdp). Then, $\mathcal{J}_r(\hat{\pi})\geq \mathcal{J}_r(\pi_{\theta}^*)$, and $\mathcal{J}_c(\hat{\pi})\leq d+\epsilon$ if $\lambda\geq R_{max}/\epsilon$.

Figures (5)

  • Figure 1: Comparison between RLHF, Safe-RLHF and CS-RLHF frameworks
  • Figure 2: Cost--reward trade-off comparison (a) Alpaca-7B(left), (b) Safe-RLHF(middle), and (c) CS-RLHF(right). Black dots denote jailbreak responses. Green and white shades denotes Safe and Unsafe zone respectively.
  • Figure 3: Safety against 40 unseen jailbreak prompts. CS-RLHF restricts unsafe generations to 15%, significantly lower than Safe-RLHF and other models.
  • Figure 4: Reward–cost distributions under alternative $\lambda$ settings. (a) $\lambda$ value tuned (3–10) in CS-RLHF (left): partial improvement, but many jailbreak responses remain unsafe. (b) Fixed $\lambda = 30$ (right): all responses are forced into the safe region, but helpful outputs are also restricted due to overly strict penalties.
  • Figure 5: Scores assigned by Safe-RLHF and CS-RLHF cost models on identical prompt--response pairs. Both models were given the same inputs; the figures highlights differences in scoring behavior. Excerpts are shown for brevity, with full responses and additional examples in Appendix \ref{['appendix:Extra_results']}(Table \ref{['tab:csrlhf-cost-JB']}).

Theorems & Definitions (8)

  • Theorem 1
  • Corollary 1
  • proof
  • Lemma 1
  • Lemma 2
  • proof
  • Lemma 3
  • Theorem 2