NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Safety Pretraining: Toward the Next Generation of Safe AI

Pratyush Maini, Sachin Goyal, Dylan Sam, Alex Robey, Yash Savani, Yiding Jiang, Andy Zou, Matt Fredrikson, Zacharcy C. Lipton, J. Zico Kolter

TL;DR

Current AI safety relies on "post-hoc alignment"—patching models after they’ve already learned harmful patterns during pretraining. This paper introduces a data-centric framework that embeds safety directly into the pretraining phase, reducing attack success rates from 38.8% to 8.4% without compromising general performance.

What Problem Does This Paper Address?

The core issue is that alignment is not unlearning. Traditional methods like Reinforcement Learning from Human Feedback (RLHF) or Direct Preference Optimization (DPO) act as a superficial mask. Once a large language model (LLM) internalizes unsafe information during its massive pretraining phase, that knowledge is incredibly difficult to remove. Adversarial attacks (jailbreaks) easily bypass these "bolted-on" safety layers because the underlying model still "knows" how to be harmful.

The authors argue that for AI to be truly safe, safety must be "built-in" from the start. They propose shifting the focus from how we fine-tune models to how we curate and annotate the data they see during their initial training.

Methods

The researchers developed a four-step data-centric pretraining framework:

  1. Safety Filtering: Instead of simple keyword blocking, they built a robust Safety Classifier (trained on GPT-4 annotations) to categorize web data by risk level (0-5).
  2. Synthetic Recontextualization: Rather than just deleting sensitive data (which can lead to knowledge gaps), they used LLMs to rewrite it into safe, educational narratives. For example, a toxic post about a historical tragedy is transformed into a classroom-style lecture explaining the ethical and historical implications.
  3. Native Refusal Training: They created two new datasets: RefuseWeb, which simulates dialogues where an assistant responsibly refuses harmful requests, and Moral Education, which reframes harmful content into articles focused on ethical reasoning.
  4. Harmfulness-Tag Annotated Pretraining: They injected a special token, <potentially_unsafe_content>, into 5% of the unsafe training sequences. During inference, they use a novel Safe Beam Search algorithm that looks one token ahead and discards generation paths that have a high probability of producing this "harmful" tag.
The four pillars of the safety pretraining framework: Filtering, Rephrasing, Refusal Training, and Tagging.

Datasets

  • FineWeb-Edu: The base corpus used for filtering and annotation.
  • SafeWeb: A newly released 100-billion-token synthetic corpus of recontextualized data.
  • RefuseWeb & Moral Education: Datasets designed to teach the model how and why to refuse harmful prompts.
  • Evaluation Benchmarks: The models were tested on standard safety benchmarks including HarmBench, JailbreakBench, and AdvBench, as well as general capability benchmarks like MMLU and GSM8k.

Key Insights and Ideas

  • The "Outer Onion" Hypothesis: The authors suggest that safety risks embedded during pretraining are at the "core" of the model, while post-hoc alignment only affects the "outer layers." If the core is unsafe, no amount of outer-layer tuning will suffice.
  • Censorship is Counterproductive: A surprising finding from their ablations was that training only on "safe" (Score 0) data actually increased the model's vulnerability. Without seeing unsafe patterns during training, the model never learns how to recognize or respond to them responsibly.
  • Reasoning Over Rules: Moving from simple refusal (rule-following) to moral education (reasoning) yielded the largest gains in safety. Teaching the model the logic behind safety makes it more robust to novel attacks.
Ablation study showing that removing all unsafe data (Score 0 only) actually increases risk, while rephrasing and moral education significantly decrease it.

Key Results

The authors released SafeLM, a 1.7B parameter model that demonstrates the power of this approach:

  • Robustness: SafeLM reduced the Attack Success Rate (ASR) from 38.8% to 8.4% on safety benchmarks.
  • Performance Stability: Crucially, this was achieved with zero performance degradation on general tasks like mathematics and reasoning (Table 1 in the paper).
  • Resilience to "Unlearning": Unlike standard models whose safety layers "peel off" after even a small amount of benign fine-tuning (e.g., on math problems), SafeLM remained natively aligned and robust.
Comparison of ASR across different training stages, showing SafeLM's superior robustness compared to standard models.

Limitations and Future Work

While highly effective, the authors note a few areas for improvement:

  • Over-refusal: There is a modest increase in the model refusing benign prompts (over-refusal) when using the Safe Beam Search at inference time.
  • Adaptive Attacks: Current adversarial jailbreaks were not designed with the Safe Beam Search algorithm in mind; future work is needed to see if attackers can "game" the lookahead mechanism.
  • Standardization: The authors propose Data Safety Report Cards (Figure 6) as a new standard for transparency in pretraining datasets, encouraging the community to move away from "black box" data curation.
Figure 1: Data Safety Report Card. Our new proposed standardized report card on the safety of pretraining datasets. We report (i) the distribution over safety scores on a sample of our pretraining data and (ii) the frequencies of content (per 1 million tokens) from the MLCommons Safety Taxonomy (Vidgen et al., 2024) in different components of our pretraining mixture.

Summary updated

BibTeX
@inproceedings{maini2025safety,
  author = {Pratyush Maini and Sachin Goyal and Dylan Sam and Alex Robey and Yash Savani and Yiding Jiang and Andy Zou and Matt Fredrikson and Zacharcy C. Lipton and J. Zico Kolter},
  title = {{Safety Pretraining: Toward the Next Generation of Safe AI}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=91H9CSvdwl},
}
Figure