https://github.com/zama-ai/concrete-ml
Concrete ML: Privacy Preserving ML framework using Fully Homomorphic Encryption (FHE), built on top of Concrete, with bindings to traditional ML frameworks.
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.8%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Concrete ML: Privacy Preserving ML framework using Fully Homomorphic Encryption (FHE), built on top of Concrete, with bindings to traditional ML frameworks.
Basic Info
Statistics
- Stars: 1,263
- Watchers: 23
- Forks: 182
- Open Issues: 35
- Releases: 32
Topics
Metadata Files
README.md
📒 Documentation | 💛 Community support | 📚 FHE resources by Zama
About
What is Concrete ML
Concrete ML is a Privacy-Preserving Machine Learning (PPML) open-source set of tools built on top of Concrete by Zama.
It simplifies the use of fully homomorphic encryption (FHE) for data scientists so that they can automatically turn machine learning models into their homomorphic equivalents, and use them without knowledge of cryptography.
Concrete ML is designed with ease of use in mind. Data scientists can use models with APIs that are close to the frameworks they already know well, while additional options to those models allow them to run inference or training on encrypted data with FHE. The Concrete ML model classes are similar to those in scikit-learn and it is also possible to convert PyTorch models to FHE.
Main features
- Built-in models: Ready-to-use FHE-friendly models with a user interface that is equivalent to their the scikit-learn and XGBoost counterparts
- Customs models: Concrete ML supports models that can use quantization-aware training. These are developed by the user using PyTorch or keras/tensorflow and are imported into Concrete ML through ONNX
Learn more about Concrete ML features in the documentation.
Use cases
By leveraging FHE, Concrete ML can unlock a myriad of new use cases for machine learning, such as enabling secure and private data collaboration, protecting sensitive data while still allowing for analysis, and facilitating machine learning on data-sets that are subject to strict data privacy regulations, for instance
- Healthcare data analysis: Improve patient care while maintaining privacy by allowing secure, confidential data sharing between healthcare providers.
- Financial services: Facilitate secure financial data analysis for risk management and fraud detection, keeping client information encrypted and safe.
- Ad campaign tracking: Create targeted advertising and campaign insights in a post-cookie era, ensuring user privacy through encrypted data analysis.
- Industries: Enable predictive maintenance in the cloud while keeping sensitive data confidential, enhancing efficiency and data security.
- Biometrics: Give the ability to create user authentication applications without having to reveal their identities.
- Government: Enable governments to create digitized versions of their services without having to trust cloud providers.
See more use cases in the list of demos.
Table of Contents
Getting Started
Installation
Depending on your OS, Concrete ML may be installed with Docker or with pip:
| OS / HW | Available on Docker | Available on pip | | :-------------------------------------: | :-----------------: | :--------------: | | Linux | Yes | Yes | | Windows | Yes | No | | Windows Subsystem for Linux | Yes | Yes | | macOS 11+ (Intel) | Yes | Yes | | macOS 11+ (Apple Silicon: M1, M2, etc.) | Coming soon | Yes |
Note: Concrete ML only supports Python 3.8, 3.9, 3.10, 3.11 and 3.12.
Concrete ML can be installed on Kaggle (see this question on the community for more details) and on Google Colab.
Docker
To install with Docker, pull the concrete-ml image as follows:
docker pull zamafhe/concrete-ml:latest
Pip
To install Concrete ML from PyPi, run the following:
pip install -U pip wheel setuptools
pip install concrete-ml
Find more detailed installation instructions in this part of the documentation
A simple example
Here is a simple example which is very close to scikit-learn for a logistic regression :
```python from sklearn.datasets import makeclassification from sklearn.modelselection import traintestsplit from concrete.ml.sklearn import LogisticRegression
Lets create a synthetic data-set
x, y = makeclassification(nsamples=100, classsep=2, nfeatures=30, random_state=42)
Split the data-set into a train and test set
Xtrain, Xtest, ytrain, ytest = traintestsplit( x, y, testsize=0.2, randomstate=42 )
Now we train in the clear and quantize the weights
model = LogisticRegression(nbits=8) model.fit(Xtrain, y_train)
We can simulate the predictions in the clear
ypredclear = model.predict(X_test)
We then compile on a representative set
model.compile(X_train)
Finally we run the inference on encrypted inputs !
ypredfhe = model.predict(X_test, fhe="execute")
print("In clear :", ypredclear) print("In FHE :", ypredfhe) print(f"Similarity: {int((ypredfhe == ypredclear).mean()*100)}%")
Output:
# In clear : [0 0 0 0 1 0 1 0 1 1 0 0 1 0 0 1 1 1 0 0]
# In FHE : [0 0 0 0 1 0 1 0 1 1 0 0 1 0 0 1 1 1 0 0]
# Similarity: 100%
```
It is also possible to call encryption, model prediction, and decryption functions separately as follows.
Executing these steps separately is equivalent to calling predict_proba on the model instance.
```python
Predict probability for a single example
yprobafhe = model.predictproba(Xtest[[0]], fhe="execute")
Quantize an original float input
qinput = model.quantizeinput(X_test[[0]])
Encrypt the input
qinputenc = model.fhecircuit.encrypt(qinput)
Execute the linear product in FHE
qyenc = model.fhecircuit.run(qinput_enc)
Decrypt the result (integer)
qy = model.fhecircuit.decrypt(qyenc)
De-quantize and post-process the result
y0 = model.postprocessing(model.dequantizeoutput(q_y))
print("Probability with predict_proba: ", yprobafhe)
print("Probability with encrypt/run/decrypt calls: ", y0)
```
This example is explained in more detail in the linear model documentation.
Concrete ML built-in models have APIs that are almost identical to their scikit-learn counterparts. It is also possible to convert PyTorch networks to FHE with the Concrete ML conversion APIs. Please refer to the linear models, tree-based models and neural networks documentation for more examples, showing the scikit-learn-like API of the built-in models.
[!Note] Zama 5-Question Developer Survey
We want to hear from you! Take 1 minute to share your thoughts and helping us enhance our documentation and libraries. 👉 Click here to participate.
Resources
Demos
Live demos on Hugging Face
- Credit card approval: Predicting credit scoring card approval application in which sensitive data can be shared and analyzed without exposing the actual information to neither the three parties involved, nor the server processing it.
- Check the code here
- Sentiment analysis with transformers: predicting if an encrypted tweet / short message is positive, negative or neutral, using FHE.
- Health diagnosis: giving a diagnosis using FHE to preserve the privacy of the patient based on a patient's symptoms, history and other health factors.
- Check the code here
- Encrypted image filtering : filtering encrypted images by applying filters such as black-and-white, ridge detection, or your own filter.
- Check the code here
Other demos
- Encrypted Large Language Model: converting a user-defined part of a Large Language Model for encrypted text generation. This demo shows the trade-off between quantization and accuracy for text generation and shows how to run the model in FHE.
- Private inference for federated learned models: private training of a Logistic Regression model and then importing the model into Concrete ML and performing encrypted prediction.
- Titanic: solving the Kaggle Titanic competition. Implemented with XGBoost from Concrete ML, this example comes as a companion of the Kaggle notebook.
- CIFAR10 FHE-friendly model with Brevitas: training a VGG9 FHE-compatible neural network using Brevitas, and a script to run the neural network in FHE. Execution in FHE takes ~4 minutes per image and shows an accuracy of 88.7%.
- CIFAR10 / CIFAR100 FHE-friendly models with Transfer Learning approach: series of three notebooks, that convert a pre-trained FP32 VGG11 neural network into a quantized model using Brevitas. The model is fine-tuned on the CIFAR data-sets, converted for FHE execution with Concrete ML and evaluated using FHE simulation. For CIFAR10 and CIFAR100, respectively, our simulations show an accuracy of 90.2% and 68.2%.
If you have built awesome projects using Concrete ML, please let us know and we will be happy to showcase them here!
Tutorials
- [Video tutorial] Train a linear classifier on encrypted data using Concrete ML and Fully Homomorphic Encryption (FHE)
- [Video tutorial] How To Convert a Scikit-learn Model Into Its Homomorphic Equivalent
- Linear Regression Over Encrypted Data With Homomorphic Encryption
- How to Deploy a Machine Learning Model With Concrete ML
- More Built-in models tutorials and Deep learning tutorials
Explore more useful resources in Awesome Zama repo
Documentation
Full, comprehensive documentation is available here: https://docs.zama.ai/concrete-ml.
Working with Concrete ML
Citations
To cite Concrete ML in academic papers, please use the following entry:
text
@Misc{ConcreteML,
title={Concrete {ML}: a Privacy-Preserving Machine Learning Library using Fully Homomorphic Encryption for Data Scientists},
author={Zama},
year={2022},
note={\url{https://github.com/zama-ai/concrete-ml}},
}
Contributing
To contribute to Concrete ML, please refer to this section of the documentation.
License
This software is distributed under the BSD-3-Clause-Clear license. Read this for more details.
FAQ
Is Zama’s technology free to use?
Zama’s libraries are free to use under the BSD 3-Clause Clear license only for development, research, prototyping, and experimentation purposes. However, for any commercial use of Zama's open source code, companies must purchase Zama’s commercial patent license.
All our work is open source and we strive for full transparency about Zama's IP strategy. To know more about what this means for Zama product users, read about how we monetize our open source products in this blog post.
What do I need to do if I want to use Zama’s technology for commercial purposes?
To commercially use Zama’s technology you need to be granted Zama’s patent license. Please contact us at hello@zama.ai for more information.
Do you file IP on your technology?
Yes, all of Zama’s technologies are patented.
Can you customize a solution for my specific use case?
We are open to collaborating and advancing the FHE space with our partners. If you have specific needs, please email us at hello@zama.ai.
Support
🌟 If you find this project helpful or interesting, please consider giving it a star on GitHub! Your support helps to grow the community and motivates further development.
Owner
- Name: Zama
- Login: zama-ai
- Kind: organization
- Email: hello@zama.ai
- Location: Paris
- Website: https://zama.ai
- Twitter: zama_fhe
- Repositories: 15
- Profile: https://github.com/zama-ai
Zama's Concrete Framework is the easiest way to write efficient FHE code
Committers
Last synced: 11 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Benoit Chevallier-Mames | b****s@z****i | 521 |
| Roman Bredehoft | 5****t | 353 |
| Jordan Fréry | j****y@z****i | 261 |
| dependabot[bot] | 4****] | 217 |
| Luis Montero | l****o@z****i | 199 |
| Andrei Stoian | 9****a | 179 |
| Arthur Meyre | a****e@z****i | 79 |
| Celia KHERFALLAH | c****h@z****i | 76 |
| Roman | R****t | 52 |
| Zama Bot | 6****t | 13 |
| yuxizama | 1****a | 13 |
| aquint-zama | a****t@z****i | 8 |
| Jérémy Zaccherini | j****i@z****i | 6 |
| David Testé | d****e@f****r | 4 |
| rudy | r****d@g****m | 2 |
| thomas-quadratic | 1****c | 1 |
| tguerand | 4****d | 1 |
| Roger Carhuatocto | c****o@i****o | 1 |
| Robin Straub | r****b@g****m | 1 |
| Olivier Boulant | o****t@p****e | 1 |
| Jeremy Shulman | 1****l | 1 |
| Hugo Le Belzic | h****c@g****m | 1 |
| Ben | b****s@z****i | 1 |
| Ahmet Celebi | 5****2 | 1 |
| khoaguin | d****k@p****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 5 months ago
All Time
- Total issues: 116
- Total pull requests: 1,260
- Average time to close issues: 24 days
- Average time to close pull requests: 7 days
- Total issue authors: 75
- Total pull request authors: 35
- Average comments per issue: 2.94
- Average comments per pull request: 1.12
- Merged pull requests: 866
- Bot issues: 2
- Bot pull requests: 354
Past Year
- Issues: 30
- Pull requests: 385
- Average time to close issues: 11 days
- Average time to close pull requests: 8 days
- Issue authors: 24
- Pull request authors: 19
- Average comments per issue: 0.87
- Average comments per pull request: 0.87
- Merged pull requests: 244
- Bot issues: 1
- Bot pull requests: 137
Top Authors
Issue Authors
- maxwellgodv (14)
- bhuvneshchaturvedi2512 (5)
- bcm-at-zama (4)
- jfrery (4)
- malickKhurram (3)
- nazarpysko (3)
- gy-cao (2)
- reaneling (2)
- dependabot[bot] (2)
- zama-bot (2)
- MarcT0K (2)
- qxzhou1010 (2)
- tguerand (2)
- andrei-stoian-zama (2)
- Daihongwei1900 (2)
Pull Request Authors
- dependabot[bot] (354)
- RomanBredehoft (259)
- jfrery (156)
- andrei-stoian-zama (125)
- fd0r (97)
- zama-bot (84)
- kcelia (62)
- bcm-at-zama (45)
- yuxizama (22)
- aquint-zama (11)
- VolodymyrBg (8)
- rudy-6-4 (3)
- mohammadnaseri (2)
- DeVikingMark (2)
- bonsainoodle (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 2,007 last-month
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 2
(may contain duplicates) - Total versions: 63
- Total maintainers: 1
proxy.golang.org: github.com/zama-ai/concrete-ml
- Documentation: https://pkg.go.dev/github.com/zama-ai/concrete-ml#section-documentation
- License: other
-
Latest release: v1.9.0
published 11 months ago
Rankings
pypi.org: concrete-ml
Concrete ML is an open-source set of tools which aims to simplify the use of fully homomorphic encryption (FHE) for data scientists.
- Homepage: https://zama.ai/concrete-ml/
- Documentation: http://docs.zama.ai/concrete-ml/
- License: BSD-3-Clause-Clear
-
Latest release: 1.9.0
published 11 months ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout ac593985615ec2ede58e132d2e21d2b1cbd6127c composite
- actions/setup-python 5ccb29d8773c3f3f653e1705f474dfaa8a06a912 composite
- rtCamp/action-slack-notify 12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 composite
- actions/checkout ac593985615ec2ede58e132d2e21d2b1cbd6127c composite
- rtCamp/action-slack-notify 12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 composite
- actions/checkout ac593985615ec2ede58e132d2e21d2b1cbd6127c composite
- actions/download-artifact 9bc31d5ccc31df68ecc42ccf4149144866c47d8a composite
- actions/setup-python 5ccb29d8773c3f3f653e1705f474dfaa8a06a912 composite
- actions/upload-artifact 0b7f8abb1508181956e8e162db84b466c27e18ce composite
- aws-actions/configure-aws-credentials 67fbcbb121271f7775d2e7715933280b06314838 composite
- docker/build-push-action c56af957549030174b10d6867f20e78cfd7debc5 composite
- docker/login-action 49ed152c8eca782a232dede0303416e8f356c37b composite
- docker/setup-buildx-action v2 composite
- gsactions/commit-message-checker 16fa2d5de096ae0d35626443bcd24f1e756cafee composite
- machulav/ec2-github-runner 4e0303de215db88e1c489e07a15ca4d867f488ea composite
- marocchino/sticky-pull-request-comment fcf6fe9e4a0409cd9316a5011435be0f3327f1e1 composite
- rtCamp/action-slack-notify 12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 composite
- softprops/action-gh-release de2c0eb89ae2a093876385947365aca7b0e5f844 composite
- actions/checkout ac593985615ec2ede58e132d2e21d2b1cbd6127c composite
- actions/setup-python 5ccb29d8773c3f3f653e1705f474dfaa8a06a912 composite
- aws-actions/configure-aws-credentials 67fbcbb121271f7775d2e7715933280b06314838 composite
- machulav/ec2-github-runner 4e0303de215db88e1c489e07a15ca4d867f488ea composite
- peter-evans/create-pull-request 2b011faafdcbc9ceb11414d64d0573f37c774b04 composite
- rtCamp/action-slack-notify 12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 composite
- actions/checkout ac593985615ec2ede58e132d2e21d2b1cbd6127c composite
- actions/setup-python 5ccb29d8773c3f3f653e1705f474dfaa8a06a912 composite
- aws-actions/configure-aws-credentials 67fbcbb121271f7775d2e7715933280b06314838 composite
- machulav/ec2-github-runner 4e0303de215db88e1c489e07a15ca4d867f488ea composite
- peter-evans/create-pull-request 2b011faafdcbc9ceb11414d64d0573f37c774b04 composite
- rtCamp/action-slack-notify 12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 composite
- stefanzweifel/git-auto-commit-action v4 composite
- actions/checkout ac593985615ec2ede58e132d2e21d2b1cbd6127c composite
- actions/setup-python 5ccb29d8773c3f3f653e1705f474dfaa8a06a912 composite
- aws-actions/configure-aws-credentials 67fbcbb121271f7775d2e7715933280b06314838 composite
- machulav/ec2-github-runner 4e0303de215db88e1c489e07a15ca4d867f488ea composite
- nick-fields/retry v2 composite
- jupyter *
- opencv-python-headless *
- pandas *
- 209 dependencies
- black ^22.1.0 develop
- darglint ^1.8.1 develop
- flake8 ^4.0.1 develop
- flake8-bugbear ^22.3.23 develop
- isort ^5.10.1 develop
- jinja2 <3.1 develop
- jupyter ^1.0.0 develop
- keyring * develop
- mdformat ^0.7.14 develop
- mdformat-toc ^0.3.0 develop
- mdformat_myst ^0.1.4 develop
- mypy 0.942 develop
- nbmake ^1.3.0 develop
- nbqa ^1.3.1 develop
- nbsphinx 0.8.7 develop
- pandas ^1.4.1 develop
- pip-audit ^2.1.0 develop
- py-progress-tracker ^0.4.6 develop
- pydocstyle ^6.1.1 develop
- pygments-style-tomorrow ^1.0.0 develop
- pylint 2.13.0 develop
- pytest ^7.1.1 develop
- pytest-cov ^3.0.0 develop
- pytest-randomly ^3.11.0 develop
- pytest-repeat ^0.9.1 develop
- pytest-xdist ^2.5.0 develop
- pytest_codeblocks ^0.14.0 develop
- python-semantic-release 7.27.0 develop
- semver ^2.13.0 develop
- sphinx-zama-theme ^3.0.2 develop
- tomlkit ^0.7.0 develop
- concrete-ml-extensions-hb ^0.4.2
- concrete-numpy ^0.5.0
- numpy ^1.22.3
- onnx 1.11.0
- protobuf 3.19.4
- python >=3.8,<3.10
- scikit-learn ^1.0.2
- scipy ^1.8.0
- setuptools *
- skorch ^0.11.0
- torch ^1.11.0
- xgboost ^1.5.2
- concrete-ml *
- jupyter *
- torchvision *
- concrete-ml *
- jupyter *
- pandas *
- torchvision *
- concrete-ml *
- jupyter *
- pandas *
- grequests *
- requests *
- tqdm *
- grequests *
- requests *
- tqdm *
- torchvision *
- grequests *
- requests *
- tqdm *
- transformers *
- concrete-ml *
- jupyter *
- pandas *
- transformers *
- transformers *
- concrete-ml *
- jupyter *
- pandas *
- concrete-ml *
- flwr *
- openml *
- apache_beam ==2.49.0
- datasets ==2.14.4
- loguru ==0.7.0
- mwparserfromhell ==0.6.4
- concrete-ml ==1.1.0
- transformers ==4.30.2
- concrete-ml *
- jupyter *
- pandas *
- transformers *
- concrete-ml *
- jupyter *
- pandas *
- actions/checkout 3df4ab11eba7bda6032a0b82a6bb43b11571feac composite
- rtCamp/action-slack-notify b24d75fe0e728a4bf9fc42ee217caa686d141ee8 composite
- actions/checkout 3df4ab11eba7bda6032a0b82a6bb43b11571feac composite
- actions/setup-python 61a6322f88396a6271a6ee3565807d608ecaddd1 composite
- actions/upload-artifact 0b7f8abb1508181956e8e162db84b466c27e18ce composite
- rtCamp/action-slack-notify b24d75fe0e728a4bf9fc42ee217caa686d141ee8 composite
- actions/checkout 3df4ab11eba7bda6032a0b82a6bb43b11571feac composite
- actions/setup-python 61a6322f88396a6271a6ee3565807d608ecaddd1 composite
- actions/upload-artifact v3 composite
- aws-actions/configure-aws-credentials 8c3f20df09ac63af7b3ae3d7c91f105f857d8497 composite
- machulav/ec2-github-runner 4e0303de215db88e1c489e07a15ca4d867f488ea composite
- rtCamp/action-slack-notify b24d75fe0e728a4bf9fc42ee217caa686d141ee8 composite
- actions/checkout 3df4ab11eba7bda6032a0b82a6bb43b11571feac composite
- actions/setup-python 61a6322f88396a6271a6ee3565807d608ecaddd1 composite
- peter-evans/create-pull-request 284f54f989303d2699d373481a0cfa13ad5a6666 composite
- rtCamp/action-slack-notify b24d75fe0e728a4bf9fc42ee217caa686d141ee8 composite
- actions/checkout 3df4ab11eba7bda6032a0b82a6bb43b11571feac composite
- rtCamp/action-slack-notify b24d75fe0e728a4bf9fc42ee217caa686d141ee8 composite
- actions/checkout 3df4ab11eba7bda6032a0b82a6bb43b11571feac composite
- actions/download-artifact 9bc31d5ccc31df68ecc42ccf4149144866c47d8a composite
- ad-m/github-push-action master composite
- aws-actions/configure-aws-credentials 8c3f20df09ac63af7b3ae3d7c91f105f857d8497 composite
- crazy-max/ghaction-import-gpg v6.0.0 composite
- docker/build-push-action 0565240e2d4ab88bba5387d719585280857ece09 composite
- docker/login-action 343f7c4344506bcbf9b4de18042ae17996df046d composite
- docker/setup-buildx-action v3 composite
- machulav/ec2-github-runner 4e0303de215db88e1c489e07a15ca4d867f488ea composite
- rtCamp/action-slack-notify b24d75fe0e728a4bf9fc42ee217caa686d141ee8 composite
- softprops/action-gh-release de2c0eb89ae2a093876385947365aca7b0e5f844 composite
- actions/checkout 3df4ab11eba7bda6032a0b82a6bb43b11571feac composite
- actions/upload-artifact 0b7f8abb1508181956e8e162db84b466c27e18ce composite
- wei/git-sync 55c6b63b4f21607da0e9877ca9b4d11a29fc6d83 composite
- actions/checkout 3df4ab11eba7bda6032a0b82a6bb43b11571feac composite
- actions/setup-python 61a6322f88396a6271a6ee3565807d608ecaddd1 composite
- peter-evans/create-pull-request 284f54f989303d2699d373481a0cfa13ad5a6666 composite
- stefanzweifel/git-auto-commit-action v4 composite
- actions/checkout 3df4ab11eba7bda6032a0b82a6bb43b11571feac composite
- actions/setup-python 61a6322f88396a6271a6ee3565807d608ecaddd1 composite
- rtCamp/action-slack-notify b24d75fe0e728a4bf9fc42ee217caa686d141ee8 composite
- fastapi *
- python-multipart *
- uvicorn *
- concrete-ml *
- jupyter *
- torchvision *