Skip to content

Commit 6df00ad

Browse files
committed
update document and add demo yaml
1 parent 1d0ba1a commit 6df00ad

File tree

2 files changed

+84
-13
lines changed

2 files changed

+84
-13
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
runner:
16+
train_data_dir: "data/sample_data/train"
17+
train_reader_path: "NAMLDataReader" # importlib format
18+
use_gpu: False
19+
use_xpu: True
20+
train_batch_size: 10
21+
epochs: 20
22+
print_interval: 2
23+
#model_init_path: "output_model/0" # init model
24+
model_save_path: "output_model_all"
25+
infer_batch_size: 2
26+
infer_reader_path: "NAMLDataReader" # importlib format
27+
test_data_dir: "data/sample_data/train"
28+
infer_load_path: "output_model_all"
29+
infer_start_epoch: 0
30+
infer_end_epoch: 3
31+
32+
# hyper parameters of user-defined network
33+
hyper_parameters:
34+
# optimizer config
35+
optimizer:
36+
class: Adam
37+
learning_rate: 0.001
38+
strategy: async
39+
# user-defined <key, value> pairs
40+
article_content_size: 30
41+
article_title_size: 10
42+
browse_size: 10
43+
neg_condidate_sample_size: 4
44+
word_dimension: 30
45+
category_size: 4
46+
sub_category_size: 10
47+
category_dimension: 32
48+
word_dict_size: 101
Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,56 @@
1-
# How to train naml on kunlun
1+
# 使用昆仑XPU芯片加速NAML模型训练
22

3-
## Prepare kunlun environment
4-
[Paddle installation for machines with Kunlun XPU card](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/2.0-rc1/install/install_Kunlun_zh.html)
3+
## 准备Paddle昆仑XPU版训练环境
4+
[昆仑XPU芯片运行飞桨](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/xpu_docs/index_cn.html)
55

6-
## Prepare data
6+
## 数据准备
7+
8+
### 示例数据
9+
参考 [数据准备](README##数据准备)
10+
11+
12+
### 全量数据
713
```shell
814
cd PaddleRec/datasets/MIND/data
915
bash run.sh
1016
```
1117

12-
## Train
18+
## 训练
1319
```shell
14-
# set kunlun card id
20+
# 设置训练使用的昆仑XPU芯片卡号
1521
export FLAGS_selected_xpus=0
16-
# enable convolution autotune
22+
# 开启昆仑XPU芯片卷积计算加速(可不设置)
1723
export XPU_CONV_AUTOTUNE=2
1824

1925
cd PaddleRec/models/rank/naml
20-
python3.7 -u ../../../tools/trainer.py -m config_bigdata_kunlun.yaml
26+
# 全量数据动态图训练
27+
python3.7 -u ../../../tools/trainer.py -m config_bigdata_kunlun.yaml # 使用示例数据,请指定config_kunlun.yaml
28+
# 全量数据静态图训练
29+
python3.7 -u ../../../tools/static_trainer.py -m config_bigdata_kunlun.yaml # 使用示例数据,请指定config_kunlun.yaml
2130
```
2231

23-
24-
## Eval
32+
## 评估
2533
```shell
26-
# set kunlun card id
34+
# 设置训练使用的昆仑XPU芯片卡号
2735
export FLAGS_selected_xpus=0
28-
# enable convolution autotune
36+
# 开启昆仑XPU芯片卷积计算加速(可不设置)
2937
export XPU_CONV_AUTOTUNE=2
3038

3139
cd PaddleRec/models/rank/naml
32-
python3.7 -u ../../../tools/infer.py -m config_bigdata_kunlun.yaml
40+
# 全量数据动态图预测
41+
python3.7 -u ../../../tools/infer.py -m config_bigdata_kunlun.yaml # 使用示例数据,请指定config_kunlun.yaml
42+
# 全量数据静态图预测
43+
python3.7 -u ../../../tools/static_infer.py -m config_bigdata_kunlun.yaml # 使用示例数据,请指定config_kunlun.yaml
3344
```
45+
46+
## 模型效果
47+
以下为全量数据训练2个epoch的结果:
48+
49+
| 模型 | 训练auc |batch_size | epoch_num| Time of each epoch|
50+
| :------| :------ | :------ | :------| :------ |
51+
| naml | 0.71 | 50 | 2 | 约7小时 |
52+
53+
54+
| 模型 | 预测auc |batch_size | Time of each epoch|
55+
| :------| :------ | :------ | :------ |
56+
| naml | 0.67 | 10 | 约2小时 |

0 commit comments

Comments
 (0)