Safe Transformer: An Explicit Safety Bit For Interpretable And Controllable Alignment

Jingyuan Feng, Andrew Gambardella, Gouki Minegishi, Takeshi Kojima, Yusuke Iwasawa, Yutaka MatsuoarXiv 2026

TL;DR

Current safety alignment methods bake safe behavior implicitly into an LLM's parameters, creating an uninspectable black box. This paper introduces Safe Transformer (ST), which inserts a discrete information bottleneck containing an explicit, readable, and manually overridable "safety bit" ($s$) between transformer layers. This modular approach achieves near-zero attack success rates against jailbreaks while providing a transparent, dual-mode switch for safety control.

What Problem Does This Paper Address?

When a standard large language model (LLM) refuses a user request, it is incredibly difficult to pinpoint exactly why it did so because safety rules are implicitly distributed across billions of parameters. This opacity makes it hard to audit models or intervene when safety mechanisms fail.

Existing solutions either rely on brittle prompt-based defenses or post-hoc external guardrails that are entirely decoupled from the model's generation process. The authors address this gap by designing an architecturally integrated safety mechanism that is both interpretable (the safety decision can be directly read from an internal variable) and controllable (the safety decision can be manually overridden).

Methods

The authors propose Safe Transformer (ST), an architecture that introduces a variational Information Bottleneck (IB) at the midpoint of a decoder-only transformer backbone.

The mechanism works via a two-stage process:

  1. The Information Bottleneck Module: Hidden states from the lower layers are processed by a non-causal Bidirectional Encoder to capture full prompt context. A Write-in FFN then outputs logits for a single supervised safety bit ($s$) and a set of unsupervised latent bits ($u$). The safety bit is discretized ($s=1$ for safe, $s=0$ for unsafe), while the unsupervised bits $u$ capture the remaining semantic information needed for text generation. These bits are combined into a discrete code, mapped back to the hidden dimension via a Read-out FFN, and injected into the upper layers using cross-attention.
  2. Two-Stage Training:
  3. Stage 1 (Safety Classification): The base model is frozen, and the model is trained strictly to classify whether an input prompt is safe or unsafe into the safety bit $s$.
  4. Stage 2 (Disentanglement via Contrastive Training): The classification modules are frozen, and the upper layers are fine-tuned using LoRA. Crucially, the model is trained on contrastive pairs: the exact same prompt is paired with a helpful response when $s=1$, and a refusal template when $s=0$. This forces the upper layers to decouple behavioral mode from semantic content.
Figure 1: Safe transformer architecture. Orange modules are newly introduced; blue modules are from the base model. Left: The information bottleneck processes the key-value input to the decoder, ensuring generation is conditioned on the discrete code (s, u). The decoder serves as an adapter that bridges the representation gap between our bottleneck output and the upper layers’ expected input distribution. Right: Unlike standard VAEs with only unsupervised latents, we introduce a supervised safety bit s alongside the unsupervised latent u. The Write-in FFN outputs logits for both components: the safety logit is discretized into s = 1(z0 > 0), while u is sampled from the remaining logits. The safety logit is trained with supervised labels to classify input prompt safety, while u preserves sufficient information flow through the bottleneck for generation quality.

During inference, the model can run in Automatic Mode (where the encoder computes $s$ from the prompt) or Manual Mode (where a developer or user manually forces $s^*=1$ or $s^*=0$).

Datasets

  • Stage 1 Training: A balanced dataset of 36k prompts (18k safe instructions from Alpaca-GPT4 and 18k unsafe prompts from PKU-SafeRLHF).
  • Stage 2 Training: A contrastive dataset of 9k prompts from Alpaca-GPT4, where each prompt is duplicated to map to both a helpful response ($s=1$) and a randomly selected refusal template ($s=0$).
  • Evaluation Benchmarks:
  • XSTest to evaluate safe compliance and over-refusal behavior.
  • AdversarialQA, DangerousQA, and CatQA to evaluate safety against four distinct jailbreak prompt templates (Standard, Chain-of-Thought, Chain-of-Utterances, and Suffix injection).
  • ARC-Easy, HellaSwag, MMLU, and GSM8K to monitor downstream task performance.

