• Stars
    star
    795
  • Rank 56,854 (Top 2 %)
  • Language
    Python
  • Created over 4 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

高质量中文预训练模型集合:最先进大模型、最快小模型、相似度专门模型

CLUE Pretrained Models

高质量中文预训练模型集合:

最先进的大模型、速度最快和效果好的小模型、面向相似性或句子对任务优化的专门模型。

更多细节请参考我们的技术报告 https://arxiv.org/pdf/2003.01355

./pics/corpus.png

We introduce the Chinese corpus from CLUE organization, CLUECorpus2020, a large-scale corpus that can be used directly for self-supervised learning such as pretraining of a language model, or language generation. It has 100G raw corpus with 35 billion Chinese characters, which is retrieved from Common Crawl.

To better understand this corpus, we conduct language understanding experiments on both small and large scale, and results show that the models trained on this corpus can achieve excellent performance on Chinese. We release a new Chinese vocabulary(vocab clue) with a size of 8K, which is only one-third of the vocabulary size used in Chinese Bert released by Google. It saves computational cost and memory while works as good as original vocabulary. We also release both large and tiny versions of the pre-trained model on this corpus. The former achieves the state-of-the-art result, and the latter retains most precision while accelerating training and prediction speed for eight times compared to Bert-base.

介绍

本项目是与CLUECorpus2020的姊妹项目,通过使用前者的预训练语料库和新版的词汇表,来做模型的预训练。详细报告见,技术报告

项目亮点:

1.提供了大模型、小模型和语义相似度模型。大模型取得与当前中文上效果最佳的模型一致的效果,在一些任务上效果更好。

2.小模型速度比Bert-base提升8倍左右,与albert_tiny速度一致,但效果更佳;

3.语义相似度模型,用于处理语义相似度或句子对问题,有很大概率比直接用预训练模型效果要好;

4.一期支持6个分类和句子对任务,会支持CLUE benchmark所有任务;

模型下载

模型简称 参数量 存储大小 语料 词汇表 直接下载
RoBERTa-tiny-clue
超小模型
7.5M 28.3M CLUECorpus2020 CLUEVocab TensorFlow
PyTorch (提取码:8qvb)
RoBERTa-tiny-pair
超小句子对模型
7.5M 28.3M CLUECorpus2020 CLUEVocab TensorFlow
PyTorch (提取码:8qvb)
RoBERTa-tiny3L768-clue
小模型
38M 110M CLUECorpus2020 CLUEVocab TensorFlow
RoBERTa-tiny3L312-clue
小模型
<7.5M 24M CLUECorpus2020 CLUEVocab TensorFlow
RoBERTa-large-clue
大模型
290M 1.20G CLUECorpus2020 CLUEVocab TensorFlow
PyTorch (提取码:8qvb)
RoBERTa-large-pair
大句子对模型
290M 1.20G CLUECorpus2020 CLUEVocab TensorFlow
PyTorch (提取码:8qvb)

快速加载

依托于Huggingface-Transformers 2.5.1,可轻松调用以上模型。

tokenizer = BertTokenizer.from_pretrained("MODEL_NAME")
model = BertModel.from_pretrained("MODEL_NAME")

其中MODEL_NAME对应列表如下:

模型名 MODEL_NAME
RoBERTa-tiny-clue clue/roberta_chinese_clue_tiny
RoBERTa-tiny-pair clue/roberta_chinese_pair_tiny
RoBERTa-tiny3L768-clue clue/roberta_chinese_3L768_clue_tiny
RoBERTa-tiny3L312-clue clue/roberta_chinese_3L312_clue_tiny
RoBERTa-large-clue clue/roberta_chinese_clue_large
RoBERTa-large-pair clue/roberta_chinese_pair_large

中文任务基准测评.分类与句子对任务

AFQMC:语义相似度任务
TNEWS':中文新闻(短文本)分类。包含15个类别的新闻,包括旅游,教育,金融,军事等。
IFLYTEK':关于app应用描述的长文本数据,包含和日常生活相关的各类应用主题,共119个类别,如:打车、地图导航、免费WIFI、经营等
CMNLI:自然语言推理任务,判断给定的两个句子之间的关系,如蕴涵、中立、矛盾。

效果对比-小模型

模型 Score 参数 AFQMC TNEWS' IFLYTEK' CMNLI
BERT-base (baseline) 67.57% 108M 73.70% 56.58% 60.29% 79.69%
ALBERT-tiny 60.65% 4M 69.92% 53.35% 48.71% 70.61%
RoBERTa-tiny-clue 63.60% 7.5M 69.52% 54.57% 57.31% 73.10%

