Skip to content

Commit b619c19

Browse files
authored
Pretrain (#207)
* add textcnn_pretrain * add textcnn_pretrain * change classification to textcnn * add readme in paddlerec
1 parent 3061d46 commit b619c19

File tree

22 files changed

+856
-15
lines changed

22 files changed

+856
-15
lines changed

doc/pre_train_model.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,27 @@ PaddleRec基于业务实践,使用真实数据,产出了推荐领域算法
77
### 获取地址
88

99
```bash
10-
wget xxx.tar.gz
10+
wget https://paddlerec.bj.bcebos.com/textcnn_pretrain%2Fpretrain_model.tar.gz
1111
```
1212

1313
### 使用方法
1414

15-
解压后,得到的是一个paddle的模型文件夹,使用`PaddleRec/models/contentunderstanding/classification_finetue`模型进行加载
15+
解压后,得到的是一个paddle的模型文件夹,使用`PaddleRec/models/contentunderstanding/textcnn`模型进行加载
16+
您可以在PaddleRec/models/contentunderstanding/textcnn_pretrain中找到finetune_startup.py文件,在config.yaml中配置startup_class_path和init_pretraining_model_path两个参数。
17+
在参数startup_class_path中配置finetune_startup.py文件的地址,在init_pretraining_model_path参数中配置您要加载的参数文件。
18+
以textcnn_pretrain为例,配置完的runner如下:
19+
```
20+
runner:
21+
- name: train_runner
22+
class: train
23+
epochs: 6
24+
device: cpu
25+
save_checkpoint_interval: 1
26+
save_checkpoint_path: "increment"
27+
init_model_path: ""
28+
print_interval: 10
29+
startup_class_path: "{workspace}/finetune_startup.py"
30+
init_pretraining_model_path: "{workspace}/pretrain_model/pretrain_model_params"
31+
phases: phase_train
32+
```
33+
具体使用方法请参照textcnn[使用预训练模型进行finetune](https://github.com/PaddlePaddle/PaddleRec/tree/master/models/contentunderstanding/textcnn_pretrain)

doc/yaml.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
| startup_class_path | string | 路径 || 自定义startup流程实现的地址 |
3838
| runner_class_path | string | 路径 || 自定义runner流程实现的地址 |
3939
| terminal_class_path | string | 路径 || 自定义terminal流程实现的地址 |
40+
| init_pretraining_model_path | string | 路径 ||自定义的startup流程中需要传入这个参数,finetune中需要加载的参数的地址 |
41+
4042

4143

4244

models/contentunderstanding/readme.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 内容理解模型库
22

33
## 简介
4-
我们提供了常见的内容理解任务中使用的模型算法的PaddleRec实现, 单机训练&预测效果指标以及分布式训练&预测性能指标等。实现的内容理解模型包括 [Tagspace](tagspace)[文本分类](classification)等。
4+
我们提供了常见的内容理解任务中使用的模型算法的PaddleRec实现, 单机训练&预测效果指标以及分布式训练&预测性能指标等。实现的内容理解模型包括 [Tagspace](tagspace)[文本分类](textcnn)[基于textcnn的预训练模型](textcnn_pretrain)等。
55

66
模型算法库在持续添加中,欢迎关注。
77

@@ -23,7 +23,7 @@
2323
| 模型 | 简介 | 论文 |
2424
| :------------------: | :--------------------: | :---------: |
2525
| TagSpace | 标签推荐 | [EMNLP 2014][TagSpace: Semantic Embeddings from Hashtags](https://www.aclweb.org/anthology/D14-1194.pdf) |
26-
| Classification | 文本分类 | [EMNLP 2014][Convolutional neural networks for sentence classication](https://www.aclweb.org/anthology/D14-1181.pdf) |
26+
| textcnn | 文本分类 | [EMNLP 2014][Convolutional neural networks for sentence classication](https://www.aclweb.org/anthology/D14-1181.pdf) |
2727

2828
下面是每个模型的简介(注:图片引用自链接中的论文)
2929

@@ -32,7 +32,7 @@
3232
<img align="center" src="../../doc/imgs/tagspace.png">
3333
<p>
3434

35-
[文本分类CNN模型](https://www.aclweb.org/anthology/D14-1181.pdf)
35+
[textCNN模型](https://www.aclweb.org/anthology/D14-1181.pdf)
3636
<p align="center">
3737
<img align="center" src="../../doc/imgs/cnn-ckim2014.png">
3838
<p>
@@ -42,7 +42,7 @@
4242
git clone https://github.com/PaddlePaddle/PaddleRec.git paddle-rec
4343
cd PaddleRec
4444
python -m paddlerec.run -m models/contentunderstanding/tagspace/config.yaml
45-
python -m paddlerec.run -m models/contentunderstanding/classification/config.yaml
45+
python -m paddlerec.run -m models/contentunderstanding/textcnn/config.yaml
4646
```
4747

4848
## 使用教程(复现论文)
@@ -134,7 +134,7 @@ batch: 13, acc: [0.928], loss: [0.01736144]
134134
batch: 14, acc: [0.93], loss: [0.01911209]
135135
```
136136

137-
**(2)Classification**
137+
**(2)textcnn**
138138

139139
### 数据处理
140140
情感倾向分析(Sentiment Classification,简称Senta)针对带有主观描述的中文文本,可自动判断该文本的情感极性类别并给出相应的置信度。情感类型分为积极、消极。情感倾向分析能够帮助企业理解用户消费习惯、分析热点话题和危机舆情监控,为企业提供有利的决策支持。
@@ -206,4 +206,4 @@ batch: 3, acc: [0.90234375], loss: [0.27907994]
206206
| 数据集 | 模型 | loss | acc |
207207
| :------------------: | :--------------------: | :---------: |:---------: |
208208
| ag news dataset | TagSpace | 0.0198 | 0.9177 |
209-
| ChnSentiCorp | Classification | 0.2282 | 0.9127 |
209+
| ChnSentiCorp | textcnn | 0.2282 | 0.9127 |

models/contentunderstanding/classification/config.yaml renamed to models/contentunderstanding/textcnn/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
workspace: "models/contentunderstanding/classification"
15+
workspace: "models/contentunderstanding/textcnn"
1616

1717
dataset:
1818
- name: data1

0 commit comments

Comments
 (0)