DNAlign: Dynamic null-space safety alignment framework for LLMsDNAlign: Dynamic Null-Space Safe Alignment for LLMs
DNAlign performs null-space-constrained inference-time alignment on Vicuna-7B and Qwen-7B; HH-RLHF average reward is higher than baselines.
- Safety alignment often harms fluency, factuality, or existing knowledge. The authors aim to suppress harmful outputs and preserve generation quality for benign questions within the same inference.
- DNAlign does not change parameters. It formulates decoding as a dynamical system, uses a value function trained on HH-RLHF to optimize control signals, and projects them onto the null space determined by SHP neutral hidden states.
- In Table I, DNAlign's average reward is higher than the baselines in the same table, with Vicuna-7B, HH-RLHF at 1.2258. Diversity and coherence are not the highest in every cell. Qwen-7B takes 12.447 minutes of inference at 10 batches.
- The paper does not have a dedicated section on limitations. Experiments report Vicuna-7B and Qwen-7B; harmful generalization, harmless sets, and inference time are mainly reported for Qwen-7B. The paper does not report the number of repetitions, λ, the chosen k, or whether HH-RLHF training and evaluation were split.
- Evaluated models
- Vicuna-7BQwen-7B
- Benchmarks
- HH-RLHFSHPRealToxicityPromptsToxiGenCategorical-HarmfulQAOSASST1DollyHC3AlpacaShareGPTReddit ELI5
- Metrics
- Average RewardCoherenceDiversityComprehensive Quality
DNAlign is a lightweight safety alignment framework that combines control-theoretic optimization with null-space projection, treating the LLM as a dynamic system and applying controllable perturbations to steer generation toward safe behavior. Its projection module restricts perturbations to a harm-related subspace derived from neutral hidden states, thereby preserving general knowledge and answer quality; a value function trained on human preference data adaptively optimizes the control signal. Evaluations on multiple LLM backbones show that the framework consistently reduces harmful outputs while maintaining fluency, coherence, and factual utility, and overall outperforms existing alignment baselines without sacrificing generation diversity.
Related events and news
1 events · 0 news mentions
- This event's paper
DNAlign:零空间投影安全对齐框架
Paper analysis
What problem does this paper attempt to solve?
Safety alignment often harms fluency and factuality; DNAlign attempts to simultaneously constrain harmful outputs and preserve neutral knowledge at inference time.
Safety alignment and knowledge preservation are handled separately, and inference-time interventions may still harm fluency and factuality.
- Deployment scenario: The authors state that LLMs are used in healthcare, finance, and education, but may generate harmful or biased content, undermining trust and causing social harm. Therefore, it is necessary to align with human safety preferences while preserving pretrained knowledge to provide factual, fluent responses to benign questions.
- Existing shortcomings: The authors state that RLHF and DPO require extensive human annotation, are prone to overfitting specific prompts, and struggle to balance safety across diverse prompts. Prompt engineering and controlled decoding are lighter, but sensitive to paraphrasing, domains, or prompt structure; dynamic interventions may still reduce fluency or factual accuracy on benign tasks.
- Knowledge-side gap: The authors state that full fine-tuning and static representation editing may overwrite existing knowledge, and continual learning methods like EWC are difficult to scale to large models. Editing before RLHF may overwrite each other, and knowledge-aware prompting is sensitive to paraphrasing and model bias. The authors believe there is a lack of a framework that jointly optimizes both in the same process.
- Our approach: The authors propose DNAlign. It treats the LLM as a dynamical system, injects control perturbations without changing parameters, and restricts perturbations to a harm-related subspace derived from neutral hidden states; a value function trained on human preference data then adaptively optimizes the control signal.
What related research exists?
The authors categorize related work into safety alignment, knowledge preservation, and their combination, and state that joint optimization is lacking.
Safety Alignment
- RLHF and DPO: Christiano et al. (2017) and subsequent work first train a reward model from human evaluations, then fine-tune with reinforcement learning; Rafailov et al. (2023) DPO directly optimizes based on preference rankings without a separate reward model. The authors state that both rely on large amounts of high-quality annotations, are prone to overfitting the training prompt distribution, and depend on the model's existing knowledge, potentially giving compliant but inaccurate answers in complex domains.
- Test-time interventions: Prompt engineering appends safety instructions after the input; controlled decoding modifies token sampling to suppress unsafe outputs. The authors state that the former is sensitive to subtle paraphrasing, and the latter struggles to adapt to different safety tolerances in education and healthcare.
- Dynamic interventions: The authors state that methods treating LLMs as dynamical systems are more flexible, but still often reduce fluency or accuracy on benign tasks.
Knowledge Preservation
- Full fine-tuning and continual learning: Retraining all parameters on new data can partially preserve pretrained knowledge, but the authors state it is computationally expensive and prone to catastrophic forgetting. EWC penalizes updates to parameters critical for old tasks, and memory replay replays historical samples; the authors state both are too expensive for billion-parameter models.
- Local editing and null space: ROME and MEMIT use causal tracing to locate and locally modify neurons or attention related to specific facts. Null-space projection projects parameter perturbations onto a subspace orthogonal to neutral knowledge representations. The authors state such null-space techniques mainly handle factual updates, less so behavioral alignment, and models may be factually correct yet still give inappropriate guidance.
Combining Safety and Knowledge
- Sequential pipelines: First knowledge editing, then RLHF. The authors state the latter alignment step overwrites prior knowledge corrections.
- Prompt-based methods: Use prompts for factual alignment without changing parameters. The authors state they are fragile to paraphrasing and cannot handle harmful associations within representations.
Experimental Baselines and Benchmarks
- Baselines: Unedited backbone, Static RE, Contrastive Decoding (CD), RE-Control. The authors describe Static RE as static reward-based activation adjustment, CD as dynamically integrating rewards during generation, and RE-Control as dynamic control alignment.
- Benchmarks: Mixed evaluation uses HH-RLHF and SHP; harmful generalization uses RealToxicityPrompts, ToxiGen, Categorical-HarmfulQA; benign evaluation uses OSASST1, Dolly, HC3, Alpaca, ShareGPT, Reddit ELI5.
The authors position this work as using control theory and null-space projection to jointly handle safety alignment and knowledge preservation in the same process, rather than treating them as independent objectives.
How does the paper address this problem?
DNAlign optimizes control signals during inference without changing parameters, and projects them onto the null space of a neutral knowledge subspace.
DNAlign formulates per-token generation as a discrete-time dynamical system: at each step, a temporary control signal is injected and then projected outside the protected subspace determined by neutral prompt hidden states, so that the intervention acts mainly in directions orthogonal to that subspace.
Problem Setting
- Generation target: The LLM predicts the next token from the preceding context. The final-layer hidden state passes through the LMHead and softmax to yield the word distribution. The authors state that the final-layer state acts like a semantic anchor that can distinguish neutral prompts from prompts requiring safety handling.
- Two sample types: P0 is a neutral prompt–response pair, and P1 is a harmful pair requiring safety alignment. Quality is reflected by the reward r(response | prompt; θ) for human preferences.
- Preservation constraint: For neutral states lying in the column space of K0, the reward after intervention should remain approximately unchanged. The columns of K0 are the final-layer hidden states of neutral prompts, so the control signal is required to lie approximately in the null space of K0.
Dynamical System and Control Signal
- State: The state at the t-th generated token is s_t = {h_t, o_t}. h_t is the attention key–value across layers; o_t is the pre-logit before the LMHead. The initial state is obtained from a forward pass with unchanged parameters.
- Uncontrolled transition: The next state is updated by the native function f_LM based on the current KV and the sampled token. The LMHead weights are fixed at inference time.
- Control input: u_t = {u^h_t, u^o_t} does not change parameters and is recomputed at each step. u^o biases the pre-logit to lower the probability of harmful candidate tokens; u^h adjusts the KV to avoid the context becoming a semantically inconsistent transition.
- Design difference: The authors state that this differs from changing weights or truncating outputs; the intervention is limited to instantaneous state adjustments.
Null-Space Projection
- Matrix source: N neutral prompts are taken from SHP, and their final-layer hidden states are extracted to form K0, followed by SVD. The first k left singular vectors are retained to form U_prot. k is determined by cross-validation; the paper does not give the selected value.
- Projection: P = Id − Uprot Uprot⊤. Vectors multiplied by P are orthogonal to the protected subspace. P is computed offline and loaded at inference time.
- Application point: The KV control component is multiplied by P before entering f_LM; the control on the pre-logit is projected by the same logic. The authors state that the projected signal has no overlapping component with neutral representations but can still act on harmful-related directions orthogonal to the protected subspace.
Value Function and Signal Optimization
- Training: A three-layer MLP V_ϕ(s_t) is trained on human-labeled safe/useful pairs from HH-RLHF by minimizing a Bellman loss. The target is the next-state value, or the final reward from UltraRM-13B; stop-grad prevents gradients from flowing into the next-state estimate. The paper states that UltraRM-13B prioritizes harmlessness.
- Inference objective: argmax{ut} 𝔼[R]−λ∑t=1T|ut|22. It represents maximizing expected long-term reward while penalizing control magnitude. Equation (11) updates u_t in the direction of the value function gradient and writes a term related to u_t P; the plain text lacks parentheses, and how the terms combine is not further explained in the paper. The method section writes gradient ascent for 100 iterations. Default values for λ and step size α are not given in the method section.
End-to-End Pipeline
- Compute s_0 = {h_0, o_0} from the input.
- Load the precomputed P. The authors state that on Vicuna-7B, this loading takes less than 0.1% of total inference time.
- At each step, optimize u_t with V_ϕ, then project through P.
- Update the KV and pre-logit with the projected signal, and sample from softmax(W(o_t+P u^o_t)). W is the fixed LMHead weight.
- Stop at EOS or when reaching the 200-token limit. The authors state that this limit is consistent across experiments.
Figure 2 depicts the above steps as state initialization, control optimization, null-space projection, and state update. Figure 1 illustrates with a text-message-link-style safety Q&A: the unedited model, after a new safety knowledge update, gives an answer inconsistent with its original refusal, while after DNAlign editing it still refuses. The figure has no quantitative scores.
What experiments did the paper conduct?
On the two 7B backbones, DNAlign's average reward is higher than the Table I baselines, and diversity and coherence are not the highest in every cell.
Experimental Setup
- Models and Baselines: The tested backbones are Vicuna-7B and Qwen-7B. Controls are the unedited backbone, Static RE, Contrastive Decoding (CD), and RE-Control. The paper states initialization uses a uniform random seed and hyperparameters, but does not give the seed value.
- Data: The main comparisons are HH-RLHF and SHP. Harmful generalization uses RealToxicityPrompts, ToxiGen, and Categorical-HarmfulQA; the text states the controls are the Qwen-7B base and RE-Control. Harmless evaluations use OSASST1, Dolly, HC3, Alpaca, ShareGPT, and Reddit ELI5, also primarily with Qwen-7B. Except for the metric formulas and some experiments stating 1000 samples, the paper does not give sizes per dataset.
- Metrics and Evaluation: Average reward is the mean after scoring with UltraRM-13B; the formula writes M as 1000, and scores are not normalized. Coherence is TF-IDF cosine similarity with human preference references, using the top 1000 words of the reference corpus. Diversity is composed of rep-n for 2-gram to 4-gram. Overall quality is scored by DeepSeek-R1-Distill-Qwen-32B on a scale of 1 to 10. The paper states this evaluation model's correlation with human evaluation scores is 0.82.
- Procedure Settings: The value function is trained on HH-RLHF under reward model supervision; the projection matrix is built offline from SHP neutral prompts. Generation limit is 200 tokens. The paper does not report the number of repetitions.
- Flowchart Differences: Figure 3 marks six generalization datasets and Over-refusal Detection on three harmless datasets. The text in Section H/I writes three external harmful sets and six harmless sets. The text does not report a separate over-refusal rate.
Main Results
Average reward, according to Table I:
Swipe horizontally to read the table
Setting Base CD Static RE RE-Control DNAlign Vicuna-7B, HH-RLHF 0.1410 0.8440 0.9130 0.9614 1.2258 Vicuna-7B, SHP 0.3913 0.7830 0.7831 0.7456 1.0756 Qwen-7B, HH-RLHF 0.5519 0.9036 0.7088 0.7218 0.9430 Qwen-7B, SHP 0.3939 0.6415 0.6546 0.6401 0.9882 - Authors' Interpretation: The authors state that on the mixed prompts of HH-RLHF, DNAlign's safety alignment is better than RE-Control and other tested systems, without sacrificing fluency and content richness. On SHP, which is mainly everyday harmless queries, the authors state the intervention does not erode general capability.
- Overall Quality: In Table I, DNAlign is highest in all four cells: Vicuna-7B's HH-RLHF is 6.1600, SHP is 6.9700; Qwen-7B is 7.3846 and 6.8965. Some baselines are lower than the unedited backbone, e.g., Static RE on Vicuna-7B, HH-RLHF is 5.0500, while the base is 5.3600.
- Exceptions: Diversity is not highest in every cell. On Vicuna-7B's SHP, base is 0.8833, DNAlign 0.8818; on Qwen-7B's HH-RLHF, base is 0.9381, DNAlign 0.9371; on Qwen-7B's SHP, RE-Control is 0.9424, DNAlign 0.9402. For coherence, on Qwen-7B's SHP, CD is 0.4247, higher than DNAlign's 0.4164. In the same table, on Qwen-7B, HH-RLHF, CD's average reward is 0.9036, higher than RE-Control's 0.7218, but diversity drops from 0.9381 to 0.8680.
Harmful Scenario Generalization
- Setup: Section H compares DNAlign, the unedited base, and RE-Control on Qwen-7B, with datasets RealToxicityPrompts, ToxiGen, and Categorical-HarmfulQA. This section does not separately write step size and number of iterations.
- Results: The authors report on RealToxicityPrompts DNAlign average reward 0.7999, base 0.3374, and claim an increase of 137.1%; diversity 0.9241, coherence 0.4648. On ToxiGen, DNAlign average reward is 0.5465; Section H and Figure 7 caption state a 229.4% increase relative to base, Section J writes "229.4 increase" without a percent sign; coherence 0.2251, diversity 0.9615. The exact scores for Categorical-HarmfulQA are not listed item by item in the text.
- Authors' Interpretation: The authors state that when safety metrics rise, generation metrics remain competitive. They also state that on some datasets, overall quality may be slightly lower than the unedited backbone, but they do not give these lower scores. Figure 7 labels three groups: Base, Re-Control, Ours; the numbers on the bars in the plain text cannot be aligned column by column with the exact values in Section H.
Utility on Harmless Datasets
- Setup: Section I compares DNAlign, Qwen-7B base, and RE-Control on six harmless sets. DNAlign uses step size 0.2 and 100 gradient ascent steps.
- Results: The authors give DNAlign's diversity as 0.8464 to 0.8836, coherence 0.4077 to 0.5692, and average reward 0.3706 to 0.9210. Figure 8 caption and Section J state the average reward increases by up to 81.9% relative to base; Section I writes "81.9 improvement" without a percent sign. Per-dataset scores are not listed.
- Authors' Interpretation: The authors state that null-space projection isolates the safety intervention to a subspace orthogonal to neutral knowledge. They acknowledge that in some cases overall quality is slightly lower than the base, and state it is still higher than RE-Control; they do not give the corresponding datasets and scores.
Inference Time
- Results: Section F uses Qwen-7B and 1000 samples from HH-RLHF. The text states training batches from 1 to 10, and Figure 5's horizontal axis is "Training Batches". With 1 batch, base is 51.059 minutes, RE-Control 71.518 minutes, DNAlign 123.734 minutes; with 10 batches, they are 10.556, 10.617, and 12.447 minutes respectively. The authors state that at this point DNAlign is 1.891 minutes more than base and 1.83 minutes more than RE-Control.
- Authors' Explanation: The authors state the initial slowness comes from the null-space projection module, and the precomputed matrix loading accounts for less than 0.1% of total inference time. In the same section, coherence is DNAlign 0.4250, base 0.4192, RE-Control 0.4203, same as the Qwen-7B, HH-RLHF row in Table I.
Other Ablations and Analyses
- Step Size and Iterations: Qwen-7B, HH-RLHF distillation subset of 1000 samples; τ ranges from 10 to 100, η from 0.1 to 1.0. The authors state diversity is mostly between 0.933 and 0.942, unless τ is below 30 or η exceeds 0.8; coherence peaks when τ is 40 to 70 and η is 0.2 to 0.5. The authors choose τ=100, η=0.2, obtaining diversity 0.9366, coherence 0.4238, overall quality 7.24, and average reward 0.943. Figure 4 is this analysis; the plain text has no point-by-point readings. The methods section states 100 gradient ascent steps, while Section E states test-time epochs.
- Projection Sample Count: Vicuna-7B. 1 sample error 0.0000035, 100 samples 0.00258; 500 samples 0.587, 1000 samples 0.0415, 1500 samples 1.757, 3000 samples 2.923; 5000 samples 0.0105, 10000 samples 0.00929, 15000 samples 0.00949, 20000 samples 0.0094, 50000 samples 0.0100. The authors state that 1 to 100 samples have low error but poor generalization, 500 to 3000 samples have unstable values, and they choose 20000; the hidden dimension is written as 4096. The authors state this sample count is consistent with previous Qwen-7B experiments.
What are some points that can be further explored?
The paper does not have a dedicated section on limitations or future work.
Limitations and Future Directions Noted by the Authors
The paper does not specifically discuss limitations. The Conclusion only states that the four research questions received affirmative answers, without specifying shortcomings or follow-up experiments.
Experimental Coverage
- Backbones and baselines: Table I and Section V.B report Vicuna-7B, Qwen-7B, as well as the unedited backbone, Static RE, CD, and RE-Control.
- Data and evaluation: The main comparison uses HH-RLHF and SHP; harmful generalization uses three external sets; harmless sets number six. Rewards use UltraRM-13B, and overall quality uses DeepSeek-R1-Distill-Qwen-32B. The metric definitions write the test sample count M as 1000.
- Settings not reported in the paper: Number of repetitions, regularization coefficient λ, the cross-validation-selected k, and whether value function training and the main evaluation on HH-RLHF are split.
- Per-model experiments: Inference time, step size/iterations, harmful generalization, and harmless-set comparisons are written for Qwen-7B. The projection matrix sample size ablation is written for Vicuna-7B; the authors state that 20000 is consistent with the earlier Qwen-7B experiments.
- Budget and figures: The generation limit is written as 200 tokens, and the method section writes gradient ascent for 100 iterations. Figure 3 is labeled Over-refusal Detection, and the text does not give an over-refusal rate.
Summarize the main content of the paper
DNAlign uses null-space-constrained inference-time control for safety alignment; Table I average reward is higher than the listed baselines.
DNAlign is a safety alignment framework that does not change LLM parameters, used to suppress harmful outputs at inference time and reduce changes to fluent, factual responses supported by neutral knowledge.
- Problem: The authors argue that existing RLHF, DPO, prompt engineering, controlled decoding, full fine-tuning, and edit-then-align pipelines either have high annotation and computational costs or damage fluency, factuality, or already-edited knowledge.
- Method: The decoding state is written as KV and pre-logit. A three-layer MLP value function is trained on HH-RLHF with a Bellman loss, and at inference time the control signal is updated along the value gradient; neutral hidden states from SHP undergo SVD to obtain a projection matrix, and the control is restricted to the null space of the protected subspace. Generation stops at EOS or 200 tokens.
- Main results: In the four backbone × dataset cells of Table I, DNAlign's average reward is higher than Base, CD, Static RE, and RE-Control. Vicuna-7B, HH-RLHF is 1.2258, RE-Control is 0.9614; Qwen-7B, HH-RLHF is 0.9430, RE-Control is 0.7218. Overall quality is also highest in these four cells. Diversity and coherence have counterexamples: on Qwen-7B's SHP, CD coherence is 0.4247, and DNAlign is 0.4164.
- Other results: The authors report Qwen-7B average reward of 0.7999 on RealToxicityPrompts, with the base at 0.3374; on ToxiGen, DNAlign is 0.5465. On the six harmless sets, DNAlign diversity ranges from 0.8464 to 0.8836. With Qwen-7B, 1000 HH-RLHF samples, and 10 batches, DNAlign inference takes 12.447 minutes, and the base takes 10.556 minutes.
- Authors' conclusion: The authors state that the four questions of safety, utility preservation, generalization, and practicality all receive affirmative answers, and position the framework as a deployable safety alignment solution. The paper has no dedicated section discussing limitations.
Related papers
- Unintended Harms of Value-Aligned LLMs: Psychological and Empirical InsightsAnalysis / interpretabilityACL 2025
Show 3 more papers
- Large Language Models can be Strong Self-DetoxifiersDefensesarXiv