Key Insights and Ideas

  • Causal Disentanglement: By training the upper layers on identical prompts with opposing safety bits, the architecture establishes a direct causal link between the safety bit and the model's behavior. Changing $s$ alone flips the model between helpfulness and refusal, regardless of the prompt text.
  • The Role of Unsupervised Bits: The authors discovered that the unsupervised bits $u$ act as a stylistic and lexical dial. When fixing $s=1$ and varying $u$ across different random seeds, open-ended prompts generated diverse phrasings while maintaining semantic coherence. Conversely, factual queries (e.g., "What is the capital of France?") yielded identical outputs regardless of $u$, confirming that the bottleneck does not destroy core factual knowledge.
  • Preserving Base Capabilities: In Manual Mode, setting $s^*=1$ successfully recovers the base model's helpful behavior on benign prompts, while setting $s^*=0$ acts as a universal kill-switch that triggers immediate refusal.

Key Results

  • Near-Zero Jailbreak Success: Safe Transformer achieved a 0% Attack Success Rate (ASR) on the DangerousQA and CatQA benchmarks across almost all jailbreak strategies. Its overall average ASR was 2.15%, significantly outperforming the base Llama-3.2-1B-Instruct model (24.13%) and a standard Supervised Fine-Tuning (SFT) baseline (16.59%).
  • The Over-Refusal Trade-off: In automatic mode on XSTest, the internal classifier demonstrated a highly conservative bias, achieving a 99.5% unsafe refusal rate but suffering from substantial over-refusal on benign prompts (only 32.8% safe compliance). For example, it refused the prompt "How can I kill a Python process?" due to the keyword "kill".
  • Manual Override Resolution: When manually overriding the safety bit to $s^*=1$ for safe prompts, compliance jumped back up to 95.2%, matching the base model's performance and proving that the generation capabilities remain intact.
  • Downstream Performance: General knowledge benchmarks saw only minor drops (1–4 percentage points on ARC-Easy and HellaSwag). However, mathematical reasoning (GSM8K) dropped from 36.1% to 24.0%, indicating that the bottleneck compresses away complex chain-of-thought reasoning patterns.

Limitations and Future Work

  • Classifier Calibration: The automatic encoder is prone to false negatives on benign prompts that use sensitive vocabulary, leading to high over-refusal rates.
  • Reasoning Bottleneck: The discrete information bottleneck degrades performance on complex arithmetic and multi-step reasoning tasks.
  • Data and Scaling Limits: The framework was only evaluated on a small 1B parameter model using a relatively narrow training data distribution. The authors note that incorporating more diverse reasoning data and evaluating scaling behaviors on larger models are vital next steps.

Summary updated

Abstract

Current safety alignment methods encode safe behavior implicitly within model parameters, creating a fundamental opacity: we cannot easily inspect why a model refuses a request, nor intervene when its safety judgments fail. We propose Safe Transformer, a modular approach that augments pre-trained language models by inserting a discrete information bottleneck containing an explicit safety bit between transformer layers. The safety bit serves as both an interpretable signal of the model's safety classification and a controllable switch: through contrastive training, the model learns disentangled representations where the safety bit governs the behavioral mode - producing helpful responses when $s=1$ and refusals when $s=0$ - while additional unsupervised bits $u$ encode semantic content for generation. Additional unsupervised bits in the information bottleneck allow semantic information to flow through, preserving the model's generation capabilities. This design achieves both interpretability (the safety decision is directly readable) and controllability (the safety bit can be manually overridden), requiring only lightweight fine-tuning without pre-training from scratch. In red-team benchmarks, Safe Transformer achieves near-zero Attack Success Rate, substantially outperforming base models and safety fine-tuning baselines.
BibTeX
@misc{feng2026safe,
  author = {Jingyuan Feng and Andrew Gambardella and Gouki Minegishi and Takeshi Kojima and Yusuke Iwasawa and Yutaka Matsuo},
  title = {{Safe Transformer: An Explicit Safety Bit For Interpretable And Controllable Alignment}},
  year = {2026},
  eprint = {2603.06727},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.06727},
}
Figure