Abstract
Recent large-scale natural language processing (NLP) systems use a pre-trained Large Language Model (LLM) on massive and diverse corpora as a headstart. In practice, the pre-trained model is adapted to a wide array of tasks via fine-tuning on task-specific datasets. LLMs, while effective, have been shown to memorize instances of training data thereby potentially revealing private information processed during pre-training. The potential leakage might further propagate to the downstream tasks for which LLMs are fine-tuned. On the other hand, privacy-preserving algorithms usually involve retraining from scratch, which is prohibitively expensive for LLMs. In this work, we propose a simple, easy to interpret, and computationally lightweight perturbation mechanism to be applied to an already trained model at the decoding stage. Our perturbation mechanism is model-agnostic and can be used in conjunction with any LLM. We provide theoretical analysis showing that the proposed mechanism is differentially private, and experimental results showing a privacy-utility trade-off.
Introduction
Large Language Models (LLMs) are powerful tools but carry significant privacy risks due to their tendency to memorize training data. This "photographic memory" can lead to the unintended disclosure of sensitive information when the model is queried. While Differential Privacy (DP) offers a robust mathematical framework to mitigate these risks, standard implementations like DP-SGD require training from scratch. For modern models with billions of parameters, the computational and environmental costs of retraining are often prohibitive. This research introduces a post-processing approach to secure LLMs at the decoding stage, bypassing the need for expensive retraining.
Perturbation Mechanism at Decoding
The proposed method involves a lightweight perturbation mechanism applied during the generation of text. Instead of directly using the model's output probability distribution $q$ for the next token, the mechanism interpolates it with a uniform distribution $u$ over the entire vocabulary $V$.
The resulting distribution $q'$ is defined as: $$q' = \lambda q + (1 - \lambda)u$$
Here, $\lambda \in [0, 1]$ acts as a mixing parameter that controls the trade-off between the original model's utility and the privacy-preserving noise. When $\lambda = 1$, the model behaves normally; when $\lambda = 0$, it outputs purely random tokens.
This approach is model-agnostic, allowing it to be integrated into any existing LLM architecture (e.g., GPT, RoBERTa) as a simple wrapper during inference. The authors provide a formal proof showing that this mechanism satisfies $\epsilon$-Differential Privacy, where the privacy loss $\epsilon$ is determined by the number of tokens generated, the vocabulary size, and the parameter $\lambda$.
Experimental Setup
The effectiveness of the mechanism was evaluated using a 2-billion parameter RoBERTa-style encoder trained on a 1-trillion token corpus comprising Common Crawl, Wikipedia, and mC4. The researchers conducted tests on a Masked Language Modeling (MLM) task using 125,000 training examples, where 15% of tokens were masked and subsequently predicted using the private decoding mechanism.
Key Results and Privacy-Utility Trade-off
The primary metric for utility was Perplexity, which measures the model's predictive accuracy. The experiments revealed a clear relationship between the privacy budget ($\epsilon$) and model performance.
Key observations include:
- High Utility Region: For $\epsilon$ values around 80, the impact on perplexity was negligible, suggesting that meaningful privacy can be achieved with minimal performance loss.
- Usability Threshold: The model maintained functional performance until $\epsilon$ dropped below approximately 60.
- Performance Collapse: At high privacy levels ($\epsilon \leq 50$), perplexity increased by over 350%, rendering the generated text largely incoherent.
Qualitatively, at moderate privacy levels ($\epsilon \approx 63$), the model tends to substitute specific terms with semantically related but less precise alternatives, preserving grammatical structure while obscuring exact training data matches.
Discussion and Future Directions
While the proposed mechanism offers a computationally efficient path to DP, it faces challenges related to vocabulary size and sequence length. Currently, the privacy guarantee $\epsilon$ scales linearly with the number of predicted tokens, meaning privacy degrades for longer outputs. Additionally, the large vocabulary sizes of modern LLMs dilute the impact of the uniform noise.
Future research may explore "top-k" perturbation strategies to improve the privacy-utility ratio and investigate how this mechanism interacts with advanced sampling techniques like beam search or nucleus sampling. By shifting the focus from training-time to decoding-time protections, this work provides a practical tool for deploying privacy-conscious LLMs in resource-constrained environments.
Summary updated