How Quantization Impacts Privacy Risk on LLMs for Code? DOI: XXXXXXX.XXXXXXX Conference: Make sure to enter the correct conference title from your rights confirmation email; June 03–05, 2018; Woodstock, NY ISBN: 978-1-4503-XXXX-X/2018/06
Md Nazmul Haque 1 , Hua Yang 1 , Zhou Yang 2 , Bowen Xu 1 · 2025
Read How Quantization Impacts Privacy Risk on LLMs for Code? DOI: XXXXXXX.XXXXXXX Conference: Make sure to enter the correct conference title from your rights confirmation email; June 03–05, 2018; Woodstock, NY ISBN: 978-1-4503-XXXX-X/2018/06 by Md Nazmul Haque 1 , Hua Yang 1 , Zhou Yang 2 , Bowen Xu 1 (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2508-00128.txt.
Introduction
Md Nazmul Haque and co-authors ask whether shrinking code models also shrinks their privacy leaks in a 2025 study. Models that write code train on huge public collections that can include passwords and personal details, and membership tests can reveal whether a given file was in the training set. Quantization, which stores the model's numbers more coarsely, is widely used to cut costs, but its privacy effect was unknown.
The team quantized three model families, in static and dynamic styles, and measured skill and privacy risk together. Quantization cut the privacy risk markedly versus the full models. Skill and risk rose and fell together, marking a real trade-off, and a compressed large model sometimes balanced the two better than a small full model. The pattern held across designs.
Catalog record
| CREATOR | Md Nazmul Haque 1 , Hua Yang 1 , Zhou Yang 2 , Bowen Xu 1 |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 47 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2508-00128
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
How Quantization Impacts Privacy Risk on LLMs for Code? DOI: XXXXXXX.XXXXXXX Conference: Make sure to enter the correct conference title from your rights confirmation email; June 03–05, 2018; Woodstock, NY ISBN: 978-1-4503-XXXX-X/2018/06 Md Nazmul Haque 1 , Hua Yang 1 , Zhou Yang 2 , Bowen Xu 1 Abstract . Large language models for code (LLMs4Code) rely heavily on massive training data, including sensitive data, such as cloud service credentials of the projects and personal identifiable information of the developers, raising serious privacy concerns. Membership inference (MI) has recently emerged as an effective tool for assessing privacy risk by identifying whether specific data belong to a model’s training set. In parallel, model compression techniques, especially quantization, have gained traction for reducing computational costs and enabling the deployment of large models. However, while quantized models still retain knowledge learned from the original training data, it remains unclear whether quantization affects their ability to retain and expose privacy information. Answering this question is of great importance to understanding privacy risks in real-world deployments. In this work, we conduct the first empirical study on how quantization influences task performance and privacy risk simultaneously in LLMs4Code. To do this, we implement widely used quantization techniques (static and dynamic) to three representative model families, namely Pythia, CodeGen, and GPT-Neo. Our results demonstrate that quantization has a significant impact on reducing the privacy risk relative to the original model. We also uncover a positive correlation between task performance and privacy risk, indicating an underlying trade-off. Moreover, we reveal the possibility that quantizing larger models could yield better balance than using full-precision small models. Finally, we demonstrate that these findings generalize across different architectures, model sizes and MI methods, offering practical guidance for safeguarding privacy when deploying compressed LLMs4Code. 1. Introduction The advent of Large Language Models for Code (LLMs4Code) represents a significant milestone in software engineering, specifically engineered to assist in software development by understanding, generating, and manipulating programming code ( Hou et al. 2024 ) . These models, often trained on vast repositories of source code from GitHub ( Gao et al. 2020 ; Husain et al. 2020 ; Allamanis and Sutton 2013 ) , offer substantial productivity gains through features like code completion, test case generation, summarization, bug detection, code translation, etc ( Li et al. 2023 ; Lu et al. 2021 ; Nijkamp et al. 2023 ) . However, their dependence on vast amounts of training data raises significant privacy concerns. On the one hand, one critical concern is the potential violation of intellectual property rights through the misuse of code governed by restrictive licenses. In particular, malicious developers might train LLMs4Code on license-restricted code, yet remain undetected due to the lack of effective auditing mechanisms. To mitigate such threats, recent studies explored Membership Inference (MI) methods as a detection mechanism ( Wan et al. 2024 ; Yang et al. 2024 ) . MI reveals whether a specific data point, such as a piece of code, was included in the LLMs4Code training dataset. Prior research has demonstrated that MI can effectively identify unauthorized usage of license-restricted code, highlighting its potential for auditing and enforcing compliance in large-scale model training ( Yang et al. 2024 ) . On the other hand, a successful MI poses a critical threat: it could reveal that proprietary algorithms, confidential business logic, or sensitive data embedded within code comments or strings (e.g., credentials, API keys) were part of the training corpus, which can serve as an attack vector for a backdoor attack. Concurrently, the practical deployment of LLMs4Code is hindered by its sheer scale. These models often comprise billions of parameters, demanding substantial computational resources for training and inference, significant memory allocation, and resulting in considerable latency ( Huang et al. 2025 ) . To address these challenges, model compression techniques—primarily pruning, quantization, and knowledge distillation—have become indispensable tools ( Huang et al. 2025 ) . These techniques aim to reduce the model’s size and computational requirements, thereby facilitating deployment in resource-constrained environments, such as edge devices, or enabling faster and more cost-effective inference in cloud settings ( Xu and McAuley 2023 ) . Hong et al. found that quantization is currently a more effective technique than others in achieving efficiency ( Hong et al. 2024 ) . The quantized version of many well-known LLMs4Code have been released on HuggingFace, such as CodeLlama-13B ( TheBloke [n. d.] ) and StarCoder2-15B ( Second State 2024 ) . While quantized models reduce memory and computational costs, their impact on privacy risk remains an open and critical question. Intriguingly, the very act of reducing precision through quantization could inadvertently sharpen the model’s output characteristics. This increased determinism, where predictions become more consistent for a given input, might create a more discernible fingerprint of the training data. Attackers could potentially exploit these subtle, yet consistent, output patterns to more easily differentiate between training data and non-training data, thereby increasing MI risks. In privacy-sensitive applications, such risks are exacerbated. Despite the potential impact of quantization on MI, its effect has not been empirically validated yet. Hence, we propose our central research question (RQ): How does quantization impact privacy risk on LLMs4Code? To answer this RQ, we experimented with quantization techniques and evaluated their effects on three well-known families of models, Pythia , CodeGen , and GPT-Neo . Then, we assessed the impact of quantization on both task and MI performance. Our results reveal a nuanced trade-off: 8-bit static quantization can preserve task performance while significantly reducing privacy risk compared to the original models, whereas 4-bit quantization can also significantly reduce privacy but at the cost of substantial drops in task performance. This suggests that while quantization offers potential privacy-preserving benefits, lower bit quantization may compromise task performance. Also, we found scenarios where a lower bit quantization of a larger model yields resilient task performance while improving privacy compared to smaller, original models. The main contributions of this study are as follows: • We conduct the first empirical study on how quantization affects privacy risk in LLMs4Code. Along with this, we also analyze its effect on task performance. We find that 8-bit quantization maintain comparable task performance with significant privacy improvement, while 4-bit quantization reduce the privacy risk but at a cost of significant task performance drops, especially in smaller models. We uncover a positive correlation between task performance and MI effectiveness, revealing a fundamental privacy risk-effectiveness trade-off in quantized models. • We validate our findings across three LLMs4Code families such as Pythia , CodeGen , and GPT-Neo and demonstrate that the observed trends generalize across architectures and model sizes. • We identify cases where quantized larger models achieve comparable or even smaller model sizes than their full-precision smaller counterparts, while delivering better task performance and lower privacy risks. This highlights strategic quantization as a dual-purpose solution for efficiency and privacy. • We provide an actionable guideline for model developers to identify optimal quantization configurations. Data availability . We release experimental results and replication package at https://anonymous.4open.science/r/mimir-4746 . 2. Background 2.1. Quantization for LLMs4Code There are two main quantization strategies: Quantization-Aware Training (QAT) and Post-Training Quantization (PTQ). QAT ( Esser et al. 2020 ) incorporates quantization operations into the training loop, enabling the model to