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

Haonan Duan, Adam Dziedzic, Nicolas Papernot, Franziska Boenisch

Introduction

The paradigm of "in-context learning" has revolutionized how users interact with Large Language Models (LLMs). By providing a few labeled examples within a prompt, users can steer models toward specific tasks without traditional fine-tuning. However, this convenience introduces a significant security risk: prompts often contain sensitive information, such as medical records or proprietary intellectual property. This paper investigates the privacy implications of prompting and introduces the first frameworks for differentially private (DP) prompt learning: PromptDPSGD and PromptPATE.

The Privacy Gap: Membership Inference in Prompts

Before proposing solutions, the authors establish the severity of the threat by developing the first Membership Inference Attack (MIA) specifically targeting LLM prompts. An MIA allows an adversary to determine whether a specific data point was included in the prompt used to generate a model's output.

The results are stark: on the DBPedia dataset, the MIA achieved an average Area Under the Curve (AUC) of 0.84. This confirms that prompts do not inherently protect the data they contain; rather, they act as a "leaky" channel that can expose sensitive training examples to anyone with access to the model's outputs.

Overcoming the Limitations of DP Fine-Tuning

Differential Privacy (DP) is the gold standard for providing formal privacy guarantees. However, applying DP to LLMs via traditional fine-tuning (e.g., DP-SGD on all model weights) is often impractical for two reasons:

  1. Resource Intensity: Fine-tuning models with billions of parameters is computationally expensive and requires massive storage for each task-specific version.
  2. Black-Box Constraints: State-of-the-art models like GPT-4 or Claude are typically accessed via APIs. These APIs do not provide the gradient access required for standard DP-SGD.

To address these challenges, the authors propose shifting the focus from the model's internal weights to its input interface.

Proposed Frameworks

PromptDPSGD: Private Soft Prompts

For scenarios where users have access to model gradients (e.g., locally hosted open-source models), the authors introduce PromptDPSGD. Instead of updating the entire model, this method applies DP-SGD to "soft prompts"—continuous vector embeddings prepended to the input. By keeping the LLM frozen and only updating a tiny fraction of the parameters, PromptDPSGD achieves high efficiency while providing formal privacy.

PromptPATE: Private Discrete Prompts for Black-Box APIs

The paper’s most significant contribution is PromptPATE, designed for the "black-box" setting where only model outputs are available. This framework adapts the Private Aggregation of Teacher Ensembles (PATE) mechanism:

  • The Ensemble (The "Flock"): The private dataset is partitioned into disjoint subsets. Each subset is used to prompt a separate instance of the LLM (a "teacher").
  • Noisy Voting: These teachers are asked to label a set of unlabeled public data. Their votes are aggregated using a noisy mechanism (Confident GNMAX), which ensures that the resulting labels are differentially private.
  • Knowledge Transfer: The privately labeled public data is used to select or train a single "student prompt." This student prompt can then be used publicly with a single LLM call, effectively distilling the collective knowledge of the ensemble without exposing the private examples.

Experimental Evaluation

The authors evaluated these methods across a variety of NLP benchmarks, including sentiment analysis (SST-2), natural language inference (QNLI, MNLI), and topic classification (DBPedia, AGNews).

Performance and Privacy

PromptPATE demonstrated remarkable utility even under strict privacy budgets. On the SST-2 dataset, using GPT-3 as the backbone, PromptPATE achieved 92.7% accuracy with a privacy budget of $\epsilon = 0.147$. This is remarkably close to the non-private baseline of 95.2%.

Efficiency vs. Fine-Tuning

In comparisons with standard DP fine-tuning, PromptDPSGD proved superior. On SST-2, it achieved 92.31% accuracy, significantly outperforming full DP fine-tuning (85.89%). This suggests that tuning the input interface is not only more efficient but can also be more effective for downstream task adaptation under privacy constraints.

Robustness to Distribution Shift

A key finding was the robustness of PromptPATE to Out-of-Distribution (OOD) public data. The framework maintained high performance even when the public data used for the student (e.g., Wikipedia) differed significantly from the private teacher data (e.g., news articles).

Conclusion and Future Work

This research demonstrates that while prompts are inherently vulnerable to data leakage, they also provide a unique opportunity for efficient, differentially private adaptation. PromptPATE, in particular, offers a viable path for using sensitive data with commercial black-box APIs like Claude and GPT-3.

However, challenges remain. The current framework assumes the API provider is a "trusted" entity during the teacher phase. Future research may explore cryptographic solutions to eliminate this dependency. Additionally, the monetary cost of running large ensembles via paid APIs remains a barrier to scaling these methods to the most advanced models.

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