# Optimisation and Quantization of Tensorflow Model

**URL:** <https://discuss.huggingface.co/t/optimisation-and-quantization-of-tensorflow-model/34287>\
**Category:** 🤗Optimum\
**Created:** [March 21, 2023, 10:04am UTC](https://discuss.huggingface.co/t/optimisation-and-quantization-of-tensorflow-model/34287 "2023-03-21T10:04:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![D3v](https://avatars.discourse-cdn.com/v4/letter/d/e480ec/32.png) [@D3v](https://discuss.huggingface.co/u/D3v)\
**Post date:** [March 21, 2023, 10:04am UTC](https://discuss.huggingface.co/t/optimisation-and-quantization-of-tensorflow-model/34287/1 "2023-03-21T10:04:46Z")

</div>

Hey there, I have some doubt regarding optimization and qunatization of TF based model. Actually i’m doing optimization and quantization of **‘“distilbert-base-multilingual-cased”’** model, for pytorch model im able to perform optimization and qunatization. But for my use case i have to used TF based model and perform optimization and quantization but im unable to do it. It’ll helpful if anyone clear me about below questions.

1. How do i perform Optimisation and Quantisation of any TensorFlow model available in HuggingFace Model Hub.

2. Does Optimum Library work for TensorFlow model as well, can we use ORTModelxxx class for TensorFlow ?

3. Optimum[export] has functionality to convert model to onnx format for Tensorflow with level of optimization but has no quantization, so after getting the optimized onnx model how can i quantised.

---

<div class="post-metadata">

**Author:** ![regisss](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/regisss/32/22467_2.png) [@regisss](https://discuss.huggingface.co/u/regisss)\
**Post date:** [May 3, 2023, 6:33pm UTC](https://discuss.huggingface.co/t/optimisation-and-quantization-of-tensorflow-model/34287/2 "2023-05-03T18:33:12Z")

</div>

Hi @D3v, you can easily export and optimize your TF model with Optimum CLI as follows:

```bash
optimum-cli export onnx --model distilbert-base-multilingual-cased --framework tf --optimize O2 my_onnx_model

```

Then, to quantize it, you can also use the CLI as described [here](https://huggingface.co/docs/optimum/main/en/onnxruntime/usage_guides/quantization#quantizing-a-model-to-be-used-with-optimums-cli).
