# albert_zh
An Implementation of <a href="https://arxiv.org/pdf/1909.11942.pdf">A Lite Bert For Self-Supervised Learning Language Representations</a> with TensorFlow
ALBert is based on Bert, but with some improvements. It achieves state of the art performance on main benchmarks with 30% parameters less.
For albert_base_zh it only has ten percentage parameters compare of original bert model, and main accuracy is retained.
Different version of ALBERT pre-trained model for Chinese, including TensorFlow, PyTorch and Keras, is available now.
海量中文语料上预训练ALBERT模型:参数更少,效果更好。预训练小模型也能拿下13项NLP任务,ALBERT三大改造登顶GLUE基准
更多数据集、基线模型、不同任务上模型效果的详细对比,见<a href="https://github.com/chineseGLUE/chineseGLUE">中文任务基准测评chineseGLUE</a>
<img src="https://github.com/brightmart/albert_zh/blob/master/resources/albert_tiny_compare_s.jpg" width="90%" height="70%" />
模型下载 Download Pre-trained Models of Chinese
-----------------------------------------------
1、<a href="https://storage.googleapis.com/albert_zh/albert_tiny.zip">albert_tiny_zh</a>, 文件大小16M、参数为1.8M
训练和推理预测速度提升约10倍,精度基本保留,模型大小为bert的1/25;语义相似度数据集LCQMC测试集上达到85.4%,相比bert_base仅下降1.5个点。
lcqmc训练使用如下参数: --max_seq_length=128 --train_batch_size=64 --learning_rate=1e-4 --num_train_epochs=5
albert_tiny使用同样的大规模中文语料数据,层数仅为4层、hidden size等向量维度大幅减少。
【使用场景】任务相对比较简单一些或实时性要求高的任务,如语义相似度等句子对任务、分类任务;比较难的任务如阅读理解等,可以使用其他大模型。
2、<a href="https://storage.googleapis.com/albert_zh/albert_large_zh.zip">albert_large_zh</a>,参数量,层数24,文件大小为64M
参数量和模型大小为bert_base的六分之一;在口语化描述相似性数据集LCQMC的测试集上相比bert_base上升0.2个点
3、<a href="https://storage.googleapis.com/albert_zh/albert_base_zh_additional_36k_steps.zip">albert_base_zh(额外训练了1.5亿个实例即 36k steps * batch_size 4096)</a>; <a href="https://storage.googleapis.com/albert_zh/albert_base_zh.zip"> albert_base_zh(小模型体验版)</a>, 参数量12M, 层数12,大小为40M
参数量为bert_base的十分之一,模型大小也十分之一;在口语化描述相似性数据集LCQMC的测试集上相比bert_base下降约0.6~1个点;
相比未预训练,albert_base提升14个点
4、<a href="https://storage.googleapis.com/albert_zh/albert_xlarge_zh_177k.zip">albert_xlarge_zh_177k </a>;
<a href="https://storage.googleapis.com/albert_zh/albert_xlarge_zh_183k.zip">albert_xlarge_zh_183k(优先尝试)</a>参数量,层数24,文件大小为230M
参数量和模型大小为bert_base的二分之一;需要一张大的显卡;完整测试对比将后续添加;batch_size不能太小,否则可能影响精度
Updates
-----------------------------------------------
**\*\*\*\*\* 2019-10-15: albert_tiny_zh, 10 times fast than bert base for training and inference, accuracy remains \*\*\*\*\***
**\*\*\*\*\* 2019-10-07: more models of albert \*\*\*\*\***
add albert_xlarge_zh; albert_base_zh_additional_steps, training with more instances
**\*\*\*\*\* 2019-10-04: PyTorch and Keras versions of albert were supported \*\*\*\*\***
a.Convert to PyTorch version and do your tasks through <a href="https://github.com/lonePatient/albert_pytorch">albert_pytorch</a>
b.Load pre-trained model with keras using one line of codes through <a href="https://github.com/bojone/bert4keras">bert4keras</a>
c.Use albert with TensorFlow 2.0: Use or load pre-trained model with tf2.0 through <a href="https://github.com/kpe/bert-for-tf2">bert-for-tf2</a>
Releasing albert_xlarge on 6th Oct
**\*\*\*\*\* 2019-10-02: albert_large_zh,albert_base_zh \*\*\*\*\***
Relesed albert_base_zh with only 10% parameters of bert_base, a small model(40M) & training can be very fast.
Relased albert_large_zh with only 16% parameters of bert_base(64M)
**\*\*\*\*\* 2019-09-28: codes and test functions \*\*\*\*\***
Add codes and test functions for three main changes of albert from bert
ALBERT模型介绍 Introduction of ALBERT
-----------------------------------------------
ALBERT模型是BERT的改进版,与最近其他State of the art的模型不同的是,这次是预训练小模型,效果更好、参数更少。
它对BERT进行了三个改造 Three main changes of ALBert from Bert:
1)词嵌入向量参数的因式分解 Factorized embedding parameterization
O(V * H) to O(V * E + E * H)
如以ALBert_xxlarge为例,V=30000, H=4096, E=128
那么原先参数为V * H= 30000 * 4096 = 1.23亿个参数,现在则为V * E + E * H = 30000*128+128*4096 = 384万 + 52万 = 436万,
词嵌入相关的参数变化前是变换后的28倍。
2)跨层参数共享 Cross-Layer Parameter Sharing
参数共享能显著减少参数。共享可以分为全连接层、注意力层的参数共享;注意力层的参数对效果的减弱影响小一点。
3)段落连续性任务 Inter-sentence coherence loss.
使用段落连续性任务。正例,使用从一个文档中连续的两个文本段落;负例,使用从一个文档中连续的两个文本段落,但位置调换了。
避免使用原有的NSP任务,原有的任务包含隐含了预测主题这类过于简单的任务。
We maintain that inter-sentence modeling is an important aspect of language understanding, but we propose a loss
based primarily on coherence. That is, for ALBERT, we use a sentence-order prediction (SOP) loss, which avoids topic
prediction and instead focuses on modeling inter-sentence coherence. The SOP loss uses as positive examples the
same technique as BERT (two consecutive segments from the same document), and as negative examples the same two
consecutive segments but with their order swapped. This forces the model to learn finer-grained distinctions about
discourse-level coherence properties.
其他变化,还有 Other changes:
1)去掉了dropout Remove dropout to enlarge capacity of model.
最大的模型,训练了1百万步后,还是没有过拟合训练数据。说明模型的容量还可以更大,就移除了dropout
(dropout可以认为是随机的去掉网络中的一部分,同时使网络变小一些)
We also note that, even after training for 1M steps, our largest models still do not overfit to their training data.
As a result, we decide to remove dropout to further increase our model capacity.
其他型号的模型,在我们的实现中我们还是会保留原始的dropout的比例,防止模型对训练数据的过拟合。
2)为加快训练速度,使用LAMB做为优化器 Use LAMB as optimizer, to train with big batch size
使用了大的batch_size来训练(4096)。 LAMB优化器使得我们可以训练,特别大的批次batch_size,如高达6万。
3)使用n-gram(uni-gram,bi-gram, tri-gram)来做遮蔽语言模型 Use n-gram as make language model
即以不同的概率使用n-gram,uni-gram的概率最大,bi-gram其次,tri-gram概率最小。
本项目中目前使用的是在中文上做whole word mask,稍后会更新一下与n-gram mask的效果对比。n-gram从spanBERT中来。
训练语料/训练配置 Training Data & Configuration
-----------------------------------------------
30g中文语料,超过100亿汉字,包括多个百科、新闻、互动社区。
预训练序列长度sequence_length设置为512,批次batch_size为4096,训
没有合适的资源?快使用搜索试试~ 我知道了~
使用ALBERT预训练模型,用于识别文本中的时间,同时验证模型的预测耗时是否有显著提升.zip
共68个文件
py:22个
pyc:11个
jpg:9个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 70 浏览量
2024-01-07
14:34:20
上传
评论
收藏 16.77MB ZIP 举报
温馨提示
下载该项目,同时安装项目所依赖的Python模块: tensorflow, tornado; 运行run.py,启动模型训练、预测的HTTP服务; 在浏览器中输入: http://localhost:12306/model_train ,即可开始模型训练;或者直接运行train.py也可。模型训练的时间较长,需耐心等待,生成后的模型文件位于ckpt文件夹。
资源推荐
资源详情
资源评论
收起资源包目录
使用ALBERT预训练模型,用于识别文本中的时间,同时验证模型的预测耗时是否有显著提升.zip (68个子文件)
ALBERT_4_Time_Recognition-master
src
utils.py 9KB
loader.py 8KB
runServer.py 3KB
pictures
folder.png 176KB
results.png 250KB
conlleval 12KB
setup.py 3KB
data
time.dev 75KB
time.train 586KB
time.test 114KB
conlleval.py 10KB
predict.py 928B
model.py 12KB
server.py 3KB
run.py 90B
maps.pkl 106B
albert_zh
optimization_finetuning.py 6KB
resources
albert_performance.jpg 118KB
add_data_removing_dropout.jpg 96KB
create_pretraining_data_roberta.py 26KB
albert_large_zh_parameters.jpg 211KB
xlarge_loss.jpg 81KB
shell_scripts
create_pretrain_data_batch_webtext.sh 416B
albert_configuration.jpg 90KB
albert_tiny_compare_s_old.jpg 63KB
crmc2018_compare_s.jpg 62KB
state_of_the_art.jpg 118KB
albert_tiny_compare_s.jpg 47KB
data
news_zh_1.txt 32KB
bert_utils.py 4KB
run_pretraining.py 19KB
albert_config
albert_config_xlarge.json 563B
albert_config_xxlarge.json 564B
bert_config.json 518B
albert_config_tiny.json 562B
albert_config_large.json 563B
albert_config_base.json 563B
vocab.txt 107KB
modeling.py 49KB
optimization.py 12KB
test_changes.py 3KB
create_pretrain_data.sh 339B
tokenization.py 13KB
create_pretraining_data.py 43KB
__pycache__
bert_utils.cpython-36.pyc 4KB
tokenization.cpython-36.pyc 10KB
modeling.cpython-36.pyc 31KB
README.md 19KB
run_classifier.py 35KB
rnncell.py 9KB
albert_tiny
checkpoint 91B
albert_model.ckpt.meta 184KB
albert_config_tiny.json 562B
albert_model.ckpt.data-00000-of-00001 16.38MB
albert_model.ckpt.index 1KB
vocab.txt 107KB
train.py 7KB
__pycache__
runServer.cpython-36.pyc 3KB
rnncell.cpython-36.pyc 8KB
loader.cpython-36.pyc 7KB
model.cpython-36.pyc 9KB
data_utils.cpython-36.pyc 8KB
conlleval.cpython-36.pyc 7KB
train.cpython-36.pyc 5KB
utils.cpython-36.pyc 6KB
config_file 235B
data_utils.py 9KB
result
ner_predict.utf8 162KB
共 68 条
- 1
资源评论
博士僧小星
- 粉丝: 1774
- 资源: 5875
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功