TL;DR
This paper introduces the "Neighborhood Deviation Attack," a novel method to assess privacy risks in Large Language Models (LLMs) using In-Context Learning (ICL). By analyzing subtle differences in LLM outputs when presented with slightly altered input prefixes, the attack can infer whether a specific data sample was used as an ICL example, demonstrating that LLMs can inadvertently leak information about their training data even in ICL settings.
What Problem Does This Paper Address?
Large Language Models (LLMs) have become incredibly powerful, capable of adapting to new tasks with just a few examples through a technique called In-Context Learning (ICL). This eliminates the need for extensive fine-tuning. However, this flexibility introduces new privacy and security concerns. Specifically, it's unclear how much information about the specific examples used in ICL is retained by the LLM and whether this information could be exploited. Traditional Membership Inference Attacks (MIAs), which aim to determine if a data sample was part of a model's training set, are not directly applicable to the dynamic, output-driven nature of ICL in LLMs. This paper addresses this gap by proposing a new MIA tailored for ICL, aiming to quantify the privacy risks associated with this learning paradigm.
Methods
The core of the proposed "Neighborhood Deviation Attack" lies in analyzing the LLM's output behavior without needing access to its internal parameters (a black-box approach). The method involves these key steps:
- Neighbor Prefix Generation: For a given "target sample," a prefix (the initial part of the sample) is extracted. Then, a set of "neighbor prefixes" are generated by making small, semantically similar alterations to the original prefix (e.g., using synonym replacement).
- Predictive Completion: The LLM, already primed with ICL examples, is used to generate completions for both the original prefix and the generated neighbor prefixes.
- Metric Deviation Calculation: Several metrics (Similarity, BLEU, Perplexity, ROUGE-L) are used to quantify the difference between the LLM's completion of the original prefix and its completion of the neighbor prefixes. These differences, or "deviations," are calculated.
- Membership Determination: A separate attack model (a three-layer neural network) is trained on these metric deviations. This model then predicts whether the original target sample was likely part of the ICL examples based on the magnitude of these deviations. The intuition is that if a sample is a "member" of the ICL set, its completion will be more consistent with the LLM's learned patterns from those examples, leading to smaller deviations compared to neighbor prefixes.
Datasets
The experiments were conducted using three standard text classification datasets:
- DBPedia: Extracted from Wikipedia, covering 14 categories.
- AGNews: Composed of global news articles across four categories.
- TREC: A large dataset for information retrieval and question answering tasks.
The paper also utilized three LLMs: LLaMA3-8B, LLaMA2-7B, and GPT2-XL.
Key Insights and Ideas
- ICL is not perfectly private: The study demonstrates that even when LLMs are used in an ICL setting (without fine-tuning), they can still inadvertently reveal information about the specific examples they are given.
- Subtle output deviations are key: The attack leverages the fact that slight changes in the input prefix can lead to measurable differences in the LLM's generated output. These differences are more pronounced when the input is not part of the original ICL set.
- Multi-metric approach enhances robustness: Relying on a single metric for deviation is suboptimal. Combining multiple metrics (Similarity, BLEU, PPL, ROUGE-L) provides a more comprehensive and stable signal for membership inference.
- Transferability of attack models: A trained attack model can be effective across different LLMs and datasets, highlighting the generalizability of the privacy risks in ICL.
Key Results
- The proposed "Neighborhood Deviation Attack" (NDA) significantly outperforms existing MIA methods like GAP Attack and Repeat Attack in terms of "Advantage" (a measure of attack effectiveness).
- NDA achieved advantage values consistently above 0.8 across all datasets and models, reaching up to 0.91 in some cases.
- The attack demonstrated high stability, maintaining comparable performance across different LLMs and datasets.
- Optimal performance was observed when using 5-10 neighbor samples and a prefix proportion of around 20%.
- A neural network-based attack model proved most effective for membership determination.
Limitations and Future Work
- Static ICL scenarios: The current attack primarily targets static ICL scenarios where the examples remain unchanged. Future work could explore dynamic or multi-instance ICL settings.
- Small deviation differences: When the deviation between member and non-member samples is very small, the attack performance can decrease. The authors suggest exploring preprocessing steps to amplify these differences.
- Defense strategies: The paper briefly discusses potential defenses, including increasing the number of ICL examples to dilute attention, introducing controlled randomness in generation, and using output filtering. Further systematic research into these and other defense mechanisms (like differential privacy) is needed.
- Impact of dataset characteristics: The study noted that dataset characteristics can influence attack performance, suggesting further investigation into how these factors interact with LLM privacy.
Summary updated