Abstract
An important question in deploying large language models (LLMs) is how to augment LLMs with private data. We propose Differentially Private In-context Learning (DP-ICL) to enable LLMs to adapt to new tasks while maintaining privacy guarantees. DP-ICL performs private inference by establishing noisy consensus over an ensemble of exemplars using the Report-Noisy-Max mechanism. We evaluate DP-ICL on four benchmarks and find that it achieves comparable performance (<2% degradation) with non-private ICL.
1. Introduction
In-Context Learning (ICL) allows Large Language Models (LLMs) to perform new tasks by including a few examples, or exemplars, in the prompt. While effective and computationally efficient compared to fine-tuning, ICL presents significant privacy risks. When these exemplars contain sensitive information—such as medical records or private communications—they become vulnerable to extraction attacks.
As illustrated in Figure 1, a malicious user can craft queries to bypass system instructions, leading to the leakage of private data. Existing solutions like DP-SGD require access to model weights and are difficult to tune for LLMs. This paper introduces DP-ICL, a paradigm that provides formal privacy guarantees for ICL without requiring model fine-tuning or weight access.
2. The DP-ICL Framework
The core of DP-ICL is a "sample-and-aggregate" approach designed to work with black-box LLM APIs. The framework operates through four primary phases to ensure that no single exemplar can be uniquely identified from the model's output.
2.1 Methodology Phases
- Subsample and Partition: The private dataset is divided into disjoint subsets of exemplars.
- Pairing with Query: Each subset is paired with the user's query to create multiple independent prompts.
- Prompting Model: An ensemble of LLM instances processes these prompts in parallel, generating a collection of candidate responses.
- Private Aggregation: The responses are combined using a differentially private mechanism. For classification, this involves adding Gaussian noise to vote counts (Report-Noisy-Max). For generation, the system uses Embedding Space Aggregation (ESA) or Keyword Space Aggregation (KSA) to reach a private consensus.
3. Results and Analysis
DP-ICL was evaluated on standard benchmarks including SST-2, Amazon reviews, AGNews, and SAMsum.
- Performance: On SST-2, DP-ICL achieved 95.8% accuracy at $\epsilon=3$, outperforming previous private fine-tuning methods.
- Utility Retention: In complex generation tasks like dialog summarization (SAMsum), the quality degradation was minimal, with ROUGE scores decreasing by only ~1% under strict privacy constraints ($\epsilon=1$).
- Scalability: The utility-privacy tradeoff improved as the underlying model size increased, indicating that DP-ICL benefits from the emergent capabilities of larger LLMs.
4. Discussion and Conclusion
DP-ICL offers several advantages over traditional private training. It is fully compatible with black-box APIs and supports the "right to be forgotten," as removing a user's data only requires deleting an exemplar from the database rather than retraining the model.
However, the approach introduces increased latency and API costs due to the ensemble nature of the prompting. Future work will focus on optimizing these costs and refining aggregation techniques for open-ended text generation. Overall, DP-ICL provides a robust path forward for deploying LLMs in privacy-sensitive environments.
Summary updated