Manuscript Offprint

arXiv:2610.13132

DP-MIND: Differentially private memory-guided Long context Inference

Zhihao Liu, Yitian Cheng, Shuang Liu, Rui Wen, Yuke Hu, Zhan Qin

ABSTRACT

LLM-as-a-Service has become a dominant paradigm for accessing large language models without requiring local deployment. However, the process raises severe privacy concerns when user queries may include sensitive or confidential contexts. Differential privacy (DP) provides a principled approach to protecting such inputs, while existing DP inference methods are primarily designed for short- or moderate-context settings and struggle with million-token-scale inputs due to limited context capacity and severe utility degradation under DP perturbation.

In this paper, we propose DP-MIND, a memory-guided framework that scales differentially private inference to million-token contexts. DP-MIND enables private long-context inference by locally perturbing the input and processing it chunk by chunk with a compact memory that preserves task-relevant information across the sequence. To make this memory robust to DP noise, we optimize the memory construction policy directly on perturbed inputs using reinforcement learning, guided by both final answer correctness and memory consistency. We further recover perturbation-corrupted answer spans through a local denoising module without exposing the original context to the external model. We provide theoretical privacy analysis of DP-MIND and further conduct extensive empirical analysis across multiple long-context benchmarks with context lengths up to the million-token scale, demonstrating that DP-MIND consistently outperforms existing DP and long-context inference baselines in both scalability and utility.

1 INTRODUCTION

Large language models (LLMs) have rapidly become a general-purpose interface for knowledge-intensive tasks, including question answering, document analysis, code generation, personal assistance, and decision support (Zhao et al., 2026; Song et al., 2025). Rather than deploying these models locally, users increasingly access them through “LLM-as-a-Service” platforms (Brown et al., 2020; Ouyang et al., 2022; Chowdhery et al., 2022; Qwen Team, 2025), where prompts and contextual documents are submitted to remote model providers for inference. This service-oriented paradigm makes advanced LLMs broadly accessible, but it also raises a fundamental privacy concern: users often need to transmit sensitive context to remote model providers. Such context may contain private conversations, medical or financial records, source code, legal documents, or other confidential information (Chen et al., 2025; Bai et al., 2025).

Differential privacy (DP) provides a principled approach to protecting sensitive user contexts during remote LLM inference. Existing privacy-preserving inference methods primarily focus on improving the privacy–utility trade-off. DP-Forward perturbs intermediate representations (Du et al., 2023), while ObfusLM combines embedding obfuscation and shuffling against inversion attacks (Lin et al., 2025). Recent methods explore batch-level request sharing (Mai et al., 2026) and token-level DP that limits the influence of sensitive context tokens (Thareja et al., 2026). To recover utility after privacy protection, Split-and-Denoise and InferDPT employ denoising and response extraction, respectively (Mai et al., 2024; Tong et al., 2025). DP 3^{3} further extends the investigation to multi-turn inference, addressing privacy-budget consumption and semantic consistency (Zheng et al., 2026).

Although prior methods have made substantial efforts to improve the “privacy–utility” trade-off, they are primarily designed for standard short- or moderate-context inference and do not address the key challenges posed by million-token-scale inputs: context lengths that exceed the model’s effective processing capacity, severe utility degradation caused by DP noise, and substantial inference overhead. Even when the input fits within the context window, LLMs may struggle to reliably retrieve and utilize relevant information from long contexts (Liu et al., 2024).

Driven by the limitations of standard transformer inference, recent non-private long context methods have explored several directions, including context-window extension, sparse or linear attention and memory-augmented inference. Context-window extension methods enlarge the usable context length through positional adaptation (Chen et al., 2023b; Peng et al., 2024; Ding et al., 2024; Yang et al., 2025), while sparse attention and memory-based methods improve long-context scalability through efficient attention patterns and compact memory states (Beltagy et al., 2020; Zaheer et al., 2020; Yu et al., 2026). These techniques demonstrate the feasibility of scaling non-private long-context inference and provide potential directions for DP long-context inference.

In this paper, we strive to bridge this gap by studying differentially private long-context inference through the lens of memory-augmented inference that are previously under-explored in DP-literature. We propose DP-MIND, a memory-guided framework for differentially private long-context inference. To address the challenges of limited context capacity, DP-MIND partitions the long context into locally perturbed chunks and processes them sequentially, while a compact memory propagates task-relevant information across chunks without exposing the clean context. The memory policy is further optimized directly under DP perturbation using reinforcement learning, guided jointly by final answer correctness and memory consistency with the corresponding clean reference memory. In addition, DP-MIND employs a trusted local denoising module that leverages the alignment between clean and perturbed contexts to restore corrupted answer spans, improving answer utility without exposing the clean context to the external LLM. Our main contributions are summarized as follows:

