TL;DR
This paper introduces the first code completion Large Language Model (LLM) for IDEs that is fine-tuned with formal Differential Privacy (DP) guarantees. By applying DP-SGD and LoRA to a Kotlin code completion model, they demonstrate a robust defense against Membership Inference Attacks (MIAs) with minimal impact on model utility, making private code completion a practical reality.
What Problem Does This Paper Address?
Modern Integrated Development Environments (IDEs) are increasingly incorporating AI-powered features like code completion, often leveraging Large Language Models (LLMs). These LLMs are typically trained on vast amounts of code, including potentially sensitive proprietary code from users. This raises significant privacy concerns, as LLMs can "memorize" training data and inadvertently leak sensitive information like secrets or API credentials through attacks like Membership Inference Attacks (MIAs). MIAs aim to determine if a specific piece of code was part of the model's training set, which would be a major privacy breach for developers and organizations. While Differential Privacy (DP) offers a strong theoretical framework for privacy, its practical application in training large LLMs has been challenging due to computational costs and potential performance degradation. This paper addresses the gap of applying formal DP guarantees to LLMs specifically for code completion in IDEs, aiming to provide a practical and effective privacy solution.
Methods
The authors fine-tune a pre-trained LLM called "Mellum" (specifically, the Mellum SFT model, a 4-billion-parameter Transformer with Fill-in-the-Middle capabilities) on a private dataset of Kotlin code. To achieve differential privacy, they employ Differentially Private Stochastic Gradient Descent (DP-SGD). DP-SGD modifies the standard gradient descent process by:
- Per-Example Gradient Computation: Calculating gradients for each individual training example.
- Gradient Clipping: Limiting the influence of any single example by scaling down its gradient if its L2 norm exceeds a predefined threshold (C).
- Noise Addition: Adding carefully calibrated random noise (from a Gaussian distribution) to the averaged clipped gradients before updating the model weights.
- Model Update: Using the noisy gradient to update the model.
To make this computationally feasible for LLMs, they also use Low-Rank Adaptation (LoRA), a parameter-efficient fine-tuning technique. LoRA freezes the pre-trained model weights and injects a small number of trainable, low-rank matrices, significantly reducing the number of parameters that need to be updated and thus the dimensionality of the gradients. This allows for more efficient DP training. A "privacy accountant" tracks the cumulative privacy cost (ε, δ) throughout training.
Datasets
- Training Data:
- Private Dataset: 8 million Kotlin code instances from internal JetBrains repositories. This dataset was used for fine-tuning both the baseline and the DP model.
- Public Pre-training Data: The Mellum SFT model was pre-trained on over 4 trillion tokens of public code from multiple programming languages.
- Evaluation Data:
- Internal Kotlin Benchmark Dataset: A separate dataset of Kotlin code, unseen during training, was used to evaluate model performance (utility).
Key Insights and Ideas
- DP as a Practical Defense for Code LLMs: The paper demonstrates that DP is not just a theoretical concept but a practical and effective defense against privacy risks in real-world code completion LLMs.
- LoRA's Synergy with DP: Using LoRA significantly reduces the computational burden of DP-SGD, making it more feasible to train large models with privacy guarantees.
- Favorable Privacy-Utility Trade-off: The DP-trained model achieves strong privacy protection with only a marginal, statistically insignificant drop in performance compared to its non-private counterpart.
- DP as a Regularizer: The authors suggest that DP-SGD might act as a strong regularizer, potentially leading to better generalization even when trained on less data.
- Looser Privacy Budgets Can Still Be Effective: While theoretical DP work often targets very small ε values (≤ 10), this study shows that a privacy budget of ε ≈ 30 still provides robust protection against MIAs in this context, aligning with prior research.
Key Results
- Privacy: The differentially private model (Mellum Int. DP) achieved an AUC of 0.606 for Membership Inference Attacks (MIAs), which is very close to a random guess (AUC = 0.5), indicating strong privacy. In contrast, the non-private baseline (Mellum Int. Base) had an AUC of 0.901, showing high vulnerability to MIAs.
- Utility:
- CHRF++: Mellum Int. DP achieved 74.781 ± 0.342, compared to Mellum Int. Base at 75.256 ± 0.349. This is a marginal decrease.
- LLM-AS-JUDGE: Mellum Int. DP scored 0.730 ± 0.003, while Mellum Int. Base scored 0.753 ± 0.002.
- LM SCORE: Mellum Int. DP achieved 0.613 ± 0.005, compared to Mellum Int. Base at 0.643 ± 0.005.
- The DP model even outperformed the original Mellum SFT model in all utility metrics.
- Data Efficiency: The DP model achieved comparable utility while being fine-tuned on significantly less data (80K instances) compared to the non-DP baseline (8M instances).
- Privacy Budget Accumulation: The privacy budget (ε) increased gradually with the number of training data points seen, illustrating the cost of training. The final privacy budget was approximately ε ≈ 30.
Limitations and Future Work
- Limitations:
- The achieved privacy budget (ε ≈ 30) is higher than what is typically targeted in theoretical DP research (ε ≤ 10). However, the authors argue it still provides practical and robust protection.
- The DP model's validation loss was consistently higher than the non-DP model, which is an expected consequence of DP-SGD due to the added noise, slightly impeding optimization.
- Future Work:
- Explore the privacy-utility trade-off more deeply by experimenting with stricter privacy budgets (lower ε values) and their impact on model quality.
- Investigate the effects of training on more data with DP.
- Further research into optimizing DP training for LLMs to minimize utility loss.
Summary updated