Skip to content

Latest commit

 

History

History
32 lines (18 loc) · 1.56 KB

README.md

File metadata and controls

32 lines (18 loc) · 1.56 KB

Demo for building BERT model

Notice: The name of INPUT in models can be viewed by model viewers, such as Netron.

Tensorflow-BERT

  1. Download BERT-model from BERT. BERT-tiny is downloaded as example.

  2. Utilize the script export_bert.py to export frozen_bert.pb.

  3. Build Forward libraries refer to CMake-Build. -DENABLE_TENSORFLOW=ON, -DBUILD_PYTHON_LIB=ON and -DPYTHON_EXECUTABLE=$(which python3) should be specified.

  4. Copy Forward-Python library to this directory.

  5. Run the python script test_tf_bert.py

Torch-BERT

  1. Install transformers and torch.

  2. Build Forward libraries refer to CMake-Build. -DENABLE_TORCH=ON, -DBUILD_PYTHON_LIB=ON and -DPYTHON_EXECUTABLE=$(which python3) should be specified.

  3. Copy Forward-Python library to this directory.

  4. Run the python script test_torch_bert.py

ONNX-BERT

  1. Install transformers and convert an ONNX model using the transformers.onnx package. The checkpoint bert-base-uncased is exported as python -m transformers.onnx --model=bert-base-uncased bert.onnx.

  2. Build Forward libraries refer to CMake-Build. -DENABLE_ONNX=ON, -DBUILD_PYTHON_LIB=ON and -DPYTHON_EXECUTABLE=$(which python3) should be specified.

  3. Copy Forward-Python library to this directory.

  4. Run the python script test_onnx_bert.py