transformers/examples/research_projects/onnx/summarization
Sylvain Gugger 6f79d26442
Update quality tooling for formatting (#21480)
* Result of black 23.1

* Update target to Python 3.7

* Switch flake8 to ruff

* Configure isort

* Configure isort

* Apply isort with line limit

* Put the right black version

* adapt black in check copies

* Fix copies
2023-02-06 18:10:56 -05:00
..
bart_onnx Update quality tooling for formatting (#21480) 2023-02-06 18:10:56 -05:00
README.md Move BART + ONNX example to research_projects (#15271) 2022-01-21 14:47:34 +01:00
requirements.txt Move BART + ONNX example to research_projects (#15271) 2022-01-21 14:47:34 +01:00
run_onnx_exporter.py Update quality tooling for formatting (#21480) 2023-02-06 18:10:56 -05:00

Bart + Beam Search to ONNX

Author: @fatcat-z

This folder contains an example of exporting Bart + Beam Search generation (BartForConditionalGeneration) to ONNX.

Beam Search contains a for-loop workflow, so we need to make them TorchScript-compatible for exporting to ONNX. This example shows how to make a Bart model be TorchScript-compatible by wrapping up it into a new model. In addition, some changes were made to the beam_search() function to make it TorchScript-compatible.

How to run the example

To make sure you can successfully run the latest versions of the example scripts, you have to install the library from source and install some example-specific requirements. To do this, execute the following steps in a new virtual environment:

git clone https://github.com/huggingface/transformers
cd transformers
pip install '.[onnxruntime]'

Then cd in this example folder and run

pip install -r requirements.txt

Now you can run the example command below to get the example ONNX file:

python run_onnx_exporter.py --model_name_or_path facebook/bart-base