A package for applying differential privacy to model training using block-level gradient shuffling
Project description
🛡️ ForgetNet: Differentially Private Block-wise Gradient Shuffle for Deep Learning 🧠
ForgetNet introduces a novel privacy-preserving technique for deep learning: Differentially Private Block-wise Gradient Shuffle (DP-BloGS). 🔒🔀
🌟 Features
- 🚀 Fast training times, close to non-private training
- 🎯 Competitive privacy guarantees compared to DP-SGD
- 📊 Better privacy-utility trade-off in many scenarios
- 🏋️ Scalable to large models (tested up to 1.1 billion parameters)
- 🧮 Parameter-wise privacy budget allocation
📦 Installation
pip install forgetnet
🚀 Quick Start
from forgetnet import DPBloGSTrainer
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load your model and tokenizer
model = AutoModelForCausalLM.from_pretrained("gpt2")
tokenizer = AutoTokenizer.from_pretrained("gpt2")
# Initialize the DP-BloGS trainer
trainer = DPBloGSTrainer(
model=model,
args=training_args,
train_dataset=train_dataset,
eval_dataset=eval_dataset,
tokenizer=tokenizer,
target_epsilon=1.0,
delta=1e-5,
clip_value=1.0
)
# Train your model with privacy guarantees
trainer.train()
📚 How It Works
DP-BloGS introduces a probabilistic approach to gradient noise through block-wise shuffling:
- 📊 Divide gradients into blocks
- 🔀 Shuffle blocks randomly
- 📏 Apply parameter-specific block sizes
- ✂️ Use batch layer clipping
- 🧮 Accumulate gradients
This combination allows for fast training while maintaining strong privacy guarantees!
📈 Performance
DP-BloGS has been tested on various model architectures, including:
- GPT-2 (124M)
- BERT (110M)
- OPT (350M)
- BLOOM (560M)
- TinyLlama (1.1B)
Results show competitive or better performance compared to DP-SGD in terms of:
- 🏃♂️ Training speed
- 🎭 Privacy guarantees
- 📊 Model utility
📄 Citation
If you use ForgetNet in your research, please cite my paper:
@article{zagardo2024dpblogs,
title={Differentially Private Block-wise Gradient Shuffle for Deep Learning},
author={Zagardo, David},
journal={arXiv preprint arXiv:2024.XXXXX},
year={2024}
}
🤝 Contributing
We welcome contributions! Please see my CONTRIBUTING.md for details on how to get started.
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgements
We thank the open-source community and the authors of the papers cited in our work for their valuable contributions to the field of privacy-preserving machine learning.
Built with 🧠 by David Zagardo
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file forgetnet-0.1.6.tar.gz.
File metadata
- Download URL: forgetnet-0.1.6.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f7a7e4fb376ac9f02fce6392efde6ef334450b841e5d7633292df5ca52008aa
|
|
| MD5 |
d43105ef426c81743502867dc1fff3ee
|
|
| BLAKE2b-256 |
505f20227962669b3010b25fe310bab7b6f1c2a4eb09294e652282ce1788d273
|
File details
Details for the file forgetnet-0.1.6-py3-none-any.whl.
File metadata
- Download URL: forgetnet-0.1.6-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b831b1786e726e022eed6eb259c5e3e3ae58eef22781fe30a5fb993e54a9d44
|
|
| MD5 |
e78e643289df10ae568cde99115229d7
|
|
| BLAKE2b-256 |
142aa55c26462072e7287e8ac50507ec4562b05bfe66f062ef8f899e8b9e0b40
|