Privacy-Aware In-Context Learning for Large Language Models

Bishnu Bhusal, Manoj Acharya, Ramneet Kaur, Colin Samplawski, Anirban Roy, Adam D. Cobb, Rohit Chadha, Susmit Jha · DOI

Abstract

This paper introduces a novel framework for privacy-preserving In-Context Learning (ICL) that generates high-quality synthetic demonstrations without requiring expensive model fine-tuning. By aggregating and "blending" logit distributions from private and public prompts under a Differential Privacy (DP) mechanism, the authors enable Large Language Models (LLMs) to perform downstream tasks effectively while providing strong, mathematically proven guarantees against sensitive data leakage.

Introduction

Large Language Models are often tailored for specific tasks using prompt engineering, which frequently involves including sensitive examples—such as clinical records or private emails—directly in the prompt. This creates a massive privacy risk: adversaries can potentially extract this sensitive information through "jailbreak" attacks or by analyzing the model's outputs.

Existing solutions generally fall into two camps: private fine-tuning (e.g., DP-SGD), which is computationally expensive and requires full parameter access, and private prediction. While easier to implement, current private prediction methods suffer from a "privacy budget explosion"—the more tokens generated, the more the privacy guarantee weakens, often resulting in short or incoherent text. This research aims to bridge this gap by creating a system that generates long, coherent synthetic text that maintains high utility for ICL while staying within a strict privacy budget.

Methodology

The researchers propose a two-stage framework centered on a Private Synthetic Examples Generation algorithm. The process involves several key technical innovations:

The proposed framework for Private Synthetic Examples Generation, showing the pipeline from sensitive text to blended logit distributions and final token generation.
  • Logit Aggregation: Instead of using a single private prompt, the system runs parallel inference on a subset of private records to extract "logits" (raw scores for every possible next token).
  • Clipping and Centering: To bound the "sensitivity" (how much one record can change the output), the logits are clipped and re-centered. This ensures no single outlier record dominates the generation, a crucial requirement for Differential Privacy.
  • Public-Private Blending: The algorithm generates a "public" logit distribution using a generic prompt and blends it with the aggregated private signal. This allows the public prompt to provide the linguistic structure while the private data provides the task-specific signal.
  • Exponential Mechanism: The next token is sampled from this blended distribution using a temperature-scaled softmax, satisfying $(\epsilon, \delta)$-differential privacy.
  • Efficiency via KV-Caching: By using a fixed subset and reusing the KV-cache, the method achieves linear computational cost, avoiding the quadratic costs of previous resampling methods.

Experimental Results

The framework was evaluated across diverse benchmarks, including news classification (AGNews), topic classification (DBPedia), and information extraction (MIT-G, MIT-D).

Performance comparison of the proposed method against state-of-the-art baselines across multiple datasets and privacy budgets.

At a strict privacy budget of $\epsilon=1$, the proposed method outperformed previous state-of-the-art baselines on three out of five tasks. For example, on AGNews, it achieved 79.5% accuracy compared to the previous best of 75.9%. In structured data tasks (WikiMoviesJSON), the method achieved an 84.2% parse rate under $\epsilon=1$, significantly higher than the baseline's 80.6%.

Empirical privacy tests confirmed the framework's robustness. It successfully prevented the leakage of sensitive email addresses from the Enron dataset and reduced the Membership Inference Attack (MIA) success rate from a non-private AUC of 94.20 to a near-random 51.78.

Key Insights and Discussion

  • The Power of Blending: A major finding is that private data does not need to provide the grammar or structure of a sentence; a public prompt can handle that. Blending allows for much lower noise injection while maintaining coherence.
  • Simplified Mechanisms: The paper demonstrates that simple averaging and clipping are more effective than complex threshold-tuning methods like the Sparse Vector Technique (SVT), providing tighter privacy bounds and better utility.
  • Synthetic as a Buffer: By generating synthetic data first, the privacy cost is paid once during the offline phase. Subsequent queries using those synthetic examples incur no additional privacy cost due to the post-processing property of DP.

Limitations and Future Work

While the method sets a new state-of-the-art for private ICL, a utility gap remains compared to non-private "Real Data" benchmarks. Additionally, as the number of "shots" in ICL increases, performance can sometimes degrade as the private signal is diluted by DP noise. Future research will explore ways to generate entire sentences or paragraphs with a flat privacy cost, addressing the accumulation of the privacy budget with every generated token.

Summary updated

BibTeX
@inproceedings{bhusal2026privacy,
  author = {Bishnu Bhusal and Manoj Acharya and Ramneet Kaur and Colin Samplawski and Anirban Roy and Adam D. Cobb and Rohit Chadha and Susmit Jha},
  title = {{Privacy-Aware In-Context Learning for Large Language Models}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2026},
  doi = {10.1609/aaai.v40i42.40838},
}
Figure