# Transformers.onnx vs optimum.onnxruntime

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftransformers-onnx-vs-optimum-onnxruntime%2F22581%3E%5C
**Category:** 🤗Optimum\
**Created:** [September 5, 2022, 3:56pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftransformers-onnx-vs-optimum-onnxruntime%2F22581 "2022-09-05T15:56:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maxinho](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/maxinho/32/5911_2.png) [@Maxinho](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FMaxinho)%5C
**Post date:** [September 5, 2022, 3:56pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftransformers-onnx-vs-optimum-onnxruntime%2F22581%2F1 "2022-09-05T15:56:02Z")

</div>

Hello. I am interested in converting a model to ONNX to get faster inference, but I saw there are two possible approaches:

- Using transformers.onnx package: [Export 🤗 Transformers Models](https://huggingface.co/docs/transformers/v4.21.3/en/serialization#onnx)
- Using optimum.onnxruntime package: [Optimum Inference with ONNX Runtime](https://huggingface.co/docs/optimum/onnxruntime/modeling_ort#optimum-inference-with-onnx-runtime)

Should I convert the model to ONNX with the first and then use it with Optimum? It looks like Optimum can convert models to ONNX by its own now, so what is the point of transformers.onnx package?

---

<div class="post-metadata">

**Author:** ![Jingya](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/jingya/32/29444_2.png) [@Jingya](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJingya)%5C
**Post date:** [September 12, 2022, 10:09am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftransformers-onnx-vs-optimum-onnxruntime%2F22581%2F2 "2022-09-12T10:09:21Z")

</div>

Hi @Maxinho,

`ORTModel` APIs in Optimum manage the conversion of models from PyTorch to ONNX(we currently use the export in `transformers.onnx`) when it is needed, and implement the inference for different tasks so that you can use it just like using `AutoModel` APIs in Transformers.

In terms of acceleration, Optimum offers [`ORTOptimizer`](https://huggingface.co/docs/optimum/onnxruntime/optimization) and [`ORTQuantizer`](https://huggingface.co/docs/optimum/onnxruntime/quantization), with which you can optimize your computation graph and quantize your ONNX model so that you can accelerate even more the inference.
