文心大模型开发套件ERNIEKit,面向NLP工程师,提供全流程大模型开发与部署工具集,端到端、全方位发挥大模型效能。
提供业界效果领先的ERNIE3.0系列开源模型和基于ERNIE的前沿任务模型,满足企业和开发者对NLP模型开发和学习的需求,预置文本分类、文本匹配、序列标注、信息抽取、文本生成五大经典NLP任务,提供基于ERNIE3.0的预训练模型的开发和使用。
PS:这里特别注释一下,目前ERNIEKit套件在兼容Paddle2.4版本上还有点问题,稳定版本是2.2,下属环境介绍里也有表明,主要还是对1.x的fluid兼容问题。
代码结构:
文本匹配任务位于./applications/tasks/text_matching
训练集
ERNIE数据集与非ERNIE数据集格式一致,不同之处在于不用分词
ERNIE词表文件格式与非ERNIE的格式一致,ERNIE词表由文心model提供,./applications/models_hub路径下各ERNIE模型文件夹下存在着对应的词表文件,用户可根据需要进行选择,具体示例如下所示:
[PAD]0[CLS]1[SEP]2[MASK]3,4的5、6一7人81.2网络(模型)选择文心预置的可用于文本分类的模型源文件在applications/tasks/text_matching/model目录下,在介绍具体的模型前先对文本匹配网络涉及到的概念进行描述。
面向搜索、推荐系统排序模块、召回模块的常规解决方案,具体如下:
文心提供的ERNIE预训练模型的下载脚本在applications/models_hub目录下,各预训练模型可由对应的download_xx.sh文件下载得到,用户可根据需求自行下载。其中,ernie_config.json为ERNIE预训练模型的配置文件,vocab.txt为ERNIE预训练模型的词表文件,params目录为ERNIE预训练模型的参数文件目录。
匹配任务常用的指标有:Acc(准确率)、Precision(精确率)、Recall(召回率)、pn(正逆序比)、Auc、F1等
1、GPU环境及示例
环境示例
2、配置环境变量:
├──examples###各典型网络的json配置文件,infer后缀的为对应的预测配置文件│├──mtch_bow_pairwise_ch.json│├──mtch_ernie_fc_pointwise_ch.json│├──mtch_ernie_pairwise_simnet_ch.json│└──mtch_ernie_pointwise_simnet_ch.json#ernie_3.0模型下载#进入models_hub目录%cd./ERNIE/applications/models_hub#运行下载脚本!shdownload_ernie_3.0_base_ch.sh#进入对应目录%cd..%cd./tasks/text_matching#%cd/home/aistudio/ERNIE/applications/tasks/text_matching2.3训练模型使用run_trainer.py脚本加载不同的配置文件从而训练不同的模型
#训练BowMatchingPairwise模型pythonrun_trainer.py--param_path./examples/mtch_bow_pairwise_ch.json#训练ErnieMatchingFcPointwise模型pythonrun_trainer.py--param_path./examples/mtch_ernie_fc_pointwise_ch.json#训练ErnieMatchingSiamesePairwise模型pythonrun_trainer.py--param_path./examples/mtch_ernie_pairwise_simnet_ch.json#训练ErnieMatchingSiamesePointwise模型pythonrun_trainer.py--param_path./examples/mtch_ernie_pointwise_simnet_ch.json#可自行修改代码!pythonrun_trainer.py--param_path./examples/mtch_ernie_fc_pointwise_ch.json部分结果展示
INFO:02-1417:24:43:dynamic_trainer.py:170*140322371376896savepath:./output/mtch_ernie_3.0_base_fc_pointwise_ch/save_inference_model/inference_step_631INFO:02-1417:24:44:run_trainer.py:102*140322371376896endofruntrainandeval.....2.4模型预测#预测BowMatchingPairwise模型pythonrun_infer.py--param_path./examples/mtch_bow_pairwise_ch_infer.json#预测ErnieMatchingFcPointwise模型pythonrun_infer.py--param_path./examples/mtch_ernie_fc_pointwise_ch_infer.json#预测ErnieMatchingSiamesePairwise模型pythonrun_infer.py--param_path./examples/mtch_ernie_pairwise_simnet_ch_infer.json#预测ErnieMatchingSiamesePointwise模型pythonrun_infer.py--param_path./examples/mtch_ernie_pointwise_simnet_ch_infer.json#需要自行修改路径inference_model_path"!pythonrun_infer.py--param_path./examples/mtch_ernie_fc_pointwise_ch_infer.json#最后会生成预测文件:/home/aistudio/ERNIE/applications/tasks/text_matching/output/predict_result.txt部分预测结果展示:
趁着情人节介绍推广一下文心ERNIEKit套件,赶快收藏起来,节后卷起来。文心大模型开发套件ERNIEKit,面向NLP工程师,提供全流程大模型开发与部署工具集,端到端、全方位发挥大模型效能。
效果领先、简单易用、高效灵活的NLP算法定制开发工具,预置30余个大规模预训练模型、40余个NLP基础任务、20余个数据预处理工具、10余个模型微调工具。支持在BML私有化平台中使用。(旗舰版)