arXiv(opens in a new tab)cs.CLOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.26809

Safety Mid-Training: Internalizing LLM Safety as a Foundational Capability

Zhengyue Zhao, Liwei Jiang, Yejin Choi, Chaowei Xiao1

Zhengyue Zhao1^{1}, Liwei Jiang2^{2}, Yejin Choi3^{3} and Chaowei Xiao1^{1}

1^{1}Johns Hopkins University, 2^{2}University of Washington, 3^{3}Stanford University

Safety alignment for large language models (LLMs) is primarily performed during post-training, while recent work has also begun incorporating safety data into pre-training. Yet safety can degrade when later training no longer includes safety data, and gains in safety often come at the cost of general capability. This tension suggests that safety and general reasoning should not be treated as separate training goals. We instead view safety as an LLM capability that can be learned through a reasoning structure shared with general tasks. Both require the model to understand intent or task goals, apply relevant knowledge, and reason about potential consequences. We introduce safety mid-training, a stage between pre-training and post-training that jointly develops safety and general reasoning through this shared structure. Given safety and utility prompts, the base model generates structured documents and reasoning traces that are then used for mid-training. Safety mid-training reduces average attack success rate (ASR) by 72% to 81% relative to Qwen3-1.7B, 4B, and 8B base models, while also improving general capability. The benefits persist through subsequent post-training. After general-only SFT, mid-trained models largely retain their safety, achieving lower ASR than the baselines without sacrificing general capability. They also retain safety under general-only GRPO without safety rewards, while subsequent RL reaches a better safety-utility frontier when initialized from the mid-trained models. Together, these results suggest that learning safety and general reasoning within a shared mid-training stage can reduce the safety-utility trade-off and make safety more robust to subsequent training.

Website Code

1. Introduction

LLM safety has become a central part of model development (Sun et al., 2024; Yao et al., 2024), but most safety alignment is still applied after pre-training. A base model is first trained for general capability, and safety behavior is later added through supervised fine-tuning (Bianchi et al., 2024), preference learning (Bai et al., 2022; Rafailov et al., 2023; Shao et al., 2024), or related alignment methods. This post-training paradigm has improved refusal behavior on many benchmarks. In addition, recent work incorporates safety data into pre-training (Maini et al., 2025) or uses alignment-oriented documents during mid-training (Korbak et al., 2026; Li et al., 2026), allowing models to learn about safe behavior at earlier stages of training.

However, safety learned during one stage can decline during subsequent training. The final safety behavior can become highly sensitive to the composition of the SFT data. If later SFT contains little or no safety data, the model may quickly lose safety even when the training data is intended to improve general capability (Qi et al., 2023). This is especially relevant when adapting models to new tasks, where training data often focuses on the task itself. At the same time, safety training can create a trade-off between safety and general capability (Huang et al., 2025). The base model already has reasoning patterns learned during pre-training, while safety fine-tuning often focuses on refusal behavior. As a result, improving refusal behavior can also interfere with general reasoning and instruction following. Both challenges point to the importance of how safety is connected to the model's general

Safety Mid-training pushes both axes simultaneously

Figure

(a) Safety and utility from base to safety mid-train.

Figure

(b) Robustness to safety ratio in SFT data.

Figure 1: Safety mid-training improves safety and utility while stabilizing later SFT. Both panels report full-suite averages. (a) Mid-training moves all Qwen3 and Llama3.2 models toward higher safety and utility. (b) As safety data is reduced during SFT, base models lose safety, while mid-trained models remain stable.

capabilities during training.

We take the view that safety should be learned as a foundational capability of LLMs. Safe responses depend on abilities that are also central to general reasoning. Specifically, the model needs to understand the user's intent or task goal, apply relevant knowledge and constraints, and reason about the possible consequences of an answer. These abilities define a shared reasoning structure through which safety and general capability can be learned together. For example, helping a user recover an account requires knowledge of authentication and attention to whether the proposed steps preserve the account owner's control. The same knowledge helps the model recognize when a request would give someone unauthorized access. Learning to reason about such requests therefore connects safe behavior with the knowledge and reasoning abilities used to provide useful assistance.

