Skip to content

Commit

Permalink
modify ci accroding to PaddlePaddle#4398 and adjust predictor
Browse files Browse the repository at this point in the history
  • Loading branch information
Yam0214 committed Jan 31, 2023
1 parent c3d524a commit bb48adb
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 218 deletions.
4 changes: 1 addition & 3 deletions model_zoo/ernie-3.0/deploy/simple_serving/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
- [其他参数设置](#其他参数设置)

## 环境准备

paddlenlp >= 2.5.0

使用有SimpleServing功能的PaddleNLP版本

## Server服务启动
### 文本分类任务启动
Expand Down
53 changes: 0 additions & 53 deletions model_zoo/ernie-m/configs/test.yaml

This file was deleted.

12 changes: 6 additions & 6 deletions model_zoo/ernie-m/deploy/predictor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ pip install -r requirements_gpu.txt

### 2.2 CPU端推理样例
在 CPU 端,请使用如下命令进行部署
```
python infer_cpu.py --task_name seq_cls --model_path ../../finetuned_models/export/model
```sh
python inference.py --device cpu --task_name seq_cls --model_path ../../finetuned_models/export/model
```
输出打印如下:
```
Expand Down Expand Up @@ -58,8 +58,8 @@ infer_cpu.py 脚本中的参数说明:

### 2.3 GPU端推理样例
在 GPU 端,请使用如下命令进行部署
```
python infer_gpu.py --task_name seq_cls --model_path ../../finetuned_models/export/model
```sh
python inference.py --device gpu --task_name seq_cls --model_path ../../finetuned_models/export/model
```
输出打印如下:
```
Expand All @@ -77,8 +77,8 @@ label: neutral confidence: 0.9880901575088501
-----------------------------
```
如果需要 FP16 进行加速,可以设置 precision_mode 为 fp16,具体命令为
```
python infer_gpu.py --task_name seq_cls --model_path ../../finetuned_models/export/model --precision_mode fp16
```sh
python inference.py --device gpu --task_name seq_cls --model_path ../../finetuned_models/export/model --precision_mode fp16
```
infer_gpu.py 脚本中的参数说明:
| 参数 |参数说明 |
Expand Down
85 changes: 0 additions & 85 deletions model_zoo/ernie-m/deploy/predictor/infer_cpu.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@

import argparse

from ernie_m_predictor import ErnieMPredictor
from psutil import cpu_count

from .ernie_m_predictor import ErnieMPredictor


def parse_args():
parser = argparse.ArgumentParser()
# Required parameters
parser.add_argument(
"--device", default="cpu", type=str, choices=["gpu", "cpu"], help="Device selected for inference."
)
parser.add_argument(
"--task_name",
default="seq_cls",
Expand Down Expand Up @@ -69,14 +74,19 @@ def parse_args():
choices=["fp32", "fp16", "int8"],
help="Inference precision.",
)
parser.add_argument(
"--num_threads",
default=cpu_count(logical=False),
type=int,
help="num_threads for cpu.",
)
args = parser.parse_args()
return args


def main():
args = parse_args()
args.task_name = args.task_name.lower()
args.device = "gpu"
predictor = ErnieMPredictor(args)

if args.task_name == "seq_cls":
Expand Down
69 changes: 0 additions & 69 deletions model_zoo/ernie-m/test.py

This file was deleted.

51 changes: 51 additions & 0 deletions tests/fixtures/model_zoo/ernie-m.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
classifier:
default:
do_train: True
do_eval: True
do_export: True
task_type: cross-lingual-transfer
model_name_or_path: __internal_testing__/ernie-m
output_dir: ./output_dir
export_model_dir: ./output_dir
per_device_train_batch_size: 16
per_device_eval_batch_size: 16
max_seq_length: 256
learning_rate: 5e-5
classifier_dropout: 0.1
weight_decay: 0.0
layerwise_decay: 0.8
warmup_ratio: 0.1
max_steps: 2
logging_steps: 1
save_steps: 1
eval_steps: 1
device: cpu
fp16: False
load_best_model_at_end: True
metric_for_best_model: eval_accuracy
overwrite_output_dir: True

slow:
do_train: True
do_eval: True
do_export: True
task_type: cross-lingual-transfer
model_name_or_path: ernie-m-base
output_dir: ./output_dir
export_model_dir: ./output_dir
per_device_train_batch_size: 16
per_device_eval_batch_size: 16
max_seq_length: 256
learning_rate: 5e-5
classifier_dropout: 0.1
weight_decay: 0.0
layerwise_decay: 0.8
num_train_epochs: 5
logging_steps: 767
save_steps: 12272
eval_steps: 767
device: gpu
fp16: False
load_best_model_at_end: Trues
metric_for_best_model: eval_accuracy
overwrite_output_dir: True
Loading

0 comments on commit bb48adb

Please sign in to comment.