Skip to content

Commit

Permalink
chore: review
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrery committed Sep 26, 2023
1 parent 418695a commit e4b062f
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions doc/tutorials/privacy_preserving.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Privacy Preserving Inference with Concrete ML
#############################################

Concrete ML is a specialized library allowing the execution of machine learning models on encrypted data through Fully Homomorphic Encryption (FHE), thereby preserving data privacy.
Concrete ML is a specialized library allowing the execution of machine learning models on encrypted data through `Fully Homomorphic Encryption (FHE) <https://www.youtube.com/watch?v=FFox2S4uqEo>`, thereby preserving data privacy.

To use models such as XGBClassifier, use the following import:

Expand All @@ -21,7 +21,7 @@ Initialization of a XGBClassifier can be done as follows:
classifier = XGBClassifier(n_bits=6, [other_hyperparameters])
where ``n_bits`` determines the precision of the input features. Note that a higher value of ``n_bits`` results in increased precision but also longer FHE execution time.
where ``n_bits`` determines the precision of the input features. Note that a higher value of ``n_bits`` increases the precision of the input features and possibly the final model accuracy but also ends up with longer FHE execution time.

Other hyper parameters that exist in xgboost library can be used.

Expand Down Expand Up @@ -53,26 +53,45 @@ To verify model accuracy in encrypted computations, you can run an FHE simulatio
predictions = classifier.predict(X_test, fhe="simulate")
This simulation is can be used to evaluate the model. The resulting accuracy of this simulation step is representative of the actual FHE execution without having to pay the cost of an actual FHE execution.
This simulation can be used to evaluate the model. The resulting accuracy of this simulation step is representative of the actual FHE execution without having to pay the cost of an actual FHE execution.

When the model is ready, actual Fully Homomorphic Encryption execution can be performed:

.. code:: python
predictions = classifier.predict(X_test, fhe="execute")
Note that fhe="execute" does not preserve privacy as X_test is not encrypted here; instead it allows developers to assess the model. For privacy-preserving inferences, the model must be deployed. Concrete ML provides a deployment API to facilitate this process, ensuring end-to-end privacy, although the specifics of the deployment process are outside the scope of this tutorial. Please refer to:
Note that using FHE="execute" is a convenient way to assess the model in FHE, but for real deployment, functions to encrypt (on the client), run in FHE (on the server), and finally decrypt (on the client) have to be used for end-to-end privacy-preserving inferences.

Concrete ML provides a deployment API to facilitate this process, ensuring end-to-end privacy.

To go further in the deployment API you can read:
- the `deployment documentation <https://docs.zama.ai/concrete-ml/advanced-topics/client_server>`_
- the `deployment notebook <https://github.com/zama-ai/concrete-ml/blob/17779ca571d20b001caff5792eb11e76fe2c19ba/docs/advanced_examples/ClientServer.ipynb>`_

*******************************
Parameter Tuning in Concrete ML
*******************************

Concrete ML is compatible with standard scikit-learn pipelines such as GridSearchCV or any other hyper-parameter tuning technique.
Concrete ML is compatible with standard scikit-learn pipelines such as GridSearchCV or any other hyper-parameter tuning techniques.

******************
Examples and Demos
******************

- `Sentiment analysis (based on transformers + xgboost) <https://huggingface.co/spaces/zama-fhe/encrypted_sentiment_analysis>`_
- `XGBoost Classifier <https://github.com/zama-ai/concrete-ml/blob/6966c84b9698d5418209b346900f81d1270c64bd/docs/advanced_examples/XGBClassifier.ipynb>`_
- `XGBoost regressor <https://github.com/zama-ai/concrete-ml/blob/6966c84b9698d5418209b346900f81d1270c64bd/docs/advanced_examples/XGBRegressor.ipynb>`_

**********
Conclusion
**********

Concrete ML provides a framework for executing privacy-preserving inferences by leveraging Fully Homomorphic Encryption, allowing secure and private computations on encrypted data.
Concrete ML provides a framework for executing privacy-preserving inferences by leveraging Fully Homomorphic Encryption, allowing secure and private computations on encrypted data.

More information and examples are given in the `Concrete ML documentation`_.

.. _Zama: https://www.zama.ai/
.. _Concrete ML: https://github.com/zama-ai/concrete-ml
.. _`Concrete ML documentation`: https://docs.zama.ai/concrete-ml

0 comments on commit e4b062f

Please sign in to comment.