Flocks of Stochastic Parrots: Differentially Private Prompt Learning for Large Language Models

Haonan Duan, Adam Dziedzic, Nicolas Papernot, Franziska Boenisch

TL;DR

Prompting Large Language Models (LLMs) with sensitive data leaks information, making them highly vulnerable to membership inference attacks. To solve this, this paper introduces the first private prompt learning frameworks: PromptDPSGD for continuous soft prompts and PromptPATE for discrete text prompts. These methods provide strong differential privacy guarantees while maintaining high downstream accuracy, even when interacting with black-box commercial APIs.

What Problem Does This Paper Address?

In-context learning allows LLMs to perform new tasks simply by providing a few examples inside the prompt, completely avoiding the need to modify model weights. However, if these prompt examples contain sensitive information—like medical histories, personal data, or proprietary intellectual property—they pose a massive privacy risk.

To prove this vulnerability, the authors design the first Membership Inference Attack (MIA) specifically targeted at LLM prompts. They demonstrate that an adversary can easily determine whether a specific data point was included in an LLM's prompt just by analyzing the model's output probabilities.

While fine-tuning models with Differential Privacy (DP-SGD) can mitigate privacy leaks, full fine-tuning is computationally expensive, requires massive storage, and demands direct access to model parameters. This makes it completely impractical for state-of-the-art proprietary LLMs (like GPT-4 or Claude) that are only accessible via black-box commercial APIs. This paper tackles the challenge of learning optimal prompts privately without needing to modify or access the underlying LLM's weights.

Methods

The authors propose two distinct algorithms depending on whether the user has white-box or black-box access to the LLM:

1. PromptDPSGD (White-Box)

For scenarios where developers have access to input gradients, the authors introduce PromptDPSGD. Instead of updating millions or billions of model parameters, this method applies DP-SGD exclusively to optimize a small set of continuous soft prompt embeddings prepended to the input. The main LLM remains completely frozen. Gradients are clipped and injected with noise at each step to ensure differential privacy.

2. PromptPATE (Black-Box / API-based)

For commercial APIs where gradients are unavailable, the authors adapt the Private Aggregation of Teacher Ensembles (PATE) framework into PromptPATE.

  • The Flock of Teachers: The private dataset is split into disjoint subsets, each used to create a unique discrete text prompt. This creates an ensemble of prompted LLMs, playfully termed a "flock of stochastic parrots."
  • Noisy Knowledge Transfer: The flock votes on next-token predictions for an unlabeled, public dataset. By applying a noisy majority vote (using the Confident GNMAX algorithm), the ensemble privately labels the public data.
  • Student Prompt Selection: This newly labeled public data is used to evaluate and select a single, high-performing "student prompt" that can be safely deployed in public applications.
Figure 1: Our methods for private prompt learning. Left: PromptDPSGD obtains the input gradients from the LLM, and performs DPSGD to update the soft prompt embedding while keeping the LLM frozen. Right: PromptPATE creates a noisy ensemble of private discrete prompts, and then transfers knowledge by selecting a student prompt that can be publicly released. PromptPATE only needs black-box access of the LLM and, thus, can be easily deployed with commercial APIs.

Datasets

The methods were evaluated across several standard natural language processing benchmarks:

  • Private Downstream Datasets: sst2 (sentiment analysis), qnli (natural language inference), qqp (question pairs), mnli (multinational NLI), dbpedia (wikipedia classification), agnews (news classification), trec (question type classification), and cb (commitment bank).
  • Public Transfer Datasets (for PromptPATE): Tested in both Identically and Independently Distributed (IID) settings and Out-of-Distribution (OOD) settings using imdb, arisetv, and qqp.

Key Insights and Ideas

  • Prompts are highly leaky: The proposed MIA achieved an average AUC-ROC score of 0.84 on the dbpedia dataset using GPT-3, proving that standard prompting inherently violates data confidentiality.
Figure 2: MIA Risk. We study GPT3 prompted with 100 different one-shot examples (dbpedia). left: We present the prediction probabilities at the correct class for members (the one-shot example) and non-members (50 randomly sampled private points). The output probability for members is significantly higher than for non-member data points. right: We present the AUC-ROC curves of our MIA against the 100 prompts (gray lines) and the blue line as an average over all attacks. Given that each prompt has only one member, the resulting TPRs can only be 0% or 100% which leads to the step-shape of the gray curves. The result indicates that our attack is significantly more successful than random guessing (the red dashed line).
  • The Base Model Consensus Advantage: In PromptPATE, because every "teacher" prompt leverages the exact same underlying base LLM, the ensemble naturally achieves exceptionally high consensus when labeling public data. High consensus means fewer queries are rejected and less noise is needed, resulting in remarkably low privacy costs ($\epsilon$).
  • Robustness to Distribution Shift: PromptPATE does not require the public transfer data to perfectly match the private data distribution. For instance, using Wikipedia data (dbpedia) as private data and news articles (agnews) as public transfer data still yielded strong downstream performance.

Key Results

  • Efficiency vs. Fine-Tuning: PromptDPSGD achieves competitive accuracy compared to state-of-the-art private fine-tuning methods (like LoRA) while tuning orders of magnitude fewer parameters (<10K parameters for soft prompts vs. 1.2M for LoRA).
Performance comparison of PromptDPSGD against full tuning and LoRA
  • High Utility at Strict Privacy Budgets: Using GPT-3 (Curie) on the sst2 dataset, PromptPATE achieved a downstream accuracy of 92.7% under a very strict privacy guarantee of ($\epsilon = 0.147, \delta = 10^{-6}$). This closely rivals the non-private baseline accuracy of 95.2%.
  • API Compatibility: On Claude-v1, PromptPATE successfully delivered strong privacy protection ($\epsilon < 0.1$) and high utility using purely black-box text token outputs.

Limitations and Future Work

  • The Trusted API Provider Assumption: PromptPATE protects prompt data privacy from end-users querying the model, but the private data must still be sent to the commercial API provider to generate the teacher ensemble. The authors suggest exploring cryptographic methods (like homomorphic encryption) in future work to remove this reliance on API trust.
  • Unoptimized Templates: The natural language instructions and prompt templates were taken directly from prior literature without optimization. Tuning these templates could yield even higher student accuracy.
  • Monetary Constraints: Due to commercial API costs, the authors could not scale experiments to larger models like GPT-4 or test massive teacher ensembles, which they hypothesize would further improve the privacy-utility trade-off.

Summary updated

BibTeX
@inproceedings{duan2023flocks,
  author = {Haonan Duan and Adam Dziedzic and Nicolas Papernot and Franziska Boenisch},
  title = {{Flocks of Stochastic Parrots: Differentially Private Prompt Learning for Large Language Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=u6Xv3FuF8N},
}
Figure