To learn this shared reasoning structure, we introduce safety mid-training, a stage between pre-training and post-training that jointly develops safety and general reasoning. Mid-training continues the base model's capability learning before instruction tuning or preference optimization (OLMo et al., 2024; Lambert et al., 2024; Grattafiori et al., 2024; Yang et al., 2025). It provides an opportunity to train on the knowledge and reasoning behind safe responses while learning from general tasks in the same stage. We therefore organize safety and utility examples in a common format and train the base model on them together. In this way, the model learns to apply its existing knowledge to safe behavior through the reasoning structure it also uses for general tasks. This connection provides a way to improve safety while preserving general capability, and gives later SFT and RL a model that has already learned to use these abilities for safety.

Based on this view, we construct safety mid-training data with a self-generation pipeline (Agarwal et al., 2024; Zhao et al., 2026; Shenfeld et al., 2026), as described in Figure 2. We start from existing safety and utility prompts. For each prompt, the base model generates a structured document that organizes the information needed for the response. It also generates a reasoning trace that connects this information to a complete answer. The generated traces are filtered by a judge model for faithfulness, coherence, and consistency with the reference answer and safety label. The accepted documents and reasoning traces form a corpus for training safety and general capability together. Using the base model itself to generate this data makes the construction process practical without requiring a larger model as the generator.

We evaluate safety mid-training on Qwen3-1.7B, 4B, 8B, and Llama3.2-1B, 3B base models, using a pool of 185K prompts and about 200M mid-training tokens. Without any SFT, safety mid-training reduces average ASR on malicious requests by 68% to 86% relative to the base models, while also improving utility (Tables 1 and 5). After SFT, our models achieve lower average ASR than the post-training-only, Safety Pretraining, and Alignment

Safety as a capability learned through shared reasoning

Figure

Shared reasoning structure

Intent / goal

Understand the request

Knowledge

Apply relevant facts and constraints

Consequences

Reason about possible outcomes

Stronger safety capability with general capability preserved

Safety retained during general-only SFT and GRPO without safety data or rewards

Jointly learned during safety mid-training

Constructing the safety mid-training corpus

Figure

Prompt

Safety label

Reference

answer

Structured document

Task

Core goal

Relevant knowledge

Key constraints

Possible consequences

Best feasible path

Verification

Base model generates

Reasoning trace and answer

Grounded in the document and reference answer

Judge filtering

Faithfulness

Coherence

Answer consistency

Pass rubric checks

Quality score ≥\geq 4

Training records

Document prose

Prompt, reasoning

and answer

Safety

mid-training

Continue

training the

base model

Self-generated documents and traces; both record types are filtered before training.

Figure 2: Overview of safety mid-training. Top: safety and general tasks share a reasoning structure based on intent or task goals, relevant knowledge, and consequences. Safety mid-training learns from both types of tasks through this structure. The resulting safety capability remains effective during general-only SFT and GRPO. Bottom: the base model generates structured documents and grounded reasoning traces. A judge filters the candidates, and the accepted document and reasoning records are used for mid-training.

Pretraining baselines across all three SFT data mixtures, while maintaining strong general capability (Table 2). These results show that safety mid-training improves safety before and after instruction tuning and alleviates the safety-utility trade-off.

More importantly, the safety gains remain when subsequent training uses only general data. Under general-only SFT, mid-trained models largely retain their safety, achieving lower ASR than the baselines while maintaining general capability (Figure 1(b) and Table 2). We also evaluate GRPO and find that safety-midtrained models hold a clear advantage over base models throughout training. When GRPO uses only general prompts, with no safety data or safety rewards, mid-trained models retain much of their safety, whereas the base models lose substantially more safety compared with training that includes safety data and rewards. In addition, even after GRPO has fully converged, the advantage of mid-training persists, showing that it raises the ceiling that later RL can reach for both safety and general capability. Together, the SFT and GRPO results show that safety learned through shared reasoning can remain effective as the model continues to learn from general tasks.

Our contributions can be summarized as follows. (1) We introduce safety mid-training, a stage between pre-training and post-training that learns safety as an LLM capability through a reasoning structure shared with general tasks. (2) We propose a self-generation pipeline that builds structured documents and reasoning traces for safety and utility prompts, together with a filtered safety mid-training corpus. (3) We show that safety mid-training improves safety while maintaining general capability across multiple model sizes and benchmarks. The gains appear before SFT, remain after SFT, and persist when SFT or GRPO uses only general data, including GRPO without safety rewards. Mid-training also enables subsequent RL to reach a better safety-utility frontier.

References (63)