README.md 1.37 KB
Newer Older
Cagri Eryilmaz's avatar
Cagri Eryilmaz committed
1
2
3
4
5
6
7
8
9
# BERT-SQuAD Example with MIGraphX
Question answering with BERT using MIGraphX optimizations on ROCm platform.

There are two ways to run the example:
1) Install MIGraphX and Jupyter notebook to your system and then utilize `BERT-Squad.ipynb` notebook file.
2) Install MIGraphx to your system and follow the steps executing the python script `bert-squad-migraphx.py`.

# Steps
1) Install MIGraphX to your environment. Please follow the steps to build MIGraphX given at https://github.com/ROCmSoftwarePlatform/AMDMIGraphX
10
11
12
13
14
2) Upgrade your pip3 to latest version
```
pip3 install --upgrade pip 
```
3) Install the requirements file
Cagri Eryilmaz's avatar
Cagri Eryilmaz committed
15
```
16
pip3 install -r requirements_bertsquad.txt
Cagri Eryilmaz's avatar
Cagri Eryilmaz committed
17
```
18
4) Install `unzip` and fetch the uncased file (vocabulary):
Cagri Eryilmaz's avatar
Cagri Eryilmaz committed
19
20
21
22
23
```
apt-get install unzip
wget -q https://storage.googleapis.com/bert_models/2018_10_18/uncased_L-12_H-768_A-12.zip
unzip uncased_L-12_H-768_A-12.zip
```
24
5) Get BERT ONNX model (bertsquad-10.onnx):
Cagri Eryilmaz's avatar
Cagri Eryilmaz committed
25
```
26
wget https://github.com/onnx/models/blob/main/text/machine_comprehension/bert-squad/model/bertsquad-10.onnx
Cagri Eryilmaz's avatar
Cagri Eryilmaz committed
27
```
28
6) Run the inference, it will compile and run the model on three questions and small data provided in `inputs.json`:
Cagri Eryilmaz's avatar
Cagri Eryilmaz committed
29
30
31
32
33
34
```
python3 bert-squad-migraphx.py
```
## References
This example utilizes the following notebook :notebook: and applies it to MIGraphX:
https://github.com/onnx/models/blob/master/text/machine_comprehension/bert-squad/BERT-Squad.ipynb