diff --git a/.DS_Store b/.DS_Store index 87ed5be0a4491ef9c19a8274f5989cf8fff6ca72..73dba135a06756429233549cf93f6cef74bd81ec 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/README.md b/README.md index e5b29568372a0c7c84811394de7d39c241e2ae32..f2a786e329b62a3637465d0e7504425c38b08f6d 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ git clone https://github.com/PaddlePaddle/ERNIE.git ```plain # ernie_3.0 模型下载 # 进入models_hub目录 -cd ./erniekit_appzoo/erniekit_appzoo/models_hub +cd ./applications/models_hub # 运行下载脚本 sh download_ernie_3.0_base_ch.sh ``` @@ -87,7 +87,7 @@ sh download_ernie_3.0_base_ch.sh ```shell #进入文本分类任务文件夹 -cd ./erniekit_appzoo/erniekit_appzoo/tasks/text_classification/ +cd ./applications/tasks/text_classification/ #查看文本分类任务自带数据集 ls ./data ``` @@ -148,12 +148,12 @@ python run_infer.py --param_path ./examples/cls_enrie_fc_ch_infer.json # 预训练模型介绍 -- 参考预训练模型原理介绍:[模型介绍](./erniekit_appzoo/erniekit_appzoo/models_hub/README.md) -- 预训练模型下载:进入./erniekit_appzoo/models_hub目录下,下载示例: +- 参考预训练模型原理介绍:[模型介绍](./applications/models_hub) +- 预训练模型下载:进入./applications/models_hub目录下,下载示例: ```plain #进入预训练模型下载目录 -cd ./erniekit_appzoo/models_hub +cd ./applications/models_hub #下载ERNIE3.0 base模型 sh downlaod_ernie3.0_base_ch.sh ``` @@ -218,19 +218,19 @@ sh downlaod_ernie3.0_base_ch.sh # 应用场景 -文本分类([文本分类](./erniekit_appzoo/erniekit_appzoo/tasks/text_classification)) +文本分类([文本分类](./applications/tasks/text_classification)) -文本匹配([文本匹配](./erniekit_appzoo/erniekit_appzoo/tasks/text_matching/README.md)) +文本匹配([文本匹配](./applications/tasks/text_matching)) -系列标注([序列标注](./erniekit_appzoo/erniekit_appzoo/tasks/sequence_labeling/README.md)) +系列标注([序列标注](./applications/tasks/sequence_labeling)) -信息抽取([信息抽取](./erniekit_appzoo/erniekit_appzoo/tasks/information_extraction_many_to_many/README.md)) +信息抽取([信息抽取](./applications/tasks/information_extraction_many_to_many)) -文本生成([文本生成](./erniekit_appzoo/erniekit_appzoo/tasks/text_generation/README.md)) +文本生成([文本生成](./applications/tasks/text_generation)) -数据蒸馏([数据蒸馏](./erniekit_appzoo/erniekit_appzoo/tasks/data_distillation/README.md)) +数据蒸馏([数据蒸馏](./applications/tasks/data_distillation)) -工具使用([工具使用](./erniekit_appzoo/erniekit_appzoo/tools/README.md)) +工具使用([工具使用](./applications/tools)) # 文献引用 diff --git a/applications/.DS_Store b/applications/.DS_Store index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..b2cef4b13c498e5809519c279c97ab0b36cff08e 100644 Binary files a/applications/.DS_Store and b/applications/.DS_Store differ diff --git a/applications/models_hub/README.md b/applications/models_hub/README.md new file mode 100644 index 0000000000000000000000000000000000000000..6f1b7f9d917fd2991537483c4a5ad351fb395c76 --- /dev/null +++ b/applications/models_hub/README.md @@ -0,0 +1,18 @@ +# 模型介绍 + +- 预训练模型:包含预训练模型下载脚本、模型配置的json文件、模型对应的词表文件、外加一个简单介绍文件(readme.txt) + +- 开箱即用的模型 + +# Ernie2.0 + +[Ernie2.0 ](https://www.jiqizhixin.com/articles/2019-07-31-10) + + +# Ernie-M + +[Ernie-M](https://github.com/PaddlePaddle/ERNIE/tree/repro/ernie-m) + +# Ernie-Gen + +[Ernie-Gen](https://github.com/PaddlePaddle/ERNIE/tree/repro/ernie-gen) \ No newline at end of file diff --git a/applications/tasks/.DS_Store b/applications/tasks/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..c75a44c4b29cb4414418af95f448fd3afe08cd98 Binary files /dev/null and b/applications/tasks/.DS_Store differ diff --git a/applications/tasks/data_distillation/README.md b/applications/tasks/data_distillation/README.md index 392a10af445f5225ac2e0526a0b20105d0bcd8d9..161d54021327a7ac32821effb82dc4b55587a625 100644 --- a/applications/tasks/data_distillation/README.md +++ b/applications/tasks/data_distillation/README.md @@ -6,7 +6,7 @@ ## 代码结构 -- 数据蒸馏任务位于 erniekit_appzoo/tasks/data_distillation +- 数据蒸馏任务位于 applications/tasks/data_distillation ```plain data_distillation/ @@ -58,21 +58,21 @@ data_distillation/ - 使用预置的ERNIE 3.0 base模型 ```plain -cd erniekit_appzoo/models_hub +cd applications/models_hub bash download_ernie_3.0_base_ch.sh ``` - 下载预置的原始数据以及增强数据。 ```plain -cd erniekit_appzoo/tasks/data_distillation/distill +cd applications/tasks/data_distillation/distill bash download_data.sh ``` - 运行以下命令,开始数据蒸馏 ```plain -cd erniekit_appzoo/tasks/data_distillation +cd applications/tasks/data_distillation bash run_distill.sh ``` diff --git a/applications/tasks/information_extraction_many_to_many/README.md b/applications/tasks/information_extraction_many_to_many/README.md index b549dd0c6cc711363be8a5cdf446316a09510dcd..42c348c7b698bfbce7de6acecea3c177c4b6ef75 100644 --- a/applications/tasks/information_extraction_many_to_many/README.md +++ b/applications/tasks/information_extraction_many_to_many/README.md @@ -8,7 +8,7 @@ ## 代码结构 -- 多对多信息抽取任务位于 ./erniekit_appzoo/tasks/information_extraction_many_to_many +- 多对多信息抽取任务位于 ./applications/tasks/information_extraction_many_to_many ``` information_extraction_many_to_many/ @@ -134,7 +134,7 @@ python convert_data.py ### 网络(模型)选择 -- 文心预置的可用于生成任务的模型源文件在erniekit_appzoo/erniekit_appzoo/tasks/text_generation/model/目录下 +- 文心预置的可用于生成任务的模型源文件在applications/applications/tasks/text_generation/model/目录下 | 网络名称(py文件的类型) | 简介 | 支持类型 | 备注 | | -------------------------------------- | ------------------------------------------------------------ | ------------------------ | -------- | @@ -142,7 +142,7 @@ python convert_data.py ### ERNIE预训练模型下载 -- 文心提供的[ERNIE预训练模型](../../../../../README_MODEL.md)的参数文件和配置文件在 erniekit_appzoo/erniekit_appzoo/models_hub目录下,使用对应的sh脚本,即可拉取对应的模型、字典、必要环境等文件。 +- 文心提供的[ERNIE预训练模型](../../../../../README_MODEL.md)的参数文件和配置文件在 applications/applications/models_hub目录下,使用对应的sh脚本,即可拉取对应的模型、字典、必要环境等文件。 | 模型名称 | 下载脚本 | 备注 | | --------------- | ---------------------------------- | ------------------------------------------ | @@ -158,10 +158,10 @@ python convert_data.py ## 开始训练 -- 以属性抽取数据集的训练为例,进入指定任务目录./erniekit_appzoo/tasks/information_extraction_many_to_many +- 以属性抽取数据集的训练为例,进入指定任务目录./applications/tasks/information_extraction_many_to_many ``` -cd ./erniekit_appzoo/tasks/information_extraction_many_to_many +cd ./applications/tasks/information_extraction_many_to_many ``` #### 训练的配置文件 diff --git a/applications/tasks/sequence_labeling/README.md b/applications/tasks/sequence_labeling/README.md index acac98ade1b82832b45c89fb129a95e94a9120c0..3a2fd714c620947d043272d51572d07d9dcfc038 100644 --- a/applications/tasks/sequence_labeling/README.md +++ b/applications/tasks/sequence_labeling/README.md @@ -4,7 +4,7 @@ ## 代码结构 -- 序列标注任务位于 ./erniekit_appzoo/tasks/sequence_labeling +- 序列标注任务位于 ./applications/tasks/sequence_labeling ``` . @@ -42,7 +42,7 @@ - 在文心中,基于ERNIE的模型都不需要用户自己分词和生成词表文件,非ERNIE的模型需要用户自己提前切好词,词之间以空格分隔,并生成词表文件。切词和词表生成可以使用「[分词工具与词表生成工具](../../tools/data/wordseg/README.md)」进行处理。 - 文心中的所有数据集、包含词表文件、label_map文件等都必须为为utf-8格式,如果你的数据是其他格式,请使用「[编码识别及转换工具](../../tools/data/data_cleaning/README.md)」进行格式转换。 -- 文心中的训练集、测试集、验证集、预测集和词表分别存放在./erniekit_appzoo/tasks/sequence_labeling/data目录下的train_data、test_data、dev_data、predict_data、dict文件夹下。 +- 文心中的训练集、测试集、验证集、预测集和词表分别存放在./applications/tasks/sequence_labeling/data目录下的train_data、test_data、dev_data、predict_data、dict文件夹下。 #### 训练集/测试集/验证集文件格式 @@ -56,7 +56,7 @@ #### 词表 -- 词表:./erniekit_appzoo/tasks/sequence_labeling/data/dict/vocab.txt +- 词表:./applications/tasks/sequence_labeling/data/dict/vocab.txt - 词表文件:词表分为两列,第一列为词,第二列为id(从0开始),列与列之间用**\t**进行分隔,一般是vocab.txt文件。文心的词表中,[PAD]、[CLS]、[SEP]、[MASK]、[UNK]这5个词是必须要有的,若用户自备词表,需保证这5个词是存在的。 ```plain @@ -75,7 +75,7 @@ #### 标签词表 -- 标签词表:./erniekit_appzoo/tasks/sequence_labeling/data/dict/vocab_label_map.txt +- 标签词表:./applications/tasks/sequence_labeling/data/dict/vocab_label_map.txt - 标签词表文件:标签词表分为两列,第一列为词,第二列为id(从0开始),列与列之间用**\t**进行分隔,一般是vocab_label_map.txt文件。标签顺序需要满足对应的标签体系,比如下面是BIO的标签体系,同一类别的标签B要排在I前面,O排在整个标签词表的最后。 ```plain @@ -90,7 +90,7 @@ B-PER 0 ### 网络(模型)选择 -- 文心预置的可用于序列标注的模型在erniekit_appzoo/tasks/sequence_labeling/model目录下,目前支持模型的特点如下所示: +- 文心预置的可用于序列标注的模型在applications/tasks/sequence_labeling/model目录下,目前支持模型的特点如下所示: | 网络名称(py文件的类名) | 简介 | 支持类型 | 支持预训练模型 | 备注 | | ------------------------------------------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ | ---- | @@ -98,7 +98,7 @@ B-PER 0 ### ERNIE预训练模型下载 -- 文心提供的[ERNIE预训练模型](../../models_hub/README.md)的参数文件和配置文件在erniekit_appzoo/models_hub目录下,由对应的download_xx.sh文件是下载得到,包括模型的参数文件、配置文件以及词表等。 +- 文心提供的[ERNIE预训练模型](../../models_hub/README.md)的参数文件和配置文件在applications/models_hub目录下,由对应的download_xx.sh文件是下载得到,包括模型的参数文件、配置文件以及词表等。 | 模型名称 | 下载脚本 | 备注 | | --------------- | ---------------------------------- | ------------------------------------------ | @@ -119,10 +119,10 @@ B-PER 0 ## 开始训练 -- 进入制定任务目录 ./erniekit_appzoo/tasks/sequence_labeling +- 进入制定任务目录 ./applications/tasks/sequence_labeling ``` -cd ./erniekit_appzoo/tasks/sequence_labeling +cd ./applications/tasks/sequence_labeling ``` ### 训练的配置文件 diff --git a/applications/tasks/text_classification/README_CODE.md b/applications/tasks/text_classification/README_CODE.md index 46f9bc308275e193bc22669b9aeba496f5b1df4b..006c5257cd1cb7ec6b3fbe73a4aee6dfec03a1f4 100644 --- a/applications/tasks/text_classification/README_CODE.md +++ b/applications/tasks/text_classification/README_CODE.md @@ -2,7 +2,7 @@ ## 代码结构 -- 分类任务位于erniekit_appzoo/tasks/text_classification +- 分类任务位于applications/tasks/text_classification ```plain . @@ -79,7 +79,7 @@ - 在文心中,基于ERNIE的模型都不需要用户自己分词和生成词表文件,非ERNIE的模型需要用户自己提前切好词,词之间以空格分隔,并生成词表文件。切词和词表生成可以使用「[分词工具与词表生成工具](../../tools/data/wordseg/README.md)」进行处理。 - 文心中的所有数据集、包含词表文件、label_map文件等都必须为为utf-8格式,如果你的数据是其他格式,请使用「[编码识别及转换工具](../../tools/data/data_cleaning/README.md)」进行格式转换。 -- 文心中的训练集、测试集、验证集、预测集和词表分别存放在./erniekit_appzoo/tasks/text_classification/data目录下的train_data、test_data、dev_data、predict_data、dict文件夹下。 +- 文心中的训练集、测试集、验证集、预测集和词表分别存放在./applications/tasks/text_classification/data目录下的train_data、test_data、dev_data、predict_data、dict文件夹下。 - 在分类任务中,训练集、测试集和验证集的数据格式相同,数据分为两列,列与列之间用**\t**进行分隔。第一列为文本,第二列为标签。以下为示例: ### 单标签分类 @@ -158,7 +158,7 @@ USB接口 只有 2个 , 太 少 了 点 , 不能 接 太多 外 接 设备 ## 网络(模型)选择 -文心预置的可用于文本分类的模型源文件在./erniekit_appzoo/tasks/text_classification/model目录下,各个模型的特点如下所示(后面章节会依次展示使用方法): +文心预置的可用于文本分类的模型源文件在./applications/tasks/text_classification/model目录下,各个模型的特点如下所示(后面章节会依次展示使用方法): | 网络名称(py文件的类名) | 简介 | 支持类型 | 支持预训练模型 | 备注 | | ------------------------------------------------------- | ------------------------------------------------------------ | ---------- | ------------------------------------------------------------ | ---- | @@ -169,7 +169,7 @@ USB接口 只有 2个 , 太 少 了 点 , 不能 接 太多 外 接 设备 ## ERNIE预训练模型下载 -文心提供的ERNIE预训练模型的参数文件和配置文件在./erniekit_appzoo/tasks/models_hub/目录下,由对应的download_xx.sh文件是下载得到。ERNIE部分模型介绍,请详见文档「[ERNIE模型介绍](../../models_hub/README.md)」 +文心提供的ERNIE预训练模型的参数文件和配置文件在./applications/tasks/models_hub/目录下,由对应的download_xx.sh文件是下载得到。ERNIE部分模型介绍,请详见文档「[ERNIE模型介绍](../../models_hub/README.md)」 ## 模型评估指标选择 diff --git a/applications/tasks/text_classification/README_ERNIE.md b/applications/tasks/text_classification/README_ERNIE.md index f178e94e3de505118fb666421aba7db61012fba2..a5d5d4d506ebdfa2405fd8899bc4e4c47da4d56a 100644 --- a/applications/tasks/text_classification/README_ERNIE.md +++ b/applications/tasks/text_classification/README_ERNIE.md @@ -2,15 +2,15 @@ # 开始训练 -- 进入分类任务的目录./erniekit_appzoo/tasks/text_classification +- 进入分类任务的目录./applications/tasks/text_classification ``` -cd ./erniekit_appzoo/tasks/text_classification +cd ./applications/tasks/text_classification ``` ## 预训练模型准备 -- 模型均存放于./erniekit_appzoo/models_hub文件夹下,进入该文件夹下载对应ERNIE模型 +- 模型均存放于./applications/models_hub文件夹下,进入该文件夹下载对应ERNIE模型 ``` cd ../../models_hub diff --git a/applications/tasks/text_classification/README_GRID.md b/applications/tasks/text_classification/README_GRID.md index 051f4e7acf264b3aaad41cf7ff89836eb3b0b56c..7191cc9acfb2d015de0af364ea920d6880f01628 100644 --- a/applications/tasks/text_classification/README_GRID.md +++ b/applications/tasks/text_classification/README_GRID.md @@ -7,7 +7,7 @@ 这里我们以BOW分类任务为例介绍文心中的网格搜索的使用方式,主要分为以下几个步骤: 1. 数据准备:数据集的准备与通用的BOW分类任务一致,不再赘述,详细信息请移步“[快速使用->实战演练:使用文心进行模型训练](https://ai.baidu.com/ai-doc/ERNIE-Ultimate/Ekmlrorrp)” -2. 参数配置:以erniekit_appzoo/tasks/text_classification/examples/cls_bow_ch.json为例,假如我们需要对学习率这个参数进行网格搜索设置,那么将”model”中的”learning_rate“的值修改为一个数组即可。目前文心的网格搜索的作用范围在optimization和train_reader的config中,用户可设置多个learning_rate、batch_size和epoch等。修改示例如下: +2. 参数配置:以applications/tasks/text_classification/examples/cls_bow_ch.json为例,假如我们需要对学习率这个参数进行网格搜索设置,那么将”model”中的”learning_rate“的值修改为一个数组即可。目前文心的网格搜索的作用范围在optimization和train_reader的config中,用户可设置多个learning_rate、batch_size和epoch等。修改示例如下: ``` { @@ -36,7 +36,7 @@ } ``` -3. 启动训练:使用网格搜索进行训练的启动脚本与普通训练任务不一样,启动脚本为**run_with_preprocess.py**,该脚本的位置在erniekit_appzoo/tools/run_preprocess/目录下,可以拷贝到当前erniekit_appzoo/tasks/text_classification目录下使用,入参为上一步骤配置好的json文件,具体如下所示: +3. 启动训练:使用网格搜索进行训练的启动脚本与普通训练任务不一样,启动脚本为**run_with_preprocess.py**,该脚本的位置在applications/tools/run_preprocess/目录下,可以拷贝到当前applications/tasks/text_classification目录下使用,入参为上一步骤配置好的json文件,具体如下所示: ``` # BOW 中文文本分类模型 @@ -50,8 +50,8 @@ python run_with_preprocess.py --param_path ./examples/cls_bow_ch.json - json_tmp:交叉验证处理完成之后生成的新的待运行配置文件,如下图所示: -![img](http://rte.weiyun.baidu.com/api/imageDownloadAddress?attachId=2c310896927a4aa0a76a8b2331b18a76) +![img](./img/1.png) - log:基于交run_with_preprocess.py运行的任务都会生成新的json配置,每个json对应一个独立的trainer,各个trainer按照顺序串行训练,所以日志会分别输出到对应编号的log中。如下图就是串行的4个trainer的日志。日志内容和单独运行run_trainer.py输出到test.log中的日志一样,如下图所示: -![img](http://rte.weiyun.baidu.com/api/imageDownloadAddress?attachId=5188e4fb42bf41c1aaf9cd208aecbe41) +![img](./img/2.png) diff --git a/applications/tasks/text_classification/README_M.md b/applications/tasks/text_classification/README_M.md index e73ddad65f23a86785f6caa67c1a33b40813fae5..49fcc400710772b7a9d631b82650a33169493d9d 100644 --- a/applications/tasks/text_classification/README_M.md +++ b/applications/tasks/text_classification/README_M.md @@ -2,15 +2,15 @@ ## 开始训练 -- 进入分类任务的目录./erniekit_appzoo/tasks/text_classification +- 进入分类任务的目录./applications/tasks/text_classification ``` -cd ./erniekit_appzoo/tasks/text_classification +cd ./applications/tasks/text_classification ``` ### 预训练模型准备 -- 模型均存放于./erniekit_appzoo/models_hub文件夹下,进入该文件夹下载对应ERNIE-M模型 +- 模型均存放于./applications/models_hub文件夹下,进入该文件夹下载对应ERNIE-M模型 ``` cd ../../models_hub diff --git a/applications/tasks/text_classification/img/1.png b/applications/tasks/text_classification/img/1.png new file mode 100644 index 0000000000000000000000000000000000000000..866c97adc09cee540beb5d44b685ffacf51e21ba Binary files /dev/null and b/applications/tasks/text_classification/img/1.png differ diff --git a/applications/tasks/text_classification/img/2.png b/applications/tasks/text_classification/img/2.png new file mode 100644 index 0000000000000000000000000000000000000000..8478091724dced208fca5c2bfd53f1e582f7235e Binary files /dev/null and b/applications/tasks/text_classification/img/2.png differ diff --git a/applications/tasks/text_generation/README.md b/applications/tasks/text_generation/README.md index 728e74008272fc7ee8a36e61e7ddab603770c32f..153b6235a5155e72fea84eede6fa0b215baad383 100644 --- a/applications/tasks/text_generation/README.md +++ b/applications/tasks/text_generation/README.md @@ -5,7 +5,7 @@ ## 代码结构 -- 文本生成任务位于 ./erniekit_appzoo/tasks/text_generation +- 文本生成任务位于 ./applications/tasks/text_generation ```shell text_generation/ @@ -51,7 +51,7 @@ text_generation/ ### 网络(模型)选择 -- 文心预置的可用于生成任务的模型源文件在./erniekit_appzoo/tasks/text_generation/model/目录下 +- 文心预置的可用于生成任务的模型源文件在./applications/tasks/text_generation/model/目录下 | 网络名称(py文件的类型) | 简介 | 支持类型 | 备注 | | ------------------------------------------------------- | ------------------------------------------------------------ | -------------------- | ---------- | @@ -59,7 +59,7 @@ text_generation/ ### ERNIE预训练模型下载 -- 文心提供的[ERNIE预训练模型](../../models_hub/README.md)的参数文件和配置文件在 erniekit_appzoo/erniekit_appzoo/models_hub目录下,使用对应的sh脚本,即可拉取对应的模型、字典、必要环境等文件。 +- 文心提供的[ERNIE预训练模型](../../models_hub/README.md)的参数文件和配置文件在 applications/applications/models_hub目录下,使用对应的sh脚本,即可拉取对应的模型、字典、必要环境等文件。 | 模型名称 | 下载脚本 | 备注 | | --------- | -------------------------------- | -------------------------------------------------------- | @@ -71,10 +71,10 @@ text_generation/ ## 开始训练 -- 进入指定任务的目录:./erniekit_appzoo/tasks/text_generation +- 进入指定任务的目录:./applications/tasks/text_generation ``` -cd ./erniekit_appzoo/tasks/text_generation +cd ./applications/tasks/text_generation ``` ### 训练的配置文件 diff --git a/applications/tasks/text_matching/README.md b/applications/tasks/text_matching/README.md index eafa7c77f5f64c9b6899dee908817eb0b0a8e5a6..eabaa0de08d1830dc7a25d6e7d3ad1b1159b21c1 100644 --- a/applications/tasks/text_matching/README.md +++ b/applications/tasks/text_matching/README.md @@ -4,7 +4,7 @@ ## 代码结构 -- 文本匹配任务位于./erniekit_appzoo/tasks/text_matching +- 文本匹配任务位于./applications/tasks/text_matching ```plain . @@ -63,8 +63,8 @@ - 在文心中,基于ERNIE的模型都不需要用户自己分词和生成词表文件,非ERNIE的模型需要用户自己提前切好词,词之间以空格分隔,并生成词表文件。切词和词表生成可以使用「[分词工具与词表生成工具](../../tools/data/wordseg/README.md)」进行处理。 - 文心中的所有数据集、包含词表文件、label_map文件等都必须为为utf-8格式,如果你的数据是其他格式,请使用「[编码识别及转换工具](../../tools/data/data_cleaning/README.md)」进行格式转换。 - 在文本匹配任务中,根据其训练方式的不同,训练集分为Pointwise和Pairwise两种格式,测试集、验证集和预测集的格式相同。 -- 非ERNIE数据的pointwise训练集、pairwise训练集、测试集、验证集和预测集分别存放在./erniekit_appzoo/tasks/text_matching/data目录下的train_data_pointwise_tokenized、train_data_pairwise_tokenized、test_data_tokenized、dev_data_tokenized和predict_data_tokenized文件夹下。 -- ERNIE数据的pointwise训练集、pairwise训练集、测试集、验证集和预测集分别存放在./erniekit_appzoo/tasks/text_matching/data目录下的train_data_pointwise、train_data_pairwise、test_data、dev_data和predict_data文件夹下。 +- 非ERNIE数据的pointwise训练集、pairwise训练集、测试集、验证集和预测集分别存放在./applications/tasks/text_matching/data目录下的train_data_pointwise_tokenized、train_data_pairwise_tokenized、test_data_tokenized、dev_data_tokenized和predict_data_tokenized文件夹下。 +- ERNIE数据的pointwise训练集、pairwise训练集、测试集、验证集和预测集分别存放在./applications/tasks/text_matching/data目录下的train_data_pointwise、train_data_pairwise、test_data、dev_data和predict_data文件夹下。 #### **非ERNIE模型数据** @@ -108,7 +108,7 @@ ##### 词表 -- 非ERNIE模型的词表文件示例存放在**./erniekit_appzoo/tasks/text_matching/data/dict/vocab.txt**:词表分为两列,第一列为词,第二列为id(从0开始),列与列之间用**\t**进行分隔。文心的词表中**,**[PAD]、[CLS]、[SEP]、[MASK]、[UNK]这5个词是必须要有的,若用户自备词表,需保证这5个词是存在的。部分词表示例如下所示: +- 非ERNIE模型的词表文件示例存放在**./applications/tasks/text_matching/data/dict/vocab.txt**:词表分为两列,第一列为词,第二列为id(从0开始),列与列之间用**\t**进行分隔。文心的词表中**,**[PAD]、[CLS]、[SEP]、[MASK]、[UNK]这5个词是必须要有的,若用户自备词表,需保证这5个词是存在的。部分词表示例如下所示: ```plain [PAD] 0 @@ -172,7 +172,7 @@ ##### 词表 -- ERNIE词表文件格式与非ERNIE的格式一致,ERNIE词表由文心model提供,./erniekit_appzoo/models_hub路径下各ERNIE模型文件夹下存在着对应的词表文件,用户可根据需要进行选择,具体示例如下所示: +- ERNIE词表文件格式与非ERNIE的格式一致,ERNIE词表由文心model提供,./applications/models_hub路径下各ERNIE模型文件夹下存在着对应的词表文件,用户可根据需要进行选择,具体示例如下所示: ```plain [PAD] 0 @@ -188,7 +188,7 @@ ### 网络(模型)选择 -- 文心预置的可用于文本分类的模型源文件在erniekit_appzoo/tasks/text_matching/model目录下,在介绍具体的模型前先对文本匹配网络涉及到的概念进行描述。 +- 文心预置的可用于文本分类的模型源文件在applications/tasks/text_matching/model目录下,在介绍具体的模型前先对文本匹配网络涉及到的概念进行描述。 | | 单塔 | 双塔 | | --------- | --------------- | --------------- | @@ -212,7 +212,7 @@ ### ERNIE预训练模型下载 -- 文心提供的[ERNIE预训练模型](../../models_hub/README.md)的下载脚本在erniekit_appzoo/models_hub目录下,各预训练模型可由对应的download_xx.sh文件下载得到,用户可根据需求自行下载。其中,ernie_config.json为ERNIE预训练模型的配置文件,vocab.txt为ERNIE预训练模型的词表文件,params目录为ERNIE预训练模型的参数文件目录。 +- 文心提供的[ERNIE预训练模型](../../models_hub/README.md)的下载脚本在applications/models_hub目录下,各预训练模型可由对应的download_xx.sh文件下载得到,用户可根据需求自行下载。其中,ernie_config.json为ERNIE预训练模型的配置文件,vocab.txt为ERNIE预训练模型的词表文件,params目录为ERNIE预训练模型的参数文件目录。 | 模型名称 | 下载脚本 | 备注 | | --------------- | ---------------------------------- | ------------------------------------------ | @@ -233,10 +233,10 @@ ## 开始训练 -- 进入指定任务目录./erniekit_appzoo/tasks/text_matching +- 进入指定任务目录./applications/tasks/text_matching ```shell -cd ./erniekit_appzoo/tasks/text_matching +cd ./applications/tasks/text_matching ``` ### 训练的配置文件 diff --git a/applications/tools/README.md b/applications/tools/README.md index d62eecabca720d4a19385f475c5b2e963b46e400..3785c0d085bae496144d667561a983652ae442f3 100644 --- a/applications/tools/README.md +++ b/applications/tools/README.md @@ -1,8 +1,8 @@ # 工具使用 -- [分词工具与词表生成工具](./data/wordseg/README.md) -- [数据增强](data/data_aug/README.md) -- [交叉验证](./run_preprocess/README.md) +- [分词工具与词表生成工具](./data/wordseg) +- [数据增强](data/data_aug) +- [交叉验证](./run_preprocess) - [网格搜索](../tasks/text_classification/README_GRID.md) -- [编码及转换攻击](./data/data_cleaning/README.md) +- [编码及转换攻击](./data/data_cleaning) diff --git a/applications/tools/data/.DS_Store b/applications/tools/data/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0e1d6b15dba7c0e1f9521d771c3fc6839722dc6a Binary files /dev/null and b/applications/tools/data/.DS_Store differ diff --git a/applications/tools/data/data_aug/README.md b/applications/tools/data/data_aug/README.md index ae94d4471a9fcb93ed379048631152d8ce369424..43195f43c95549f64d6ea042ac3ca38def348775 100644 --- a/applications/tools/data/data_aug/README.md +++ b/applications/tools/data/data_aug/README.md @@ -20,7 +20,7 @@ ## 脚本运行(说明) -开发套件用于数据增强的python脚本位于目录./erniekit_appzoo/tools/data_aug/data_aug.py +开发套件用于数据增强的python脚本位于目录./applications/tools/data_aug/data_aug.py - 运行data_aug.py脚本 ```shell @@ -64,7 +64,7 @@ shell输出: - 进去下游任务(分类任务) ```java -cd ./erniekit_appzoo/tasks/text_classification/ +cd ./applications/tasks/text_classification/ ``` - 一键启动数据增强和训练脚本 diff --git a/applications/tools/data/data_cleaning/README.md b/applications/tools/data/data_cleaning/README.md index d23477ff4914dba0fa28a93be401e86e11de6654..298d42ffd7fdb745423653ad9eadb4e7c612fc5e 100644 --- a/applications/tools/data/data_cleaning/README.md +++ b/applications/tools/data/data_cleaning/README.md @@ -1,6 +1,6 @@ # 编码识别及转换工具 -文心中的所有文件要求必须是utf-8格式,包括所有的样本集、词表文件、label_map等映射文件。 文心提供了文件格式转换的工具,位置在./erniekit_appzoo/tools/data/data_cleaning +文心中的所有文件要求必须是utf-8格式,包括所有的样本集、词表文件、label_map等映射文件。 文心提供了文件格式转换的工具,位置在./applications/tools/data/data_cleaning - 识别输入文本的编码格式: ```plain diff --git a/applications/tools/data/wordseg/README.md b/applications/tools/data/wordseg/README.md index 547e9343ca8e6310a29e01ed54f281d60daad6c9..ab11ee1241f0b2ab7160a4ed4770415aebb90d9e 100644 --- a/applications/tools/data/wordseg/README.md +++ b/applications/tools/data/wordseg/README.md @@ -2,7 +2,7 @@ ## 分词 -开发套件用于分词的python脚本位于目录./erniekit_appzoo/tools/data/wordseg/wordseg_lac.py: +开发套件用于分词的python脚本位于目录./applications/tools/data/wordseg/wordseg_lac.py: - 文心中集成了[LAC](https://www.paddlepaddle.org.cn/modelbasedetail/lac)分词工具,运行该脚本前,需要先下载分词工具[lac](https://github.com/baidu/lac)包,或者直接通过pip命令安装: diff --git a/applications/tools/run_preprocess/README.md b/applications/tools/run_preprocess/README.md index 73aea94e724acba92e17f34f9735a1efd61344bb..860e53dad32d0758e9bed1ec257bb6d05424a4b3 100644 --- a/applications/tools/run_preprocess/README.md +++ b/applications/tools/run_preprocess/README.md @@ -13,7 +13,7 @@ - 每次挑选其中1份作为验证集,剩余k-1份作为训练集用于训练模型; - 重复第2步k次,在每个训练集上训练后得到一个模型。用这个模型在相应的验证集上测试,计算并保存模型的评估指标。 -![img](http://rte.weiyun.baidu.com/api/imageDownloadAddress?attachId=8e5371445df84ada880543a641dd8c1f) +![img](./img/1.png) ## 文心中使用交叉验证 @@ -21,7 +21,7 @@ 1. 准备数据:数据集的准备与通用的BOW分类任务一致,不再赘述,详细信息请移步[实战演练:使用文心进行模型训练](https://ai.baidu.com/ai-doc/ERNIE-Ultimate/Ekmlrorrp)。 -2. 配置参数:以erniekit_appzoo/tasks/text_classification/examples/cls_bow_ch.json为例,交叉验证仅需要在dataset_reader部分进行配置,其余部分与普通的训练任务一致。dataset_reader中k_fold相关参数为K折交叉验证的配置: +2. 配置参数:以applications/tasks/text_classification/examples/cls_bow_ch.json为例,交叉验证仅需要在dataset_reader部分进行配置,其余部分与普通的训练任务一致。dataset_reader中k_fold相关参数为K折交叉验证的配置: - num_fold表示需要将训练集拆成K折,num_fold的取值需要>=2; @@ -64,7 +64,7 @@ } ``` -3. 启动训练:使用交叉验证进行训练的启动脚本与普通训练任务不一样,启动脚本为**run_with_preprocess.py**,该脚本的位置在erniekit_appzoo/tools/run_preprocess/目录下,可以拷贝到erniekit_appzoo/tasks/text_classification目录下使用,入参为上一步骤配置好k_fold参数的json文件,具体如下所示: +3. 启动训练:使用交叉验证进行训练的启动脚本与普通训练任务不一样,启动脚本为**run_with_preprocess.py**,该脚本的位置在applications/tools/run_preprocess/目录下,可以拷贝到applications/tasks/text_classification目录下使用,入参为上一步骤配置好k_fold参数的json文件,具体如下所示: ``` # BOW 中文文本分类模型 @@ -78,12 +78,12 @@ python run_with_preprocess.py --param_path ./examples/cls_bow_ch.json - data_tmp:通过K折交叉验证处理过后的数据,如图所示就是将原始数据分成了4组,每组包含train_data 和 dev_data,如下图所示: -![img](http://rte.weiyun.baidu.com/api/imageDownloadAddress?attachId=6b520e0e75c94b00bfb22d2a70f9cac6) +![img](./img/2.png) - json_tmp:交叉验证处理完成之后生成的新的待运行配置文件,如下图所示: -![img](http://rte.weiyun.baidu.com/api/imageDownloadAddress?attachId=5cfbc77da7a74f429dc5f6f6ffffb268) +![img](./img/3.png) - log:基于交run_with_preprocess.py运行的任务都会生成新的json配置,每个json对应一个独立的trainer,各个trainer按照顺序串行训练,所以日志会分别输出到对应编号的log中。如下图就是串行的4个trainer的日志。日志内容和单独运行run_trainer.py输出到test.log中的日志一样,如下图所示: -![img](http://rte.weiyun.baidu.com/api/imageDownloadAddress?attachId=5c55226559ff4d63aa43720d5f1757bc) +![img](./img/4.png) diff --git a/applications/tools/run_preprocess/img/1.png b/applications/tools/run_preprocess/img/1.png new file mode 100644 index 0000000000000000000000000000000000000000..3b303e5a1990ed0464715fc3aabd403510e8832b Binary files /dev/null and b/applications/tools/run_preprocess/img/1.png differ diff --git a/applications/tools/run_preprocess/img/2.png b/applications/tools/run_preprocess/img/2.png new file mode 100644 index 0000000000000000000000000000000000000000..41aedf06a8e2e8587022635bc5339c5785d1e399 Binary files /dev/null and b/applications/tools/run_preprocess/img/2.png differ diff --git a/applications/tools/run_preprocess/img/3.png b/applications/tools/run_preprocess/img/3.png new file mode 100644 index 0000000000000000000000000000000000000000..866c97adc09cee540beb5d44b685ffacf51e21ba Binary files /dev/null and b/applications/tools/run_preprocess/img/3.png differ diff --git a/applications/tools/run_preprocess/img/4.png b/applications/tools/run_preprocess/img/4.png new file mode 100644 index 0000000000000000000000000000000000000000..8478091724dced208fca5c2bfd53f1e582f7235e Binary files /dev/null and b/applications/tools/run_preprocess/img/4.png differ