Demo for building BERT model
August 24, 2021 ยท View on GitHub
Notice: The name of INPUT in models can be viewed by model viewers, such as Netron.
Tensorflow-BERT
-
Download BERT-model from BERT. BERT-tiny is downloaded as example.
-
Utilize the script export_bert.py to export
frozen_bert.pb. -
Build Forward libraries refer to CMake-Build.
-DENABLE_TENSORFLOW=ON,-DBUILD_PYTHON_LIB=ONand-DPYTHON_EXECUTABLE=$(which python3)should be specified. -
Copy Forward-Python library to this directory.
-
Run the python script
test_tf_bert.py
Torch-BERT
-
Install
transformersandtorch. -
Build Forward libraries refer to CMake-Build.
-DENABLE_TORCH=ON,-DBUILD_PYTHON_LIB=ONand-DPYTHON_EXECUTABLE=$(which python3)should be specified. -
Copy Forward-Python library to this directory.
-
Run the python script
test_torch_bert.py
ONNX-BERT
-
Install
transformersand convert an ONNX model using thetransformers.onnxpackage. The checkpointbert-base-uncasedis exported aspython -m transformers.onnx --model=bert-base-uncased bert.onnx. -
Build Forward libraries refer to CMake-Build.
-DENABLE_ONNX=ON,-DBUILD_PYTHON_LIB=ONand-DPYTHON_EXECUTABLE=$(which python3)should be specified. -
Copy Forward-Python library to this directory.
-
Run the python script
test_onnx_bert.py