TL;DR
This paper introduces the first provably differentially private (DP) framework for the cross-attention mechanism, protecting sensitive data embedded in system prompts and Retrieval-Augmented Generation (RAG) contexts. By reframing cross-attention as a weighted distance problem and utilizing a novel tree-based data structure with truncated Laplace noise, the authors achieve strong $(\epsilon, \delta)$-DP guarantees and robustness against adaptive adversarial queries. Remarkably, the added privacy error naturally diminishes to zero as the input sequence length grows.
What Problem Does This Paper Address?
Cross-attention is a foundational module in modern Large Generative Models (LGMs), powering critical applications like RAG, system prompting, and guided diffusion models. It allows a model to dynamically weigh and extract information from external data sources. However, the underlying key ($K$) and value ($V$) matrices frequently encode highly sensitive user data or proprietary business logic. Recent studies have shown that these prompts and contexts can be easily recovered or leaked via adversarial user attacks.
While traditional privacy techniques like DP-SGD protect training data during the fine-tuning stage, they are computationally expensive, require full model retraining, and do not explicitly safeguard the attention layers from leaking context data during inference. This paper addresses the lack of theoretical privacy guarantees specifically tailored to the cross-attention mechanism, ensuring that sensitive external data remains secure even when interacting with untrusted users who submit adaptive queries.
Methods
The authors propose a novel data structure called DPCrossAttention that integrates differential privacy directly into the attention computation through three main steps:
- Reframing Cross-Attention as a Distance Problem: The standard Softmax cross-attention calculation relies on exponential inner products, which do not naturally conform to standard DP noise-addition techniques. The authors use polynomial kernel approximation methods to transform the cross-attention mechanism into a weighted $\ell_2^2$ distance problem.
- The DPTree Data Structure: To privately answer these distance queries, they design
DPTree, a binary summation segment tree. Instead of adding noise directly to the final outputs or to every single element in a flat array (which would cause the error to grow linearly with the sequence length $n$), they inject truncated Laplace noise into the nodes of the tree. This hierarchical approach ensures that the error only increases by a factor of $\text{poly}(\log n)$. - Defending Against Adaptive Queries: In adversarial settings, attackers can choose subsequent queries based on the model's previous outputs. To maintain privacy under these conditions, the authors boost the algorithm's success probability using a Chernoff bound and employ an $\epsilon_0$-net/metric entropy argument to bound the error across the entire query space, ensuring robustness against adaptive attacks.
Datasets
Not discussed in the paper. The work is entirely theoretical, focusing on algorithmic design, complexity analysis, and provable privacy/utility bounds rather than empirical evaluation on standard datasets.
Key Insights and Ideas
- Mathematical Equivalence: The core breakthrough is demonstrating that Softmax cross-attention can be accurately approximated and computed as a weighted distance problem using polynomial kernels and the Law of Cosines.
- Privacy at Scale: A highly encouraging finding is that the additive privacy error is inversely proportional to the input sequence length ($n$). As context windows grow larger—a major trend in modern generative AI—the relative impact of the privacy-preserving noise approaches zero, meaning longer contexts naturally enjoy better utility.
- Hierarchical Noise Injection: By injecting noise into a tree structure rather than a flat array, the framework prevents privacy loss from compounding dramatically across multiple token queries, allowing the system to safely handle long generations.
Key Results
- Privacy Guarantees: The proposed framework provides provable $(\epsilon, \delta)$-differential privacy for cross-attention computations.
- Algorithmic Complexity: For an input sequence length $n$ and feature dimension $d$, the data structure achieves $\widetilde{O}(ndr^2)$ space and initialization complexity, with a query time of $\widetilde{O}(dr^2)$ per token (where $r$ is the parameter for the polynomial kernel method).
- High Utility: The mechanism guarantees a relative error of $2\epsilon_s/(1-\epsilon_s)$ and an additive error bounded by $\widetilde{O}((1-\epsilon_s)^{-1} n^{-1} \epsilon^{-1} R^{2s} R_w r^2)$ relative to the ground truth, confirming that utility remains high as the sequence length increases.
Limitations and Future Work
- Extension to Self-Attention: The current framework is restricted to cross-attention, where the key and value matrices are fixed before inference. Extending this to self-attention is highly challenging because the tree nodes would need to be dynamically updated for every single query token, which the current static analysis does not support.
- Kernel Parameter Scaling: The feature dimension and kernel parameters ($r, s$) directly impact the computational complexity. Optimizing these polynomial approximations for exceptionally high-dimensional spaces remains an open problem.
- Empirical Validation: Because this paper is purely theoretical, implementing
DPCrossAttentionin production-scale large language models to measure the actual impact on downstream task accuracy and hardware latency is left for future research.
Summary updated