Introduction
When I asked my husband if he had any concerns regarding data privacy in large language models (LLMs), he said: “No, I only run my sh** locally.” This approach, keeping data safe and secure on one's own premises, might indeed make for the briefest of blog posts!
But what happens when running everything locally isn't an option? The deployment of LLMs often necessitates interacting with vast, externally sourced datasets, raising significant privacy concerns. These include ensuring the anonymization of sensitive data, preventing inadvertent data leaks, and adhering to stringent privacy regulations like GDPR and CCPA. Furthermore, the potential for LLMs to perpetuate biases presents additional ethical considerations. The actual inspiration for this post came from one of our readers (thank you, Aleks!), he asked if we can address the topic of data privacy since his clients are very concerned about data leakage.
“Many organizations have a straight-out ban on AI technologies,” he wrote, “and the fear is data leakage.”
Building on this topic and continuing last week's discussion on Vulnerabilities in LLMs (Token 1.21), today we explore the technical aspects of data privacy within LLM systems. Our focus will be on:
Data leakage: old fear with a new dimension
Data anonymization techniques and their pivotal role in safeguarding privacy,
The intricacy of data privacy in LLMs,
The principles and applications of Differential Privacy,
How Federated Learning contributes to privacy preservation,
And the emerging technologies shaping the future of data privacy in LLMs.
Data leakage: old fear with a new dimension
Data leakage is not a new fear; any cloud system has the potential to expose private data through vulnerabilities or misconfigurations. Data leakage in LLMs involves the unintended exposure of sensitive information through the model's outputs, stemming from their training on extensive datasets that may contain private data. This can happen directly, through memorization and reproduction of specific data points, or indirectly, via inference from the model's generated content.
Similar to other cloud systems, both LLMs and cloud services face the risk of exposing sensitive data, however, the nuances of data leakage in LLMs set them apart:
Nature of data handling: LLMs uniquely generate new content based on learned information, while other cloud systems typically store, process, or analyze data without creating new outputs.
Memorization vs. Storage: LLMs may leak data due to the model's memorization and overfitting of training data, contrasting with cloud systems where leakage often arises from security misconfigurations or insecure data storage/access.
Output monitoring: The dynamic nature of LLM-generated responses requires vigilant monitoring for potential data leakage, a contrast to the static data management focus in traditional cloud systems.
Dynamic vs. static data concerns: The core challenge with LLMs is managing risks from their dynamic content generation, whereas traditional cloud systems focus on securing static data.
The intricacy of data privacy in LLMs
A joint research of scholars from the National University of Singapore, Cornell University, University of California, and Google Research was the first to point out that existing privacy-preserving techniques can only partially solve issues in data privacy in LLMs.
The fact is that natural language data differs from other types of data in its complexity in the context of data privacy. Moreover, the specifics of LLMs, such as regurgitating large portions of their training data, introduce an additional layer of complexity to preserving privacy.
The intricacies of natural language data include its varied interpretations and specific usage constraints necessary to maintain privacy. Humans generally understand and respect these implicit boundaries, but the challenge lies in conveying these subtle distinctions to an AI model. Read their research paper to learn about this in detail.

Examples of private information and the contexts in which they might be shared. Source: dlm.acm.org
In other words, the definition of data privacy when speaking about natural language is more intricate than for other types of data. Furthermore, algorithms behind inference attacks only improve over time.
Let's explore the technical aspects of data privacy within LLM systems that can be helpful:
Data anonymization techniques and their role in privacy preservation
Data anonymization plays a crucial role in privacy preservation for LLMs and other data-intensive applications. Techniques such as data masking, pseudonymization, generalization, perturbation, swapping, and synthetic data generation help protect sensitive information while maintaining data utility for analysis and machine learning tasks. These methods ensure compliance with privacy regulations like GDPR and HIPAA by obscuring personal identifiers and sensitive details, enabling secure data sharing and analysis without compromising individual privacy.
In the light of recent popularity of retrieval-augmented generation (RAG), there is an interesting paper that studied the privacy implications of retrieval-based language models that incorporate external text data stores to enhance their performance. Their findings reveal that these models are more prone to privacy breaches, exposing private information more readily than traditional models. To mitigate these risks, the team explored various strategies, including data sanitization and modifying the model's architecture, which showed promise in reducing privacy leaks. However, they also identified that completely safeguarding against all forms of data extraction remains challenging, highlighting the ongoing need for further research in balancing model utility with data privacy.
Differential privacy
One of the most widely acceptable formulations of privacy using mathematical terms is called differential privacy (DP). It was proposed in 2014 in the book “The Algorithmic Foundations of Differential Privacy” to deal with “the paradox of learning nothing about an individual while learning useful information about a population.” Differential privacy incorporates random noise into aggregated data to allow data mining without exposing participants’ private information.
The ideas underlying the differential privacy approach can be integrated into LLM in four main ways during pre-training, fine-tuning, prompt tuning, and inference for generating outputs without giving away any private information.
Pre-training
DP's application during the pre-training phase can bolster LLMs against the effects of random noise.
In 2023, Yu et al. introduced a method that uses DP to refine the pre-training process. Their approach selectively uses public data, guided by DP, to focus on information pertinent to specific tasks without exposing sensitive data. This method minimizes the risk of inadvertently memorizing or disclosing private information.

