Skip to content

Commit

Permalink
chore: fix links
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-stoian-zama committed Sep 21, 2023
1 parent 4a7e32c commit dbeed7e
Show file tree
Hide file tree
Showing 38 changed files with 1,669 additions and 573 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ Various tutorials are proposed for the [built-in models](docs/built-in-models/ml

- [Sentiment analysis with transformers](use_case_examples/sentiment_analysis_with_transformer): a gradio demo which predicts if a tweet / short message is positive, negative or neutral, with FHE of course! The [live interactive](https://huggingface.co/spaces/zama-fhe/encrypted_sentiment_analysis) demo is available on Hugging Face. This [blog post](https://huggingface.co/blog/sentiment-analysis-fhe) explains how this demo works!

- [CIFAR10 FHE-friendly model with Brevitas](use_case_examples/cifar_brevitas_training): code for training from scratch a VGG-like FHE-compatible neural network using Brevitas, and a script to run the neural network in FHE. Execution in FHE takes ~20 minutes per image and shows an accuracy of 88.7%.
- [CIFAR10 FHE-friendly model with Brevitas](use_case_examples/cifar/cifar_brevitas_training): code for training from scratch a VGG-like FHE-compatible neural network using Brevitas, and a script to run the neural network in FHE. Execution in FHE takes ~20 minutes per image and shows an accuracy of 88.7%.

- [CIFAR10 / CIFAR100 FHE-friendly models with Transfer Learning approach](use_case_examples/cifar_brevitas_finetuning): series of three notebooks, that show how to 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%.
- [CIFAR10 / CIFAR100 FHE-friendly models with Transfer Learning approach](use_case_examples/cifar/cifar_brevitas_finetuning): series of three notebooks, that show how to 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%.

- [FHE neural network splitting for client/server deployment](use_case_examples/cifar_brevitas_with_model_splitting): we explain how to split a computationally-intensive neural network model in two parts. First, we execute the first part on the client side in the clear, and the output of this step is encrypted. Next, to complete the computation, the second part of the model is evaluated with FHE. This tutorial also shows the impact of FHE speed/accuracy trade-off on CIFAR10, limiting PBS to 8-bit, and thus achieving 62% accuracy.
- [FHE neural network splitting for client/server deployment](use_case_examples/cifar/cifar_brevitas_with_model_splitting): we explain how to split a computationally-intensive neural network model in two parts. First, we execute the first part on the client side in the clear, and the output of this step is encrypted. Next, to complete the computation, the second part of the model is evaluated with FHE. This tutorial also shows the impact of FHE speed/accuracy trade-off on CIFAR10, limiting PBS to 8-bit, and thus achieving 62% accuracy.

- [Encrypted image filtering](use_case_examples/image_filtering): finally, the live demo for our [6-min](https://6min.zama.ai) is available, in the form of a gradio application. We take encrypted images, and apply some filters (for example black-and-white, ridge detection, or your own filter).

Expand Down
12 changes: 9 additions & 3 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [Linear Models](built-in-models/linear.md)
- [Tree-based Models](built-in-models/tree.md)
- [Neural Networks](built-in-models/neural-networks.md)
- [Nearest Neighbors](built-in-models/nearest-neighbors.md)
- [Pandas](built-in-models/pandas.md)
- [Built-in Model Examples](built-in-models/ml_examples.md)

Expand All @@ -26,15 +27,19 @@
- [Debugging Models](deep-learning/fhe_assistant.md)
- [Optimizing Inference](deep-learning/optimizing_inference.md)

## Deployment

- [Prediction with FHE](advanced-topics/prediction_with_fhe.md)
- [Hybrid models](advanced-topics/hybrid-models.md)
- [Production Deployment](advanced-topics/client_server.md)
- [Serialization](advanced-topics/serialization.md)

## Advanced topics

- [Quantization](advanced-topics/quantization.md)
- [Pruning](advanced-topics/pruning.md)
- [Compilation](advanced-topics/compilation.md)
- [Prediction with FHE](advanced-topics/prediction_with_fhe.md)
- [Production Deployment](advanced-topics/client_server.md)
- [Advanced Features](advanced-topics/advanced_features.md)
- [Serialization](advanced-topics/serialization.md)

## Developer Guide

Expand Down Expand Up @@ -89,6 +94,7 @@
- [concrete.ml.sklearn.glm.md](developer-guide/api/concrete.ml.sklearn.glm.md)
- [concrete.ml.sklearn.linear_model.md](developer-guide/api/concrete.ml.sklearn.linear_model.md)
- [concrete.ml.sklearn.md](developer-guide/api/concrete.ml.sklearn.md)
- [concrete.ml.sklearn.neighbors.md](developer-guide/api/concrete.ml.sklearn.neighbors.md)
- [concrete.ml.sklearn.qnn.md](developer-guide/api/concrete.ml.sklearn.qnn.md)
- [concrete.ml.sklearn.qnn_module.md](developer-guide/api/concrete.ml.sklearn.qnn_module.md)
- [concrete.ml.sklearn.rf.md](developer-guide/api/concrete.ml.sklearn.rf.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced-topics/advanced_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ In practice, the process looks like this:
1. Update P = P - 1
1. repeat steps 2 and 3 until the accuracy loss is above a certain, acceptable threshold.

An example of such implementation is available in [evaluate_torch_cml.py](../../use_case_examples/cifar_brevitas_training/evaluate_one_example_fhe.py) and [CifarInFheWithSmallerAccumulators.ipynb](../../use_case_examples/cifar_brevitas_finetuning/CifarInFheWithSmallerAccumulators.ipynb)
An example of such implementation is available in [evaluate_torch_cml.py](../../use_case_examples/cifar/cifar_brevitas_training/evaluate_one_example_fhe.py) and [CifarInFheWithSmallerAccumulators.ipynb](../../use_case_examples/cifar/cifar_brevitas_finetuning/CifarInFheWithSmallerAccumulators.ipynb)

## Seeing compilation information

Expand Down
10 changes: 5 additions & 5 deletions docs/advanced-topics/hybrid-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ or on differential methods. As a general rule, the difficulty
to steal a machine learning model is proportional to the size of the model, in terms of numbers of parameters and model depth.
{% endhint %}

The hybrid model deployment API provides an easy way to integrate the [standard deployment procedure](client_server.md) into neural network style models that are compiled with [`compile_brevitas_qat_model`](../developer-guide/api/concrete.ml.torch.compile.md#kbdfunctionkbd-compilebrevitasqatmodel) or [`compile_torch_model`](../developer-guide/api/concrete.ml.torch.compile.md#kbdfunctionkbd-compiletorchmodel).
The hybrid model deployment API provides an easy way to integrate the [standard deployment procedure](client_server.md) into neural network style models that are compiled with [`compile_brevitas_qat_model`](../developer-guide/api/concrete.ml.torch.compile.md#function-compile_brevitas_qat_model) or [`compile_torch_model`](../developer-guide/api/concrete.ml.torch.compile.md#function-compile_torch_model).

## Compilation

Expand Down Expand Up @@ -71,12 +71,12 @@ hybrid_model.save_and_clear_private_info(model_dir, via_mlir=True)

## Server Side Deployment

The [`save_and_clear_private_info`](<>) function serializes the FHE circuits
The [`save_and_clear_private_info`](../developer-guide/api/concrete.ml.torch.hybrid_model.md#method-save_and_clear_private_info) function serializes the FHE circuits
corresponding to the various parts of the model that were chosen to be moved
server-side. Furthermore it saves all necessary information required
to serve these sub-models with FHE, using the [`FHEModelDev`](../developer-guide/api/concrete.ml.deployment.fhe_client_server.md#kbdclasskbd-fhemodeldev) class.
to serve these sub-models with FHE, using the [`FHEModelDev`](../developer-guide/api/concrete.ml.deployment.fhe_client_server.md#class-fhemodeldev) class.

The [`FHEModelServer`](../developer-guide/api/concrete.ml.deployment.fhe_client_server.md#kbdclasskbd-fhemodelserver) class should be used to create a server application that creates end-points to serve these sub-models:
The [`FHEModelServer`](../developer-guide/api/concrete.ml.deployment.fhe_client_server.md#class-fhemodelserver) class should be used to create a server application that creates end-points to serve these sub-models:

<!--pytest-codeblocks:skip-->

Expand All @@ -91,7 +91,7 @@ For more information about serving FHE models, see the [client/server section](c
## Client Side

A client application that deploys a model with hybrid deployment can be developed
in a very similar manner to on-premise deployment: the model is loaded normally with Pytorch, but an extra step is required to specify the remote endpoint and the model parts that are to be executed remotely.
in a very similar manner to on-premise deployment: the model is loaded normally with PyTorch, but an extra step is required to specify the remote endpoint and the model parts that are to be executed remotely.

<!--pytest-codeblocks:skip-->

Expand Down
8 changes: 4 additions & 4 deletions docs/built-in-models/nearest-neighbors.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Concrete ML offers nearest neighbors non-parametric classification models with a

| Concrete ML | scikit-learn |
| :------------------------: | --------------------------------------------------------------------------------------------------------------------- |
| [KNeighborsClassifier](<>) | [KNeighborsClassifier](https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html) |
| [KNeighborsClassifier](../developer-guide/api/concrete.ml.sklearn.neighbors.md#class-kneighborsclassifier) | [KNeighborsClassifier](https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html) |

## Example usage

Expand All @@ -14,8 +14,8 @@ from concrete.ml.sklearn import KNeighborsClassifier
concrete_classifier = KNeighborsClassifier(n_bits=2, n_neighbors=3)
```

The `KNeighborsClassifier` class quantizes the training dataset that is given to `.fit` with the specified number of bits, `n_bits`. As this value must be kept low to comply with [accumulator size constraints](../getting-started/concepts.md#model-accuracy-considerations-under-fhe-constraints) the accuracy of the model will depend heavily a well-chosen value `n_bits` and the dimensionality of the data.
The `KNeighborsClassifier` class quantizes the training data-set that is given to `.fit` with the specified number of bits, `n_bits`. As this value must be kept low to comply with [accumulator size constraints](../getting-started/concepts.md#model-accuracy-considerations-under-fhe-constraints) the accuracy of the model will depend heavily a well-chosen value `n_bits` and the dimensionality of the data.

The FHE inference latency of this model is heavily influenced by the `n_bits`, the dimensionality of the data. Furthermore, the size of the dataset has a linear impact on the complexity of the data and the number of nearest neighbors, `n_neighbors`, also plays a role.
The FHE inference latency of this model is heavily influenced by the `n_bits`, the dimensionality of the data. Furthermore, the size of the data-set has a linear impact on the complexity of the data and the number of nearest neighbors, `n_neighbors`, also plays a role.

The KNN computation executes in FHE in $$O(Nlog^2k)$$ steps, where $$N$$ is the training dataset size and $$k$$ is `n_neighbors`. Each step requires several PBS of the precision required to represent the distances between test vectors and the training dataset.
The KNN computation executes in FHE in $$O(Nlog^2k)$$ steps, where $$N$$ is the training data-set size and $$k$$ is `n_neighbors`. Each step requires several PBS of the precision required to represent the distances between test vectors and the training data-set.
2 changes: 1 addition & 1 deletion docs/built-in-models/neural-networks.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The figure above right shows the Concrete ML neural network, trained with Quanti

- `n_w_bits` (default 3): number of bits for weights
- `n_a_bits` (default 3): number of bits for activations and inputs
- `n_accum_bits`: maximum accumulator bit-width that is desired. By default, this is unbounded, which, for weight and activation bitwidth settings, [may make the trained networks fail in compilation](#overflow-errors). When used, the implementation will attempt to keep accumulators under this bit-width through [pruning](../advanced-topics/pruning.md) (i.e., setting some weights to zero)
- `n_accum_bits`: maximum accumulator bit-width that is desired. By default, this is unbounded, which, for weight and activation bit-width settings, [may make the trained networks fail in compilation](#overflow-errors). When used, the implementation will attempt to keep accumulators under this bit-width through [pruning](../advanced-topics/pruning.md) (i.e., setting some weights to zero)
- `power_of_two_scaling`: forces quantization scales to be powers-of-two, which, when coupled with the ReLU activation, benefits from strong FHE inference time optimization

### Training parameters (from skorch)
Expand Down
2 changes: 1 addition & 1 deletion docs/deep-learning/fhe_friendly_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Regarding FHE-friendly neural networks, QAT is the best way to reach optimal acc

Concrete ML uses the third-party library [Brevitas](https://github.com/Xilinx/brevitas) to perform QAT for PyTorch NNs, but options exist for other frameworks such as Keras/Tensorflow.

Several [demos and tutorials](../getting-started/showcase.md) that use Brevitas are available in the Concrete ML library, such as the [CIFAR classification tutorial](../../use_case_examples/cifar_brevitas_finetuning/CifarQuantizationAwareTraining.ipynb).
Several [demos and tutorials](../getting-started/showcase.md) that use Brevitas are available in the Concrete ML library, such as the [CIFAR classification tutorial](../../use_case_examples/cifar/cifar_brevitas_finetuning/CifarQuantizationAwareTraining.ipynb).

This guide is based on a [notebook tutorial](../advanced_examples/QuantizationAwareTraining.ipynb), from which some code blocks are documented.

Expand Down
Loading

0 comments on commit dbeed7e

Please sign in to comment.