-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: yiliu30 <[email protected]>
- Loading branch information
Showing
17 changed files
with
1,129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2702,6 +2702,10 @@ Vanhoucke | |
ONNXCommunityMeetup | ||
luYBWA | ||
pQ | ||
CodeXGLUE | ||
codebert | ||
codexglue | ||
jsonl | ||
xgb | ||
xgboost | ||
hpo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
.../onnxrt/nlp/huggingface_model/code_detection/quantization/ptq_dynamic/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
Step-by-Step | ||
============ | ||
|
||
This example quantizes the [microsoft/codebert-base](https://huggingface.co/microsoft/codebert-base) fine-tuned on the the [code defect detection](https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/Defect-detection#codexglue----defect-detection) task. | ||
|
||
# Prerequisite | ||
|
||
## 1. Environment | ||
```shell | ||
pip install neural-compressor | ||
pip install -r requirements.txt | ||
``` | ||
> Note: Validated ONNX Runtime [Version](/docs/source/installation_guide.md#validated-software-environment). | ||
|
||
## 2. Prepare Dataset | ||
Run `prepare_data.sh` script to download dataset from website to `dataset` folder and pre-process it: | ||
|
||
```shell | ||
bash prepare_data.sh | ||
``` | ||
## 3. Prepare Model | ||
|
||
Fine-tuning the model on [code defect detection](https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/Defect-detection#codexglue----defect-detection) task. | ||
``` | ||
bash run_fine_tuning.sh --train_dataset_location=./dataset/train.jsonl --dataset_location=./dataset/valid.jsonl --fine_tune | ||
``` | ||
|
||
Export model to ONNX format. | ||
```bash | ||
# TODO replace the model name after uploading the model to the hugging face | ||
optimum-cli export onnx --model Intel/TBD-MODEL-NAME --task text-classification onnx_model/ | ||
``` | ||
|
||
# Run | ||
|
||
## 1. Quantization | ||
|
||
Static quantization with QOperator format: | ||
|
||
```bash | ||
bash run_quant.sh --input_model=/path/to/model \ # model path as *.onnx | ||
--output_model=/path/to/model_tune \ | ||
--dataset_location=path/to/glue/data | ||
``` | ||
|
||
## 2. Benchmark | ||
|
||
```bash | ||
bash run_benchmark.sh --input_model=path/to/model \ # model path as *.onnx | ||
--dataset_location=path/to/glue/data \ | ||
--batch_size=batch_size \ | ||
--mode=performance # or accuracy | ||
``` |
Oops, something went wrong.