Skip to content

Commit

Permalink
Tiny Fix (PaddlePaddle#1470)
Browse files Browse the repository at this point in the history
  • Loading branch information
tianxin authored Dec 15, 2021
1 parent 4d06421 commit f580332
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions examples/few_shot/efl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ python -u -m paddle.distributed.launch --gpus "0" predict.py \
--max_seq_length 512
```
#### 基于静态图的预测部署
#### 基于静态图的预测
使用动态图训练结束之后,可以将动态图参数导出成静态图参数,从而获得最优的预测部署性能,执行如下命令完成动态图转换静态图的功能:
使用动态图训练结束之后,可以将动态图参数导出成静态图参数,从而获得最优的预测性能,执行如下命令完成动态图转换静态图的功能:
```
python export_model.py --params_path=./checkpoint/model_100/model_state.pdparams --output_path=./output

```
导出静态图模型之后,可以用于部署,`deploy/python/predict.py` 脚本提供了 python 部署预测示例。运行方式
导出静态图模型之后,可以基于静态图做预测部署,`deploy/python/predict.py` 脚本提供了 python 静态图预测示例。以 tnews 数据集为例, 执行如下命令基于静态图预测
```
python deploy/python/predict.py --model_dir=./output
python deploy/python/predict.py --model_dir=./output --task_name="tnews"

```
Expand Down
7 changes: 4 additions & 3 deletions examples/few_shot/efl/deploy/python/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ def predict(self, data, tokenizer):

# ErnieTinyTokenizer is special for ernie-tiny pretained model.
tokenizer = ppnlp.transformers.ErnieTokenizer.from_pretrained('ernie-1.0')
test_ds = load_dataset("fewclue", name="tnews", splits=["test"])
processor = processor_dict["tnews"](9)
test_ds = processor.get_test_datasets(test_ds, TASK_LABELS_DESC["tnews"])
test_ds = load_dataset("fewclue", name=args.task_name, splits=["test"])
processor = processor_dict[args.task_name]()
test_ds = processor.get_test_datasets(test_ds,
TASK_LABELS_DESC[args.task_name])

batches = [
test_ds[idx:idx + args.batch_size]
Expand Down

0 comments on commit f580332

Please sign in to comment.