From dilution to alignment: understanding and mitigating long-context safety degradationFrom Dilution to Alignment: Understanding and Mitigating Long-Context Safety Degradation
The authors use safety vector projection to analyze long-context safety degradation and propose SALSA; on Qwen3-8B, the LongSafety Full safety rate rises from 39.21% to 89.20%.
- Safety alignment is mostly studied in short contexts; the authors state that as input length grows, the safety rate declines even when the context is benign or irrelevant, and the internal cause is unclear; conventional safety RL may also harm general capability and response rate.
- The authors decompose the residual safety margin into attention and MLP writes and propose SALSA: SA-GSPO trains response-level safety discrimination, SS-OPSD distills in-reasoning segmented summaries into an unprompted policy, and an EMA anchor on benign data limits drift.
- On Qwen3-8B/4B, SALSA's LongSafety Full safety rates are 89.20%/87.19%, respectively, with long-short gaps of 3.10%/4.89%; the authors state that general capability, response rate, and MSJ robustness are overall maintained or improved.
- The paper does not specifically discuss limitations. The experiments report only Qwen3-4B/8B, and safety labels come from Qwen3Guard; the training set has 3,000 examples and the test set 543, with no reported repetitions, variance, statistical tests, or members of the candidate response model pool.
- Threat model
- Studies safety alignment degradation under long-context inputs: even when the context is benign or irrelevant to the query, the safety rate declines with length; Many-shot Jailbreaking is also used to evaluate robustness. The paper does not set a white-box/black-box attacker, and training and mechanism analysis use the model's internal representations.
- Benchmarks
- LongSafetyMany-shot JailbreakingLongBench v2JailbreakBench (JBB-Behaviors)StrongREJECTXSTestWildGuardTestOpenCompassRAGTruthLongAlign
- Metrics
- Safety RateLong–Short safety gapResponse RateOC-avgAttention RetentionMLP RetentionMSJ safety score
The researchers propose the SALSA (Safety-Aware Long-context Self-distillation Alignment) method to mitigate the safety degradation of LLMs under long-context inputs, bringing long- and short-context safety rates close to parity in experiments. Prior safety research has mostly focused on short contexts, whereas model safety declines markedly as inputs grow longer, even when the surrounding context is entirely benign. The authors use safety vector projections along the attention and MLP pathways to trace the degradation, identifying two coupled mechanisms: input-side risk dilution reduces attention to risky queries, and downstream safety perception in MLP layers declines accordingly. SALSA's SA-GSPO component reinforces safety perception through response-level safety judgments, and the SS-OPSD component re-encodes the diluted risk within segmented summaries generated during reasoning and distills it into a prompt-free policy, supplemented by EMA anchoring on benign samples to preserve response rate and general capabilities.
Related events and news
1 events · 0 news mentions
- This event's paper
研究者提出SALSA方法缓解LLM长上下文安全退化
Paper analysis
What problem does this paper attempt to solve?
Studies the safety degradation caused by long context and its attention and MLP mechanisms, and proposes SALSA, which balances safety and general capability.
The core question is: why does the model's safety rate decline as input length grows, and how can long-context safety alignment be repaired without sacrificing response rate and general capability.
- Problem setting: The authors state that existing safety research mainly targets short contexts; existing LongSafety results show that even when the surrounding context is entirely benign, longer inputs reduce safety. The authors further examine two settings: relevant and irrelevant context.
- Shortcomings of existing methods: The authors state that conventional short-context alignment relies on guard model feedback to optimize query–response pairs, still leaves a long–short safety gap in long contexts, and may affect general capability and response rate; in their experiments, Plain GSPO also did not eliminate the length-induced decline.
- Core observation and hypothesis: Using safety-vector projection, the authors decompose the safety margin into attention writes A and MLP writes M, and argue that degradation comes from the coupling of input-side risk dilution and downstream safety-perception decline, rather than from loss of safety knowledge.
- Proposed approach: They propose SALSA, which uses SA-GSPO for response-level safety discrimination, SS-OPSD to distill in-reasoning segmented summaries into unprompted behavior, and an EMA anchor on benign long-context data to limit behavior drift.
- Threat model: This is an alignment and mechanistic analysis paper and does not set a white-box/black-box attacker.
- The risk condition is long input, including benign, harmful, relevant, or irrelevant context; Many-shot Jailbreaking is also tested.
- The victim systems are Qwen3-4B/8B; the internal training analysis requires access to residual, attention, and MLP representations.
- Safety is measured by Qwen3Guard labels and benchmark safety rates, and refusal is not equated with safety.
What related research exists?
Related work is divided into long-context risk, short/long-context safety alignment, and on-policy distillation; this paper emphasizes mechanism-oriented repair.
Long-context capability and safety risks
- LongBench v2 (Bai et al., 2025), RULER (Hsieh et al., 2024): Evaluate retrieval, reasoning, and long-range dependencies; the paper notes that they do not evaluate safety.
- Many-shot Jailbreaking (Anil et al., 2024): Prepends many examples of undesirable behavior to the input; the authors relay that its attack success rate increases with the number of examples; this paper uses it for robustness evaluation.
- LongSafety (Lu et al., 2025): Contains 1,543 cases across seven safety categories; it finds that neutral or benign extensions also reduce safety, and this paper uses it to study internal mechanisms.
Safety alignment
- RLHF (Ouyang et al., 2022), Constitutional AI (Bai et al., 2022), DPO (Rafailov et al., 2023): Establish safe behavior by training models to refuse harmful prompts; the paper classifies them as short-context research.
- Long-context SFT (Huang et al., 2025; Lu et al., 2025): Supervised fine-tuning on curated long-context safety data. The authors criticize such data-driven methods as constrained by sample scarcity and as treating safety as surface behavior rather than a source of processing mechanisms.
On-policy self-distillation
- Hinton et al. (2015), Agarwal et al. (2024): The former does teacher-to-student knowledge distillation, and the latter provides token-level teacher supervision on student-generated trajectories.
- On-Policy Self-Distillation (Zhao et al., 2026): The same model serves as both teacher and student to improve reasoning; SS-OPSD uses this paradigm to internalize long-context segmented summaries.
Baselines and data: The main comparisons are Base, Plain GSPO which directly optimizes the Qwen3-Guard safety reward, and SA-GSPO alone; inference-time Direct Summary is also compared. The main benchmarks are LongSafety, JBB-Behaviors, StrongREJECT, XSTest, WildGuardTest, LongBench v2, and OpenCompass.
The authors position this paper as repairing attention-side dilution and MLP-side safety-perception decline separately, rather than only fitting safer outputs.
How does the paper address this problem?
SALSA implements the decomposition of the safety margin in two types of training: discriminative SA-GSPO and summary-based SS-OPSD, plus an EMA anchor.
The overall idea is to first locate the degradation of long-context safety information in the two pathways, then repair them separately with SALSA (Safety-Aware Long-context Self-distillation Alignment); the full SALSA also incorporates Plain GSPO.
Safety Vector and Pathway Decomposition
- At decision position t⋆ (the prediction step of the first response token after thinking), take the last-layer residual before the final RMSNorm. A unit safety direction rref is constructed from the mean residuals of harmful and benign at L=0.
- The core definition is S ≡ z· rref=const+A+M; larger S indicates a stronger tendency toward safe behavior, and A and M are the sums of projections of each layer's attention and MLP outputs onto rref, respectively.
- Attention writes are expanded by layer, head, and key as attention weight times the token's risk concentration; a simplified softmax model gives query attention mass Θ(1/L) when the query logit difference is bounded and distractors grow with L.
- MLP is expanded by SwiGLU neurons: under fixed parameters κ does not change with length, and changes in M are determined by the weighted sum of gated activations. The authors state that attention dilution may weaken risk cues reaching the MLP; Appendix C clarifies that this is not a theorem of a monotonic relationship.
SA-GSPO: Response-Level Risk Discrimination
- For context c and query q, candidate responses a are collected from a model pool, labeled safe/unsafe by Qwen3Guard, and filtered into data with 1/2 in each of the two classes; the model pool members and K are not reported.
- Input x=(c,q,a), the policy outputs a judgment, the reward is the indicator that the judgment matches the label, invalid judgments get 0; the expected reward of constantly predicting the same valid label is only 0.5.
- The GSPO update is retained: G≥2 rollouts per input, advantage normalized by group mean and standard deviation, length-normalized sequence probability ratio, then clipped surrogate optimization.
- The shared-feature model in Appendix D distinguishes a unified refusal bias u from risk discrimination strength ω; Proposition 1 compares one expected update under assumptions such as balanced symmetric classes, fixed features, common output length, and coordinate separability, and the authors state that discrimination training is less likely to increase benign refusal.
SS-OPSD: Intra-Reasoning Segmented Summary Self-Distillation
- The design motivation comes from Table 2: as length increases, the attention shares of query and thinking both decrease, but thinking still occupies a larger proportion; the authors have the model summarize segment by segment semantically during reasoning to refocus risk information.
- The same model with a segmented-summary system prompt is the teacher, and the model without the prompt is the student; they share weights; trajectories are sampled from the student, and the teacher's token-level distribution is matched on each student prefix, updating only the student, with the teacher snapshot fixed at each update.
- Inference does not require the summary prompt. Appendix E.1 states that this loss transfers summary behavior but does not guarantee capability preservation.
- Proposition 2 gives conditions under which summarization increases and maintains attention writes, under assumptions such as zero background writes, preserved query concentration, proportional scaling of original group attention, and B1–B3; Appendix E.4 states that this is only a head-level mechanistic explanation.
EMA Anchor and Training Pipeline
- EMA parameters are updated as θ̄←μθ̄+(1−μ)θ, μ∈[0,1), and are not directly optimized; on LongAlign benign long-context data, token-level KL pulls the policy toward the EMA.
- The total objective is L(θ)=LOPSD(θ)+λ 𝔼x∼ Dbenign∑t DKL(πθ̄|πθ), used to limit benign behavior drift; the values of μ and λ are not reported.
- Training data pools two LongSafety corpora, 3,000 entries in total, and additionally holds out 543 entries from Lu et al. (2025) as a disjoint test; labels all come from Qwen3Guard.
- Plain GSPO is trained for at most two epochs, and the authors state that beyond two epochs long-context general capability drops by about 5 points; judge training and SS-OPSD are each trained for one epoch.
What experiments did the paper conduct?
On both Qwen3 models, SALSA improves the LongSafety safety rate and narrows the long–short gap, with additional MSJ, pathway retention, and ablation results.
Experimental Setup
- Models evaluated: Qwen3-8B, Qwen3-4B; comparing Base, +Plain GSPO, +SA-GSPO, +SALSA. Table 3 additionally compares Direct Summary on the SA-GSPO-trained model.
- Long-context data: 543 held-out LongSafety test cases; relevant context comes from LongSafety, irrelevant context from RAGTruth. The training set is 3,000 examples mixed from two LongSafety corpora.
- Short context and robustness: The same 543 cases with long context removed serve as Query; JBB-Behaviors, StrongREJECT, and Many-shot Jailbreaking with 0–64 shots are also tested.
- Response and capability: XSTest and the WildGuardTest benign split report response rate; LongBench v2 measures long-context capability, and OC-avg is the mean over 12 OpenCompass benchmarks.
- Metrics and judgment: Full/Query are safety rates, ∆ is the Long–Short gap; safety labels come from Qwen3Guard. The paper does not report evaluation judgment thresholds, human review, or agreement.
- Repetition and mechanism measurement: The number of repetitions, random seeds, or variance are not reported. Mechanism experiments measure attention/MLP retention at t⋆, both normalized to 1.000 at L=0.
Main Results
According to Table 4; Full, Query, JBB, S-R, XS, WG are percentages, ∆ is the long–short gap, and LBv2 and OC-avg are scores.
Swipe horizontally to read the table
Model Method Full↑ Query↑ ∆↓ JBB↑ S-R↑ XS↑ WG↑ LBv2↑ OC-avg↑ Qwen3-8B Base 39.21 68.51 29.30 94.00 94.57 96.40 98.50 46.70 80.71 Qwen3-8B +Plain GSPO 70.35 88.03 17.68 98.00 98.08 92.40 97.25 42.31 80.47 Qwen3-8B +SA-GSPO 83.43 94.11 10.68 100.00 99.36 92.80 95.45 43.41 80.91 Qwen3-8B +SALSA 89.20 92.30 3.10 99.00 99.68 95.20 96.02 47.25 79.98 Qwen3-4B Base 38.67 68.12 29.45 96.00 93.29 95.20 97.88 40.11 77.55 Qwen3-4B +Plain GSPO 71.09 88.60 17.51 98.00 98.72 92.80 96.83 35.71 77.57 Qwen3-4B +SA-GSPO 85.09 94.29 9.20 99.00 99.36 92.80 96.30 35.07 77.92 Qwen3-4B +SALSA 87.19 92.08 4.89 100.00 99.36 93.60 95.66 40.66 77.62 - Authors' interpretation: SALSA narrows the long–short safety gap and outperforms Plain GSPO on long-context safety and LongBench v2; on short-context Query the two are similar.
- Exceptions: SALSA is not highest in every column, e.g., 8B's JBB is lower than SA-GSPO's, and 4B's OC-avg is lower than SA-GSPO's; response rates also do not all recover to Base.
- Capability breakdown: Appendix Tables 6–7 give the 12 scores, and the authors state that general capability changes little compared with Base; no statistical significance tests are reported.
Mechanism Experiments on Length and Context Type
- Safety rate: In Table 1 for Qwen3-8B from L0 to L8192, the relevant-context safety rate goes 69.7%→42.7%, and irrelevant context 64.0%→50.5%; the corresponding ∆ are −27.0% and −13.5%.
- Pathway retention: In the same table, for relevant context Attention Retention goes 1.000→0.728 and MLP Retention 1.000→0.377; for irrelevant context they go to 0.812 and 0.667 respectively. The authors state that the relative decay of MLP is greater than that of attention.
- Attention segmentation: Table 2 renormalizes after excluding template; from L0→L8192, Neutral document goes 0.000→0.467, Query 0.151→0.065, Generated thinking 0.849→0.468.
MSJ and Post-Alignment Mechanism Analysis
- MSJ: In Figure 2(a) the horizontal axis is 0, 1, 2, 4, 8, 16, 32, 64 shots, and the vertical axis is MSJ safety score (%), comparing four methods for two models; the converted text does not retain the values at each point.
- Authors' interpretation: SA-GSPO and SALSA show only a small safety decline as shots increase, while Plain GSPO shows a clear decline at 64 shots; the authors state that dilution in MSJ is weaker, so the benefit of SS-OPSD is limited.
- Pathway results: In Figure 2(b) the horizontal axis is 0, 1K, 4K, 8K, and retention is normalized to 1.0 at length 0; the main text reports that SA-GSPO's MLP retention gain at 8K exceeds 0.2, that the attention retention of Base, Plain GSPO, and SA-GSPO is similar, and that SALSA increases attention retention.
Direct Summary Comparison
- What was tested: Table 3 compares, on the Qwen3-8B SA-GSPO-trained model, directly using a summary system prompt at inference time versus SALSA's internalized summary.
- Results: Direct Summary's Full/Query is 88.59/96.50, XS is 68.20, LBv2 is 43.96, and OC-avg is 78.03; SALSA's corresponding values are 89.20/92.30, 95.20, 47.25, and 79.98.
- Authors' interpretation: Although directly prompting for summaries improves long-context safety, it brings declines in general capability and response rate; OPSD internalization can retain this behavior while reducing the cost.
Other Ablations and Analyses
- Plain GSPO ablation (Table 5, Qwen3-8B): SALSA w/o Plain GSPO has Full/Query/∆ of 85.82/90.98/5.16, JBB 100.00, S-R 99.04, XS 98.00, WG 97.04, LBv2 45.60, and OC-avg 80.51.
- Ablation interpretation: The authors report that this variant's long-context safety gain over Plain GSPO is 15.47%, and the long–short gap drops from 17.68% to 5.16%; adding Plain GSPO still yields additional safety gains.
- Theoretical boundaries: Appendix D.5 writes benign task success as the product of response rate and conditional answer quality, and gives only a performance-loss bound; Appendix E.1 explicitly states that neither distillation nor EMA guarantees capability retention.
What are some points that can be further explored?
The paper does not specifically discuss limitations; the evidence covers two Qwen3 models, 543 test cases, and automatic safety labels, and the theoretical conclusions carry explicit assumptions.
Limitations and future directions noted by the authors
The paper does not specifically discuss limitations, nor does it have a separate Limitations or Future Work section. The method analysis includes the following scope statements:
- Discriminative training theory: Proposition 1 is a comparison of one expected update under conditions such as fixed length, common output length, and local coordinate separability; the authors state that it explains the direction of safety–responsiveness and does not guarantee learning efficiency under arbitrary weak signals (Appendix D.4).
- Capability preservation theory: Responsiveness gains and conditional answer quality are handled separately; the result is a bound on possible performance loss, not an unconditional improvement; conditional answer quality requires empirical evaluation (Appendix D.5).
- Summary theory: Proposition 2 is a head-level analysis that relies on assumptions such as zero-background writes, preservation of query concentration, and proportional attention scaling; it does not guarantee that the total safety margin increases in the full network (Appendix E.2–E.4).
- Length assumption: The thinking attention lower bound in B2 is motivated by Table 2 on finite lengths, but the paper states that this cannot establish that it holds for arbitrary lengths or on every summary run (Appendix E.2).
Experimental coverage
- The models tested are Qwen3-4B and Qwen3-8B, 2 in total; main results are in Table 4.
- The LongSafety training set has 3,000 entries and the held-out test set has 543 entries; mechanism lengths cover L0, L1024, L4096, and L8192, and MSJ covers 0–64 shots.
- Safety labels come from Qwen3Guard; the paper does not report human review, agreement between reviewers and humans, or decision thresholds.
- The paper does not report the number of repetitions, random seeds, confidence intervals, statistical significance tests, training query cost, or the members of the SA-GSPO candidate response model pool.
- Defense comparisons include Base, Plain GSPO, SA-GSPO, SALSA, and its variant without Plain GSPO; Direct Summary is reported only for Qwen3-8B in Table 3.
Summarize the main content of the paper
SALSA handles the two safety pathways separately via risk discrimination and summary self-distillation, narrowing the long-short safety gap on two Qwen3 models.
This is a long-context safety alignment and mechanistic analysis paper that focuses on the decline in safety rate as input length grows, while also aiming to avoid over-refusal and loss of general capability.
- Mechanism localization: At the decision position, the authors project the residual onto the safety direction and decompose the safety margin into attention writes and MLP writes, arguing that risk dilution and the decline in safety perception are interrelated rather than safety knowledge disappearing.
- Method combination: SA-GSPO trains response-level safety discrimination with balanced labels; SS-OPSD distills the segmented-summary behavior of a prompted teacher into an unprompted student; an EMA anchor on LongAlign benign data limits drift, and the full method also combines Plain GSPO.
- Degradation evidence: For Qwen3-8B on relevant context from L0 to L8192, the safety rate drops from 69.7% to 42.7%, and MLP retention drops from 1.000 to 0.377; on irrelevant context the safety rate drops from 64.0% to 50.5% (Table 1).
- Main results: On Qwen3-8B, SALSA's LongSafety Full is 89.20% and the long–short gap is 3.10%, versus 39.21% and 29.30% for Base; on Qwen3-4B the corresponding values are 87.19% and 4.89%, versus 38.67% and 29.45% for Base (Table 4).
- Capability and ablation: 8B+SALSA has LongBench v2 of 47.25 and OC-avg of 79.98; after removing Plain GSPO, Full is still 85.82% with a gap of 5.16% (Tables 4–5). Although Direct Summary has a higher safety rate, its XSTest response rate is 68.20% (Table 3).
- Authors' conclusion: The authors state that SALSA narrows the long–short safety gap, enhances MSJ robustness, and separately improves the retention of safety information in the MLP and attention pathways; general capability and over-refusal metrics are largely stable. Their theoretical propositions carry simplifying assumptions, and the experiments do not report repetitions or statistical tests.
Research lineage
4 foundations · 0 follow-ups in libraryNo later in-library follow-ups recorded yet.
Hover or focus a connected paper to inspect the citation context.