from pathlib import Path
from transformers.onnx import export
from transformers import AutoTokenizer, AutoModel
onnx_path = Path("model.onnx")
model_ckpt = "distilbert-base-uncased"
base_model = AutoModel.from_pretrained(model_ckpt)
tokenizer = AutoTokenizer.from_pretrained(model_ckpt)
onnx_inputs, onnx_outputs = export(tokenizer, base_model, onnx_config, onnx_config.default_onnx_opset, onnx_path)
```
The onnx_inputs and onnx_outputs returned by the export() function are
lists of the keys defined in the inputs and outputs properties of the
configuration. Once the model is exported, you can test that the model is well
formed as follows:
```python
import onnx
onnx_model = onnx.load("model.onnx")
onnx.checker.check_model(onnx_model)
```
If your model is larger than 2GB, you will see that many additional files are
