PrivCode: When Code Generation Meets Differential Privacy

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Liu, Zheng, Gong, Chen, Zhuo, Terry Yue, Li, Kecen, Yu, Weichen, Fredrikson, Matt, Wang, Tianhao
Natura: Preprint
Pubblicazione: 2025
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866911376552755200
author Liu, Zheng
Gong, Chen
Zhuo, Terry Yue
Li, Kecen
Yu, Weichen
Fredrikson, Matt
Wang, Tianhao
author_facet Liu, Zheng
Gong, Chen
Zhuo, Terry Yue
Li, Kecen
Yu, Weichen
Fredrikson, Matt
Wang, Tianhao
contents 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 higher-utility 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.
format Preprint
id arxiv_https___arxiv_org_abs_2512_05459
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle PrivCode: When Code Generation Meets Differential Privacy
Liu, Zheng
Gong, Chen
Zhuo, Terry Yue
Li, Kecen
Yu, Weichen
Fredrikson, Matt
Wang, Tianhao
Cryptography and Security
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 higher-utility 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.
title PrivCode: When Code Generation Meets Differential Privacy
topic Cryptography and Security
url https://arxiv.org/abs/2512.05459