Image Cregit: https://arxiv.org/pdf/2302.07636.pdf
Another application of DP in pre-training is exemplified by DP-BARD, a system designed for privacy-focused text rewriting under Local Differential Privacy (LDP). By employing LDP, DP-BART ensures that any single document's contribution to the overall data analysis is bounded, making it difficult to infer specific details about individual entries. The paper also proposed new techniques that lessen the need for excessive noise, thereby maintaining data quality.
DP-based Fine-tuning
The popular method for the fine-tuning phase is the Differentially Private Stochastic Gradient Descent (DP-SGD) which was proposed in the seminal paper “Deep Learning with Differential Privacy” in 2016. But there are some enhancements to it.
For example, the authors of “Differentially Private Fine-Tuning of Language Models” proposed a meta-framework for DP fine-tuning which is not only simpler but also more efficient in terms of computational and memory costs compared to previous approaches. This framework leverages the recent success of parameter-efficient methods for fine-tuning, allowing for state-of-the-art privacy-utility trade-offs on standard NLP tasks. The proposed parameter-efficient fine-tuning methods significantly reduce the computational and memory overhead typically associated with DP training.
DP-based Prompt Tuning
For generative LLMs, due to their colossal model sizes, parameter-efficient tuning methods such as prompt tuning are widely adopted to tune models on various downstream tasks. Thus, it is imperative to study these efficient tuning methods with DP optimizers for LLMs.