效果对比-大模型

模型 Score 参数 AFQMC TNEWS' IFLYTEK' CMNLI
BERT-base (baseline) 67.57% 108M 73.70% 56.58% 60.29% 79.69%
RoBERTa-wwm-large 69.46% 325M 74.44% 58.41% 62.77% 82.20%
RoBERTa-large-clue 69.68% 290M 74.41% 58.38% 63.58% 82.36%

效果对比-句子对模型

模型 Score 参数 AFQMC
RoBERTa-tiny-clue 69.52% 7.5M 69.52%
RoBERTa-tiny-pair 69.93%(↑0.41) 7.5M 69.93 %
RoBERTa-large-clue 74.00% 92M 74.00%
RoBERTa-large-pair 74.41%(↑0.41) 92M 74.41%

速度对比

模型 词汇表 词汇表大小 参数量 训练设备 训练速度
BERT-base google_vocab 21128 102M TPU V3-8 1k steps/404s
BERT-base clue_vocab 8021(↓62.04%) 92M(↓9.80%) TPU V3-8 1k steps/350s(↑15.43%)
RoBERTa-tiny-clue clue_vocab 8021(↓62.05%) 7.5M(↓92.6%) TPU V3-8 1k steps/50s(↑708.0%)

小模型使用建议

1.学习率:稍微大一点的学习率,如{1e4, 4e-4 1e-5} 默认:1e-4

2.训练轮次:5-8。 使用验证集上效果最好的模型,用于测试集上测试或在线预测

3.相似性或句子对任务,优先使用专门的RoBERTa-xxx-pair模型,如RoBERTa-tiny-pair(小号)或 RoBERTa-large-pair(大号)

模型结构

为方便调用,所有模型都保持和Bert-base一致的结构,并可以直接使用Bert加载。
RoBERTa-xxx-clue.zip
    |- bert_model.ckpt      # 模型权重
    |- bert_model.meta      # 模型meta信息
    |- bert_model.index     # 模型index信息
    |- bert_config.json     # 模型参数
    |- vocab.txt            # 词表

一键运行.基线模型与代码 Baseline with codes

使用方式:
1、克隆项目 
   git clone https://github.com/CLUEbenchmark/CLUEPretrainedModels.git
2、进入到相应的目录
   分类任务  
       例如:
       cd CLUEPretrainedModels/baselines/models/bert
       ### cd CLUEPretrainedModels/baselines/models_pytorch/classifier_pytorch
3、运行一键运行脚本(GPU方式): 会自动下载模型和所有任务数据并开始运行。
   bash run_classifier_clue.sh
   执行该一键运行脚本将会自动下载所有任务数据,并为所有任务找到最优模型,然后测试得到提交结果
4、tpu使用方式(可选)  
    cd CLUEPretrainedModels/baselines/models/bert/tpu  
    sh run_classifier_tnews.sh即可测试tnews任务(注意更换里面的gs路径和tpu ip)。数据和模型会自动下载和上传。
    
    cd CLUEPretrainedModels/baselines/models/roberta/tpu  
    sh run_classifier_tiny.sh即可运行所有分类任务(注意更换里面的路径,模型地址和tpu ip)  

预训练

小文件预训练示例 需要下载一个模型文件,并将模型文件的地址修改到以下的bash文件中。最后训练结果会保存在当前目录下的test文件夹中.

bash create_sample_zh.sh
bash run_sample.sh

结果在MLM上应该是1.0的 acc。(NSP任务没有训练)

问题反馈和支持

如有问题请提交issue,加入讨论群(QQ:836811304)

或发送邮件[email protected]

Computation Power

Research supported with Cloud TPUs from Google's TensorFlow Research Cloud (TFRC)

TODO LIST:

  1. PyTorch版本
  2. 在线预测代码
  3. 一键运行6大分类任务
  4. 大模型去掉无效参数

Reference:

  1. 关于使用的任务的介绍:AFQMC(句子对), TNEWS'(情感分析), IFLYTEK'(100+类别的分类), CMNLI(自然语言推理)

More Repositories

1

CLUEDatasetSearch

搜索所有中文NLP数据集,附常用英文NLP数据集
Python
4,023
star
2

CLUE

中文语言理解测评基准 Chinese Language Understanding Evaluation Benchmark: datasets, baselines, pre-trained models, corpus and leaderboard
Python
3,934
star
3

SuperCLUE

SuperCLUE: 中文通用大模型综合性基准 | A Benchmark for Foundation Models in Chinese
2,908
star
4

CLUENER2020

