PrivCode: When Code Generation Meets Differential Privacy
Zheng Liu, Chen Gong, Terry Yue Zhuo, Kecen Li, Weichen Yu, Matt Fredrikson, Tianhao Wang
Abstract
Large language models (LLMs) have presented outstanding performance in code generation and completion. However, fine-tuning these models on private datasets can raise privacy and proprietary concerns, such as the leakage of sensitive personal information. Differentially private (DP) code generation provides theoretical guarantees for protecting sensitive code by generating synthetic datasets that preserve statistical properties while reducing privacy leakage concerns. However, DP code generation faces significant challenges due to the strict syntactic dependencies and the privacy-utility trade-off. We propose PrivCode, the first DP synthesizer specifically designed for code datasets. It incorporates a two-stage framework to improve both privacy and utility. In the first stage, termed "privacy-sanitizing", PrivCode generates DP-compliant synthetic code by training models using DP-SGD while introducing syntactic information to preserve code structure. The second stage, termed "utility-boosting," fine-tunes a larger pre-trained LLM on the synthetic privacy-free code to mitigate the utility loss caused by DP, enhancing the utility of the generated code. Extensive experiments on four LLMs show that PrivCode generates higherutility code across various testing tasks under four benchmarks. The experiments also confirm its ability to protect sensitive data under varying privacy budgets. We provide the replication package at the anonymous link. 1 Corresponding Author (Chen Gong). Zheng and Kecen work as independent researchers and remote interns at UVA.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
2 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- PrivORL: Differentially Private Synthetic Dataset for Offline Reinforcement Learning cites BERTScore: Evaluating Text Generation with BERT
- PrivORL: Differentially Private Synthetic Dataset for Offline Reinforcement Learning cites Deep Learning with Differential Privacy
- DP-SAPF: Saliency-Aware Parameter Fine-tuning of Public Models for Differentially Private Image Synthesis cites LoRA: Low-Rank Adaptation of Large Language Models
- DP-SAPF: Saliency-Aware Parameter Fine-tuning of Public Models for Differentially Private Image Synthesis cites PrivORL: Differentially Private Synthetic Dataset for Offline Reinforcement Learning
- DP-SAPF: Saliency-Aware Parameter Fine-tuning of Public Models for Differentially Private Image Synthesis cites Deep Learning with Differential Privacy
- Extracting Training Data from Large Language Models cites Deep Learning with Differential Privacy
Cited by top-tier papers2
- PrivORL: Differentially Private Synthetic Dataset for Offline Reinforcement LearningChen Gong, Zheng Liu, Kecen Li, Tianhao WangNDSS 2026 · 3 citations
- DP-SAPF: Saliency-Aware Parameter Fine-tuning of Public Models for Differentially Private Image SynthesisChen Gong, Kecen Li, Zinan Lin, Tianhao WangUSENIX Security 2026
Builds on36
- LoRA: Low-Rank Adaptation of Large Language ModelsEdward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu et al.ICLR 2022 · 18,833 citations
- BERTScore: Evaluating Text Generation with BERTTianyi Zhang, Varsha Kishore, Felix Wu, Kilian Q. Weinberger et al.ICLR 2020 · 8,443 citations
- Deep Learning with Differential PrivacyMartín Abadi, Andy Chu, Ian J. Goodfellow, H. Brendan McMahan et al.CCS 2016 · 7,620 citations
- Finetuned Language Models are Zero-Shot LearnersJason Wei, Maarten Bosma, Vincent Y. Zhao, Kelvin Guu et al.ICLR 2022 · 4,966 citations
- Extracting Training Data from Large Language ModelsNicholas Carlini, Florian Tramèr, Eric Wallace, Matthew Jagielski et al.USENIX Security 2021 · 2,866 citations
Related papers
- PrivCode++: Latent-Conditioned Differentially Private Code Generation for Comprehensive GuaranteesZheng Liu, Chen GONG, Terry Yue Zhuo, Zhou Yang et al.ICML 2026
- Private Seeds, Public LLMs: Realistic and Privacy-Preserving Synthetic Data GenerationQian Ma, Sarah RajtmajerACL Findings 2026
- DPGA-TextSyn: Differentially Private Genetic Algorithm for Synthetic Text GenerationZhonghao Sun, Zhiliang Tian, Yiping Song, Yuyi Si et al.ACL Findings 2025
- Synthesizing Privacy-Preserving Text Data via Finetuning without Finetuning Billion-Scale LLMsBowen Tan, Zheng Xu, Eric P. Xing, Zhiting Hu et al.ICML 2025
- RewardDS: Privacy-Preserving Fine-Tuning for Large Language Models via Reward Driven Data SynthesisJianwei Wang, Chengming Shi, Junyao Yang, Haoran Li et al.EMNLP 2025