Image credit: https://arxiv.org/pdf/2305.06212.pdf
This paper discusses Privacy-Preserving Prompt Tuning (RAPT) for customizing Large Language Models (LLMs) with private data, ensuring privacy through a local differential privacy approach. Traditional prompt tuning methods struggle with performance when applied to privatized data. RAPT introduces a novel privatized token reconstruction task alongside the main task during training, improving LLM's task-dependent representations and maintaining competitive performance despite privacy constraints.
Another approach to learn prompts privately is a "flock of stochastic parrots," where an ensemble of LLMs, each presented with different prompts, votes on outputs in a manner that transfers knowledge privately to a single public prompt. This method ensures differential privacy and maintains close performance to non-private baselines, demonstrating its effectiveness with experiments using GPT-3 on various datasets. The original paper makes significant contributions by proposing methods for private prompt learning with differential privacy guarantees.
DP-based Synthetic Text Generation
This ensures the generated content doesn't reveal confidential data from its training set. The post-processing theorem guarantees that any edits to this generated text maintain privacy protections.
Federated Learning
Another golden standard of minimizing data leakage is federated learning (FL). It offers a promising approach to enhance data privacy in the training of LLMs by allowing the model to learn from decentralized data without requiring the data to leave its original location.
Despite its potential for preserving privacy, research has shown that FL can be vulnerable to data inference attacks by semi-honest or malicious adversaries. Semi-honest adversaries adhere to the FL protocols but attempt to infer private data based on available information, whereas malicious adversaries might alter training outcomes or model architectures to extract sensitive information.
So, applying FL to LLMs presents unique challenges and opportunities:
Challenges:
Security Risks: FL environments face threats like poisoning and adversarial attacks, endangering system security and privacy during training.
Efficiency Concerns: Large Language Models (LLMs) in FL demand significant computational and communication resources, potentially limiting their deployment.
Non-IID Data Issues: Non-IID data challenges model convergence and performance in FL, posing problems for LLMs.
Privacy Measures: Despite FL's privacy advantages, additional steps may be required to safeguard sensitive data throughout training.
This complexity is reflected in the scarcity of FL libraries in leading deep learning frameworks. Addressing these challenges, Microsoft Research introduced Federated Learning Utilities and Tools for Experimentation (FLUTE), a framework aimed at simplifying large-scale FL experiments. It’s open-sourced, you can find it at https://github.com/microsoft/msrflute.
Opportunities:
Enhanced Generalization: Federated LLM pre-training merges public and private data, broadening knowledge access and ensuring privacy, improving model generalization.
Efficient Fine-tuning: It customizes model tuning to client needs using supervised multi-client data for targeted multi-task training, enhancing collaboration and privacy while improving generalization.
Parameter-Efficient Tuning: Incorporating methods like adapter, prefix, prompt tuning, and LoRA within the federated framework reduces costs and maintains performance.
Prompt Engineering in FL: Combining federated learning with prompt engineering creates private data-based prompts, enhancing LLM's task proficiency and privacy protection.
Several studies have proposed privacy-enhancing defenses for federated LLMs to counter these vulnerabilities. Techniques such as Differential Privacy-Stochastic Gradient Descent (DP-SGD), Privacy-Enhancing Fine Tuning (FedPETuning), and others have been developed to protect against both semi-honest and malicious threats. For example, the use of DP-SGD can help mitigate privacy risks by introducing noise to the training process, thereby making it difficult for adversaries to extract useful information from the model updates.
Pre-training LLMs on public datasets and then customizing these models with private client data under differential privacy constraints has shown promising results for enhancing performance and convergence speed. Techniques like Parameter-Efficient Fine Tuning (PEFT) and model initialization strategies that leverage statistical insights from clients' data to select closely matching samples from public datasets have also been explored to maintain privacy while ensuring effective learning.
For example, "Federated Learning of Large Language Models with Parameter-Efficient Prompt Tuning and Adaptive Optimization" presents FedPepTAO, an innovative framework designed to improve federated learning (FL) for LLMs through the integration of parameter-efficient prompt tuning and adaptive optimization. The framework addresses the challenge of the high parameter count in LLMs, which exacerbates communication costs and complicates FL deployment. FedPepTAO implements a selective prompt tuning approach, updating only essential layers based on their impact on model performance, thus minimizing the parameters exchanged between clients and the central server. A unique scoring method assesses layer importance to optimize this process. Furthermore, FedPepTAO incorporates an adaptive optimization technique to counteract client drift and enhance performance in the presence of non-IID data, marking a substantial progression in federated learning for LLMs.
The paper “Efficient Federated Learning with Pre-Trained Large Language Model Using Several Adapter Mechanisms” introduces an innovative application of FL with pre-trained LLMs through the integration of adapter mechanisms, small capacity layers trained alongside the LLMs. These adapters significantly reduce the volume of data that needs to be transmitted between clients and the server by only updating the adapter parameters, thus maintaining the benefits of pre-trained models while enhancing training and transmission efficiency. The results show a remarkable improvement in transmission speed by over 98% and a reduction in training time by 20–40%, highlighting the potential of adapters to make FL with LLMs more practical and scalable in preserving data privacy.
Emerging technologies for data privacy in LLMs
“A Survey on Large Language Model (LLM) Security and Privacy” highlights several promising directions for leveraging LLMs in machine learning for security tasks. These directions include:
Exploiting LLMs for ML-Specific Security Tasks: Observations suggest that LLMs can effectively substitute traditional machine learning methods in security applications. This transition from traditional methods to LLMs opens up new possibilities in areas like malware detection, suggesting that LLMs could be pivotal in enhancing security measures.
Automating Security Efforts: LLMs offer the potential to automate tasks traditionally requiring human effort, such as social engineering. This shift indicates a significant opportunity for security research, focusing on replacing or augmenting human roles in security operations with LLMs.
Adapting Traditional ML Attacks for LLMs: Security vulnerabilities in LLMs often mirror those in traditional machine learning models. This similarity means that with adjustments, conventional ML attack techniques remain relevant and can be tailored to exploit vulnerabilities specific to LLMs, such as adversarial attacks.
Applying Traditional ML Defenses to LLMs: Countermeasures used against vulnerabilities in traditional ML can be adapted for LLMs. Exploring Privacy-Enhancing Technologies (PETs) and other defenses in the context of LLMs could be key in mitigating privacy and security risks.
Addressing LLM-Specific Attack Challenges: The unique aspects of LLMs, including their vast parameter space and the private nature of the most powerful models, introduce new challenges for security. Developing novel approaches or modifying existing ones to tackle these challenges is essential for the future of secure LLM deployment.
Conclusion
There are no one-size-fits-all solutions when discussing data privacy in LLM systems. It should be approached in a balanced manner, with a clear understanding that our data fuels these systems, and although daunting, these systems are primarily designed to benefit us. It requires a carefully scaled combination of internal and external information sources with user interaction. For instance, creating a platform for anonymous health inquiries necessitates stringent privacy controls to protect sensitive user data.
While the data privacy challenges in LLMs are substantial, they are surmountable with the correct knowledge and practices. We encourage a balanced perspective on AI development, advocating for innovation that does not compromise privacy standards; as well as prioritizing data privacy as an integral component of ethical AI development.
References
There is a heightened relevance of privacy in the digital age. This growing importance has led to the establishment of comprehensive privacy regulations worldwide, such as the GDPR in the EU and the CCPA in California, aimed at enhancing individuals' control over their personal data. A few docs from The Usual Suspects:
Thank you for reading, please feel free to share with your friends and colleagues. In the next couple of weeks, we are announcing our referral program 🤍







