Abstract
The increasing demand for domain-specific and human-aligned Large Language Models (LLMs) has led to the widespread adoption of Supervised Fine-Tuning (SFT) techniques. SFT datasets often comprise valuable instruction-response pairs, making them highly valuable targets for potential extraction. This paper studies this critical research problem for the first time. We start by formally defining and formulating the problem, then explore various attack goals, types, and variants based on the unique properties of SFT data in real-world scenarios. Based on our analysis of extraction behaviors of direct extraction, we develop a novel extraction method specifically designed for SFT models, called Differentiated Data Extraction (DDE), which exploits the confidence levels of fine-tuned models and their behavioral differences from pre-trained base models. Through extensive experiments across multiple domains and scenarios, we demonstrate the feasibility of SFT data extraction using DDE. Our results show that DDE consistently outperforms existing extraction baselines in all attack settings. To counter this new attack, we propose a defense mechanism that mitigates DDE attacks with minimal impact on model performance.
1. Introduction: The Vulnerability of Supervised Fine-Tuning
While previous research has demonstrated that LLMs can leak snippets of massive pre-training data, the data used for Supervised Fine-Tuning (SFT) represents a significantly more attractive target for adversaries. SFT datasets are typically smaller, highly curated, and contain proprietary domain-specific expertise, such as medical advice or specialized code.
The primary challenge in extracting this data is branch deviation. Because LLMs generate text token-by-token, a single deviation from the training sequence (e.g., the model generating "Sure!" instead of the exact training token "Definition:") causes the generation to veer away from the original training data. Standard "Vanilla" extraction methods often fail due to this error propagation.
2. Differentiated Data Extraction (DDE)
To overcome branch deviation, we propose Differentiated Data Extraction (DDE). The core insight is that the base model ($M_{Base}$) serves as a control group. By subtracting the base model's general knowledge from the fine-tuned model's ($M_{FT}$) behavior, the specific "fingerprints" of the SFT data become visible. DDE follows a four-step workflow:
- Branching Points Identification: The attacker identifies "uncertain" tokens where the fine-tuned model's confidence drops below a threshold $\tau$.
- New Branches Generation: At these points, the attacker forces the model to generate alternative sequences for both $M_{FT}$ and $M_{Base}$.
- Representative Selection: DDE compares branches to find "Outliers" (where $M_{FT}$ is highly confident but $M_{Base}$ is not) and "Closest" branches (sequences showing fine-tuning influence).
- Masked Data Completion: For retraining attacks, the LLM is used to "fill in the blanks" of fragmented instructions to create high-quality training pairs.
3. Experimental Setup and Evaluation
We evaluated DDE across three diverse domains: OSS-Instruct (code), MathInstruct (mathematics), and WildChat (user-ChatGPT conversations). We utilized LLaMA2-7B and CodeLlama-7B as victim models. To measure the presence of training data, we introduced the Next Token Correction (NTC) metric, which revealed that nudging the model back onto the training path allows it to recover over 82% of original tokens.
4. Key Results and Defense
DDE consistently outperformed baselines like Vanilla extraction and DSR. In reconstruction tasks, DDE showed an average relative improvement of 9.96% over Vanilla. In "model cloning" scenarios (retraining attacks), models trained on DDE-extracted data from WildChat achieved an SFT performance score of 12.53, significantly higher than Vanilla (10.99) or DSR (10.64).
To mitigate these risks, we proposed a defense mechanism that modifies output logits to hide confidence spikes associated with SFT data. This defense successfully mitigated DDE attacks while maintaining general model performance within a 3% impact margin.
5. Conclusion
Our research reveals hidden data leak risks in fine-tuned LLMs and demonstrates that proprietary SFT data can be extracted by exploiting behavioral differences between base and fine-tuned models. While current attacks rely on access to token logits—available in 93% of surveyed major LLM providers—future work will explore adaptive attacks in black-box settings and the risks associated with Parameter-Efficient Fine-Tuning (PEFT).
Summary updated