Beyond Safe Data: Pretraining-Stage Alignment with Regular Safety Reflection

Jinhan Li, Kexian Tang, Yihan Xu, Zhuorui Ye, Kaifeng Lyu

TL;DR

This paper argues that "safe data" does not guarantee a "safe model," as LLMs can synthesize unsafe behaviors by generalizing from seemingly benign knowledge. To combat this, the authors introduce Safety Reflection Pretraining (SRP), a method that bakes self-monitoring directly into the pretraining process by regularly inserting short safety "thoughts" into the training corpus, significantly increasing robustness against adversarial attacks and fine-tuning exploits.

What Problem Does This Paper Address?

Current safety alignment typically happens at the end of the training pipeline (Post-training) via Supervised Fine-Tuning (SFT) or Reinforcement Learning from Human Feedback (RLHF). The authors argue this approach is "shallow": it changes how a model acts without fundamentally altering the underlying capabilities it acquired during pretraining. Consequently, these safety guardrails are fragile and easily bypassed by clever prompting or even benign fine-tuning.

Furthermore, the paper challenges the common assumption that data filtering (removing toxic content) is sufficient. They demonstrate a "failure mode" where a model trained only on safe data can still reason its way into unsafe territory—for example, a model that understands how a medicine works (safe) can generalize that knowledge to understand how to weaponize it (unsafe).

Methods

The core proposal is Safety Reflection Pretraining (SRP). Instead of just filtering the corpus, SRP teaches the model to judge its own generations as it learns language.

  1. Text Segmentation: The pretraining corpus is partitioned into segments of a few hundred tokens using a sentence-aware strategy to maintain coherence.
  2. Reflection Generation: A high-quality safety classifier (like Qwen3Guard) generates a "reflection" for each segment. This is a short tag like <think> Safe </think> or <think> Unsafe: Violent </think>.
  3. Augmented Pretraining: These reflections are inserted into the corpus. The model is then trained to predict these safety verdicts as part of its standard next-token prediction objective.
  4. Compatible Post-training: To ensure this behavior carries over to deployment, the authors use an SFT pipeline that maintains the same reflection format, encouraging the model to "think" about safety before and during its responses.

Datasets

The authors evaluate their approach using both real-world and synthetic data:

  • FineWeb-Edu: 100B tokens used for real-world pretraining of 1.7B parameter models.
  • MedSafetyWorld (New): A fully controlled synthetic environment introduced by the authors. It models medical knowledge (compounds, mediators, and outcomes) to specifically test how models generalize "reverse-unsafe" behaviors (how to cause harm) from "forward-safe" data (how drugs work).
  • Evaluation Benchmarks: The models were tested against standard safety and utility benchmarks, including AdvBench, DirectHarm4, Harmful HEx-PHI, GSM8K (for benign fine-tuning robustness), IFEval, and AlpacaEval.

Key Insights and Ideas

  • Safety as a Native Capability: By making safety reflections part of the pretraining objective, safety becomes a foundational skill rather than a "patch" applied at the end.
  • The Generalization Trap: The MedSafetyWorld experiments prove that even if you perfectly filter a dataset to be 100% "safe," a sufficiently capable model can still derive unsafe actions through logical composition. This suggests that alignment must shape behavioral tendencies, not just data content.
  • Robustness to "Catastrophic Forgetting": Standard models often lose their safety alignment when fine-tuned on new, benign tasks (like math). SRP models are much more "sticky"—they retain their self-monitoring habits even after further training.

Key Results

  • Inference-Stage Robustness: In "prefill attacks" (where a model is forced to start an unsafe response), SRP reduced the Attack Success Rate (ASR) from 92.42% (baseline) to just 8.48%.
  • Fine-tuning Defense: When subjected to adversarial fine-tuning, the SRP model (with reflections) maintained a 0.00% ASR, whereas the baseline model's safety was completely broken.
  • No "Tax" on Intelligence: Despite the heavy focus on safety, SRP models performed comparably to baselines on general understanding tasks (46.77 vs 47.56 on general scores), proving that deep alignment doesn't necessarily degrade utility.
  • Superior Classification: SRP significantly improved the model's ability to identify unsafe content, boosting the harmonic mean of safety classification from 75.4% to 90.6%.

Limitations and Future Work

  • Format Dependency: The current method relies on the model maintaining the specific <think> tag format during post-training. If a user fine-tunes the model to stop using these tags, the safety performance degrades.
  • Inference Overhead: Generating internal reflections during inference adds a small amount of computational cost (extra tokens).
  • Future Direction: The authors call for research into "format-agnostic" pretraining alignment—finding ways to make the safety foundation so deep that it remains intact even if the output structure is radically changed by end-users.

Summary updated

BibTeX
@inproceedings{li2026beyond,
  author = {Jinhan Li and Kexian Tang and Yihan Xu and Zhuorui Ye and Kaifeng Lyu},
  title = {{Beyond Safe Data: Pretraining-Stage Alignment with Regular Safety Reflection}},
  booktitle = {AI4GOOD @ ICML},
  year = {2026},
  url = {https://openreview.net/forum?id=fXsMQViLbK},
}
Figure