Views
No views yet
| Model | Download | Download (with sample test data) | ONNX version | Opset version | Accuracy |
|---|---|---|---|---|---|
| BERT-Squad | 416 MB | 385 MB | 1.3 | 8 | |
| BERT-Squad | 416 MB | 384 MB | 1.5 | 10 | |
| BERT-Squad | 416 MB | 384 MB | 1.9 | 12 | 80.67171 |
| BERT-Squad-int8 | 119 MB | 101 MB | 1.9 | 12 | 80.43519 |
Compared with the fp32 BERT-Squad, BERT-Squad-int8's accuracy drop ratio is 0.29%, performance improvement is 1.81x.Note the performance depends on the test hardware.Performance data here is collected with Intel® Xeon® Platinum 8280 Processor, 1s 4c per instance, CentOS Linux 8.3, data batch size is 1.
1%%writefile inputs.json
2{
3"version": "1.4",
4"data": [
5{
6"paragraphs": [
7{
8"context": "In its early years, the new convention center failed to meet attendance and revenue expectations.[12] By 2002, many Silicon Valley businesses were choosing the much larger Moscone Center in San Francisco over the San Jose Convention Center due to the latter's limited space. A ballot measure to finance an expansion via a hotel tax failed to reach the required two-thirds majority to pass. In June 2005, Team San Jose built the South Hall, a $6.77 million, blue and white tent, adding 80,000 square feet (7,400 m2) of exhibit space",
9"qas": [
10{
11"question": "where is the businesses choosing to go?",
12"id": "1"
13},
14{
15"question": "how may votes did the ballot measure need?",
16"id": "2"
17},
18{
19"question": "By what year many Silicon Valley businesses were choosing the Moscone Center?",
20"id": "3"
21}
22]
23}
24],
25"title": "Conference Center"
26}
27]
28}1# preprocess input
2predict_file = 'inputs.json'
3
4# Use read_squad_examples method from run_onnx_squad to read the input file
5eval_examples = read_squad_examples(input_file=predict_file)
6
7max_seq_length = 256
8doc_stride = 128
9max_query_length = 64
10batch_size = 1
11n_best_size = 20
12max_answer_length = 30
13
14vocab_file = os.path.join('uncased_L-12_H-768_A-12', 'vocab.txt')
15tokenizer = tokenization.FullTokenizer(vocab_file=vocab_file, do_lower_case=True)
16
17# Use convert_examples_to_features method from run_onnx_squad to get parameters from the input
18input_ids, input_mask, segment_ids, extra_data = convert_examples_to_features(eval_examples, tokenizer,
19max_seq_length, doc_stride, max_query_length)1# postprocess results
2output_dir = 'predictions'
3os.makedirs(output_dir, exist_ok=True)
4output_prediction_file = os.path.join(output_dir, "predictions.json")
5output_nbest_file = os.path.join(output_dir, "nbest_predictions.json")
6write_predictions(eval_examples, extra_data, all_results,
7n_best_size, max_answer_length,
8True, output_prediction_file, output_nbest_file)wget https://github.com/onnx/models/raw/main/text/machine_comprehension/bert-squad/model/bertsquad-12.onnx1bash run_tuning.sh --input_model=/path/to/model \ # model path as *.onnx
2--output_model=/path/to/model_tune \
3--dataset_location=/path/to/SQuAD/dataset \
4--config=bert.yaml