Python toolkit for Chinese Language Understanding Evaluation benchmark.
中文語言理解測評基準的Python工具包,快速測評代表性數據集、基準(預訓練)模型,並針對自己的數據選擇合適的基準(預訓練)模型進行快速應用。
datasets, baselines, pre-trained models, corpus and leaderboard
中文語言理解測評基準,包括代表性的數據集、基準(預訓練)模型、語料庫、排行榜。
我們會選擇一系列有一定代表性的任務對應的數據集,做為我們測試基準的數據集。這些數據集會覆蓋不同的任務、數據量、任務難度。
現在,可以通過pip安裝PyCLUE:
pip install --upgrade PyCLUE或直接git clone安裝PyCLUE:
pip install git+https://www.github.com/CLUEBenchmark/PyCLUE.git已支持預訓練語言模型
待支持
注:數據集與CLUEBenchmark所提供的數據集一致,僅在格式上相應修改,以適應PyCLUE項目
数据量:训练集(34334)验证集(4316)测试集(3861)
例子:
{"sentence1": "双十一花呗提额在哪", "sentence2": "里可以提花呗额度", "label": "0"}
每一条数据有三个属性,从前往后分别是 句子1,句子2,句子相似度标签。其中label标签,1 表示sentence1和sentence2的含义类似,0表示两个句子的含义不同。
鏈接:https://pan.baidu.com/s/1It1SiMJbsrNl1dEOBoOGXg 提取碼:ksd1
訓練模型腳本位置:PyCLUE/clue/sentence_pair/afqmc/train.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/clue/sentence_pair/afqmc/train.ipynb
提交文件腳本位置:PyCLUE/clue/sentence_pair/afqmc/predict.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/clue/sentence_pair/afqmc/predict.ipynb
該數據集來自今日頭條的新聞版塊,共提取了15個類別的新聞,包括旅遊,教育,金融,軍事等。
数据量:训练集(266,000),验证集(57,000),测试集(57,000)
例子:
{"label": "102", "label_des": "news_entertainment", "sentence": "江疏影甜甜圈自拍,迷之角度竟这么好看,美吸引一切事物"}
每一条数据有三个属性,从前往后分别是 分类ID,分类名称,新闻字符串(仅含标题)。
鏈接:https://pan.baidu.com/s/1Rs9oXoloKgwI-RgNS_GTQQ 提取碼:s9go
訓練模型腳本位置:PyCLUE/clue/classification/tnews/train.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/clue/classification/tnews/train.ipynb
提交文件腳本位置:PyCLUE/clue/classification/tnews/predict.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/clue/classification/tnews/predict.ipynb
該數據集共有1.7萬多條關於app應用描述的長文本標註數據,包含和日常生活相關的各類應用主題,共119個類別:"打車":0,"地圖導航":1,"免費WIFI":2,"租車":3,….,"女性":115,"經營":116,"收款":117,"其他":118(分別用0-118表示)。
数据量:训练集(12,133),验证集(2,599),测试集(2,600)
例子:
{"label": "110", "label_des": "社区超市", "sentence": "朴朴快送超市创立于2016年,专注于打造移动端30分钟即时配送一站式购物平台,商品品类包含水果、蔬菜、肉禽蛋奶、海鲜水产、粮油调味、酒水饮料、休闲食品、日用品、外卖等。朴朴公司希望能以全新的商业模式,更高效快捷的仓储配送模式,致力于成为更快、更好、更多、更省的在线零售平台,带给消费者更好的消费体验,同时推动中国食品安全进程,成为一家让社会尊敬的互联网公司。,朴朴一下,又好又快,1.配送时间提示更加清晰友好2.保障用户隐私的一些优化3.其他提高使用体验的调整4.修复了一些已知bug"}
每一条数据有三个属性,从前往后分别是 类别ID,类别名称,文本内容。
鏈接:https://pan.baidu.com/s/1EKtHXmgt1t038QTO9VKr3A 提取碼:u00v
訓練模型腳本位置:PyCLUE/clue/classification/iflytek/train.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/clue/classification/iflytek/train.ipynb
提交文件腳本位置:PyCLUE/clue/classification/iflytek/predict.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/clue/classification/iflytek/predict.ipynb
CMNLI數據由兩部分組成:XNLI和MNLI。數據來自於fiction,telephone,travel,government,slate等,對原始MNLI數據和XNLI數據進行了中英文轉化,保留原始訓練集,合併XNLI中的dev和MNLI中的matched作為CMNLI的dev,合併XNLI中的test和MNLI中的mismatched作為CMNLI的test,並打亂順序。該數據集可用於判斷給定的兩個句子之間屬於蘊涵、中立、矛盾關係。
数据量:train(391,782),matched(12,426),mismatched(13,880)
例子:
{"sentence1": "新的权利已经足够好了", "sentence2": "每个人都很喜欢最新的福利", "label": "neutral"}
每一条数据有三个属性,从前往后分别是 句子1,句子2,蕴含关系标签。其中label标签有三种:neutral,entailment,contradiction。
鏈接:https://pan.baidu.com/s/1mFT31cBs2G6e69As6H65dQ 提取碼:kigh
訓練模型腳本位置:PyCLUE/clue/sentence_pair/cmnli/train.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/clue/sentence_pair/cmnli/train.ipynb
提交文件腳本位置:PyCLUE/clue/sentence_pair/cmnli/predict.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/clue/sentence_pair/cmnli/predict.ipynb
診斷集,用於評估不同模型在9種語言學家總結的中文語言現像上的表現。
使用在CMNLI上訓練過的模型,直接預測在這個診斷集上的結果,提交格式和CMNLI一致,在排行榜詳情頁可以看到結果。 (注:該數據集包含CMNLI的訓練集與測試集)
鏈接:https://pan.baidu.com/s/1DYDUGO6xN_4xAT0Y4aNsiw 提取碼:u194
訓練模型腳本位置:PyCLUE/clue/sentence_pair/diagnostics/train.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/clue/sentence_pair/diagnostics/train.ipynb
提交文件腳本位置:PyCLUE/clue/sentence_pair/diagnostics/predict.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/clue/sentence_pair/diagnostics/predict.ipynb
補充中。
多分類任務,如文本分類、情感分類等,可接受單句輸入和句子對輸入兩種形式。
數據目錄下應至少包含train.txt,dev.txt和labels.txt文件,可增加test.txt文件。
保存形式參考:
單句輸入(對應評測腳本中的task_type = 'single' ):PyCLUE/examples/classification/single_data_templates/,https://github.com/CLUEBenchmark/PyCLUE/blob/master/examples/classification/single_data_templates
句子對輸入(對應評測腳本中的task_type = 'pairs' ):PyCLUE/examples/classification/pairs_data_templates/,https://github.com/CLUEBenchmark/PyCLUE/blob/master/examples/classification/pairs_data_templates
注:應採用t作為分隔符。
訓練模型腳本位置:PyCLUE/examples/classification/train.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/examples/classification/train.ipynb
預測使用腳本位置:PyCLUE/examples/classification/predict.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/examples/classification/predict.ipynb
句子對任務(孿生網絡),如相似句子對任務等。與多分類任務中的句子對輸入模型區別:多分類任務中的句子對任務採用類似Bert的拼接形式進行輸入,而該任務採用孿生網絡的形式進行輸入。
數據目錄下應至少包含train.txt,dev.txt和labels.txt文件,可增加test.txt文件。
保存形式參考:
輸入:PyCLUE/examples/sentence_pair/data_templates/,https://github.com/CLUEBenchmark/PyCLUE/blob/master/examples/sentence_pair/data_templates
注:應採用t作為分隔符。
訓練模型腳本位置:PyCLUE/examples/sentence_pair/train.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/examples/sentence_pair/train.ipynb
預測使用腳本位置:PyCLUE/examples/sentence_pair/predict.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/examples/sentence_pair/predict.ipynb
文本匹配任務(孿生網絡),如FAQ檢索、QQ匹配檢索等任務,使用孿生網絡生成輸入句子的embedding信息,使用hnswlib檢索最相近的若干句子。
數據目錄下應至少包含cache.txt,train.txt,dev.txt和labels.txt文件,可增加test.txt文件。
保存形式參考:
輸入:PyCLUE/examples/text_matching/data_templates/,https://github.com/CLUEBenchmark/PyCLUE/blob/master/examples/text_matching/data_templates
注:應採用t作為分隔符。
訓練模型腳本位置:PyCLUE/examples/text_matching/train.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/examples/text_matching/train.ipynb
預測使用腳本位置:PyCLUE/examples/text_matching/predict.ipynb
參考:https://github.com/CLUEBenchmark/PyCLUE/blob/master/examples/text_matching/predict.ipynb
模型文件包含10個最新的checkpoint模型文件和pb模型文件(10個checkpoint模型文件在測試集dev.txt上表現最佳的模型)。
訓練過程生成的指標文件(train_metrics.png),分別為accuracy,total_loss,batch_loss,precision,recall和f1指標。
若存在驗證文件test.txt且驗證文件各行以true_label作為起始,則打印最佳模型在驗證文件上的指標。
更新中。
正式地址:https://github.com/CLUEBenchmark/PyCLUE
調試地址:https://github.com/liushaoweihua/PyCLUE