DataRx: Missingness-Aware Sampling for Safer Large Language Model Task-Specific Fine-Tuning

Junbo Zhang, Qianli Zhou, Xinyang Deng, Wen Jiang
8/5/2026
cs.CL

No confident code implementation found for this paper.

Abstract

Task-specific fine-tuning can improve the performance of large language models (LLMs) on downstream tasks. However, our study reveals that task-specific fine-tuning can also weaken the safety guardrails of aligned LLMs.

Show full abstract

A widely adopted strategy for preserving safety during fine-tuning is to incorporate safety data. Although previous studies have shown that randomly mixing safety data can alleviate safety degradation, the underlying principle determining why some safety examples are more effective than others still remains unclear. In this paper, we propose DataRx, a missingness-aware sampling method for selecting safety-critical examples. DataRx is based on the hypothesis that a safety sample is more effective when the selected examples provide safety signals that fill the missing parts of LLMs' safety capabilities. DataRx's key insight is leveraging high-dimensional hidden representations rather than discrete tokens to quantify the safety signal gap between the target model's native response and the safety reference response. The results show that, with only 1% additional safety samples from BeaverTails, DataRx reduces the average attack success rate of Llama3-8B-Instruct across seven downstream tasks from 59.23% under random sampling to 13.70%. In addition, DataRx can be combined with the existing safety data synthesis method to further enhance safety defenses during fine-tuning. We hope that DataRx will inspire more data-centric defense research.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{zhang2026datarx,
  title  = {DataRx: Missingness-Aware Sampling for Safer Large Language Model Task-Specific Fine-Tuning},
  author = {Junbo Zhang and Qianli Zhou and Xinyang Deng and Wen Jiang},
  year   = {2026},
  eprint = {2608.04322},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2608.04322v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2608.04322.svg)](https://codeofpaper.com/paper/2608.04322)

Discussion