SPARD: Defending Harmful Fine-Tuning Attack via Safety Projection with Relevance-Diversity Data Selection

Shuhao Chen, Weisen Jiang, Yeqi Gong, Shengda Luo, Chengxiang Zhuo +3 more
5/27/2026
7 citations
cs.LGcs.AIcs.CR

Official code: shuhao02/SPARD (4 stars, Python, last commit 2026-05-23).

Abstract

Fine-tuning large language models often undermines their safety alignment, a problem further amplified by harmful fine-tuning attacks in which adversarial data removes safeguards and induces unsafe behaviors. We propose SPARD, a defense framework that integrates Safety-Projected Alternating optimization with Relevance-Diversity aware data selection.

Show full abstract

SPARD employs SPAG, which optimizes alternatively between utility updates and explicit safety projections with a set of safe data to enforce safety constraints. To curate safe data, we introduce a Relevance-Diversity Determinantal Point Process to select compact safe data, balancing task relevance and safety coverage. Experiments on GSM8K and OpenBookQA under four harmful fine-tuning attacks demonstrate that SPARD consistently achieves the lowest average attack success rates, substantially outperforming state-of-the-art defense methods, while maintaining high task accuracy. Code is available at https://github.com/shuhao02/SPARD.

View on arXivView PDF

Code Implementations(1)

shuhao02/SPARDOfficial100%

The offical code for SPARD

40Python, ShellMay 23, 20266 months ago

Similar Papers

Cite this paper

@article{chen2026spard,
  title  = {SPARD: Defending Harmful Fine-Tuning Attack via Safety Projection with Relevance-Diversity Data Selection},
  author = {Shuhao Chen and Weisen Jiang and Yeqi Gong and Shengda Luo and Chengxiang Zhuo and Zang Li and James T. Kwok and Yu Zhang},
  year   = {2026},
  eprint = {2605.28030},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2605.28030v1}
}

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/2605.28030.svg)](https://codeofpaper.com/paper/2605.28030)

Discussion