CLUENER2020 中文细粒度命名实体识别 Fine Grained Named Entity Recognition
Python
1,440
star
5

CLUECorpus2020

Large-scale Pre-training Corpus for Chinese 100G 中文预训练语料
898
star
6

FewCLUE

FewCLUE 小样本学习测评基准,中文版
Python
489
star
7

pCLUE

pCLUE: 1000000+多任务提示学习数据集
Jupyter Notebook
455
star
8

KgCLUE

KgCLUE: 大规模中文开源知识图谱问答
Python
422
star
9

SimCLUE

3000000+语义理解与匹配数据集。可用于无监督对比学习、半监督学习等构建中文领域效果最好的预训练模型
Python
271
star
10

CLGE

Chinese Language Generation Evaluation 中文生成任务基准测评
Python
246
star
11

DataCLUE

DataCLUE: 数据为中心的NLP基准和工具包
Python
144
star
12

ELECTRA

中文 预训练 ELECTRA 模型: 基于对抗学习 pretrain Chinese Model
140
star
13

OCNLI

OCNLI: 中文原版自然语言推理任务
Python
139
star
14

SuperCLUElyb

SuperCLUE琅琊榜:中文通用大模型匿名对战评价基准
139
star
15

PyCLUE

Python toolkit for Chinese Language Understanding(CLUE) Evaluation benchmark
Python
128
star
16

SuperCLUE-Llama2-Chinese

Llama2开源模型中文版-全方位测评,基于SuperCLUE的OPEN基准 | Llama2 Chinese evaluation with SuperCLUE
125
star
17

SuperCLUE-Safety

SC-Safety: 中文大模型多轮对抗安全基准
93
star
18

DistilBert

DistilBERT for Chinese 海量中文预训练蒸馏bert模型
89
star
19

SuperCLUE-RAG

中文原生检索增强生成测评基准
79
star
20

SuperCLUE-Agent

SuperCLUE-Agent: 基于中文原生任务的Agent智能体核心能力测评基准
76
star
21

SuperCLUE-Open

中文通用大模型开放域多轮测评基准 | An Open Domain Benchmark for Foundation Models in Chinese
74
star
22

QBQTC

QBQTC: 大规模搜索匹配数据集
Python
67
star
23

CLUEWSC2020

CLUEWSC2020: WSC Winograd模式挑战中文版,中文指代消解任务
65
star
24

MobileQA

离线端阅读理解应用 QA for mobile, Android & iPhone
Python
60
star
25

modelfun

一站式自动化开源标注平台
Java
59
star
26

LightLM

高性能小模型测评 Shared Tasks in NLPCC 2020. Task 1 - Light Pre-Training Chinese Language Model for NLP Task
Python
57
star
27

ZeroCLUE

零样本学习测评基准,中文版
Python
54
star
28

SuperCLUE-Math6

SuperCLUE-Math6:新一代中文原生多轮多步数学推理数据集的探索之旅
Python
33
star
29

KgCLUEbench

benchmark of KgCLUE, with different models and methods
Python
27
star
30

SuperCLUE-Auto

汽车行业中文大模型测评基准,基于多轮开放式问题的细粒度评测
21
star
31

SuperCLUE-Role

SuperCLUE-Role中文原生角色扮演测评基准
18
star
32

SuperCLUE-Llama3-Chinese

Llama3开源模型中文版-全方位测评,基于SuperCLUE基准 | Llama3 Chinese Evaluation with SuperCLUE
17
star
33

LGEB

LGEB: Benchmark of Language Generation Evaluation
Python
16
star
34

SuperCLUE-Video

中文原生多层次文生视频测评基准
15
star
35

SuperCLUEgkzw

SuperCLUE高考作文机器自动阅卷系统
13
star
36

SuperCLUE-Industry

中文原生工业测评基准
11
star
37

KGQA

Knowledge Graph based Question Answering benchmark.
10
star
38

SuperCLUE-Code3

中文原生等级化代码能力测试基准
9
star
39

chatbotzh

This is a Chatbot designed for Chinese developers base on RASA. You could deploy your bot quickly with the help of this things.
Python
8
star
40

CLUEmotionAnalysis2020

CLUE Emotion Analysis Dataset 细粒度情感分析数据集
Python
7
star
41

SuperCLUE-Fin

中文金融大模型测评基准,六大类二十五任务、等级化评价,国内模型获得A级
7
star
42

SuperCLUE-Image

中文原生文生图测评基准
6
star
43

SuperCLUE-ICabin

汽车智能座舱大模型测评基准
5
star
44

SuperCLUE-Long

中文原生长文本测评基准
5
star