• To the best of our knowledge, we are the first to systematically study differentially private inference in million-token-scale long-context settings, where existing DP inference methods face fundamental challenges in scalability, utility, and efficiency.

• We propose DP-MIND, a memory-guided framework that combines chunk-wise perturbation with sequential memory propagation for DP long-context inference, and provide a comprehensive theoretical analysis of the privacy guarantee.

• We design a DP-aware reinforcement learning objective for memory construction, with a reward that jointly captures final answer correctness and memory consistency under DP perturbation. We further introduce a trusted local denoising module that restores corrupted answer spans while keeping the clean context entirely local.

• We conduct extensive experiments across multiple long-context benchmarks, privacy budgets, and context lengths up to the million-token scale. The results demonstrate that DP-MIND substantially outperforms existing DP and long-context inference baselines under DP perturbation.

References (43)

  • Safeguarding user data privacy in online large language model services
  • Longformer: The Long-Document Transformer
  • NeurIPS, 2020
  • A customized text sanitization mechanism with differential privacy
  • A survey on privacy risks and protection in large language models
  • Extending context window of large language models via positional interpolation (opens arXiv in a new tab)
  • Dynamic long context reasoning over compressed memory via end-to-end reinforcement learning
  • PaLM: Scaling Language Modeling with Pathways
  • LongRoPE: Extending LLM context window beyond 2 million tokens
  • DP-Forward: Fine-tuning and inference on language models with differential privacy in forward pass
  • The Algorithmic Foundations of Differential Privacy, volume 9 of Foundations and Trends in Theoretical Computer Science
  • Our data, ourselves: Privacy via distributed noise generation
  • Privacy- and utility-preserving textual analysis via calibrated multivariate perturbations
  • RULER: What's the Real Context Size of Your Long-Context Language Models?
  • Privacy-preserving language model service against embedding inversion attacks
  • Lost in the middle: How language models use long contexts
  • Split-and-denoise: Protect large language model inference with local differential privacy
  • Sharedrequest: Privacy-preserving model-agnostic inference for large language models
  • NeurIPS, 2022
  • YaRN: Efficient context window extension of large language models
  • Injecting domain-specific knowledge into large language models: a comprehensive survey (opens arXiv in a new tab)
  • Dp-fusion: Token-level differentially private inference for large language models
  • Inferdpt: Privacy-preserving inference for closed-box large language models
  • Bolt-on differential privacy for scalable stochastic gradient descent-based analytics
  • A differentially private text perturbation method using a regularized mahalanobis metric
  • Qwen2.5 Technical Report
  • An Yang, Bowen Yu, Chengyuan Li, Dayiheng Liu, Fei Huang, Haoyan Huang, Jiandong Jiang, Jianhong Tu, Jianwei Zhang, Jingren Zhou, et al. Qwen2.5-1m technical report. arXiv preprint arXiv:2501.15383, 2025. URL https://arxiv.org/abs/2501.15383. (opens arXiv in a new tab)
  • HotpotQA: A dataset for diverse, explainable multi-hop question answering
  • Reshaping long-context llm with multi-conv rl-based memory agent
  • Differential privacy for text analytics via natural text sanitization
  • Big bird: Transformers for longer sequences
  • Frontiers of Computer Science, 20(12):2012627, 2026
  • Dp3: Differentially private prompt perturbation for multi-turn llm inference
  • Specifically, each token is mapped to its embedding representation, perturbed with calibrated noise, and then projected back to the nearest token in the vocabulary
  • No previous memory
  • The memory update prompt incrementally integrates task-relevant information from each chunk, while the final answer prompt generates the prediction using only the accumulated differentially private memory
  • Read the section carefully and update the memory with any new information that helps answer the problem
  • The memory may contain noise or omit some details due to privacy-preserving perturbation
  • Therefore, the answer is (insert answer here)
  • EM measures exact string match after normalization
  • Chunk-only splits the context into chunks and queries them without memory propagation
  • All values are percentages
  • Results are reported on Single, Multi-Key (M-Key), and Multi-Query (M-Query) settings, where ↑ indicates higher is better