# 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实现albert+BiLstm+CRF的python源码.zip 基于轻量级albert实现albert+BiLstm+CRF的python源码.zip基于轻量级albert实现albert+BiLstm+CRF的python源码.zip基于轻量级albert实现albert+BiLstm+CRF的python源码.zip基于轻量级albert实现albert+BiLstm+CRF的python源码.zip基于轻量级albert实现albert+BiLstm+CRF的python源码.zip基于轻量级albert实现albert+BiLstm+CRF的python源码.zip基于轻量级albert实现albert+BiLstm+CRF的python源码.zip基于轻量级albert实现albert+BiLstm+CRF的python源码.zip基于轻量级albert实现albert+BiLstm+CRF的python源码.zip基于轻量级albert实现albert+BiLstm+CRF的python源码.zip基于轻量级albert实现albert+BiL
资源推荐
资源详情
资源评论
收起资源包目录
基于轻量级albert实现albert+BiLstm+CRF的python源码.zip (52个子文件)
albert_ner-master
utils.py 9KB
loader.py 9KB
runServer.py 3KB
conlleval 12KB
data
__init__.py 110B
example.dev 686KB
example.test 1.34MB
example.train 5.99MB
conlleval.py 10KB
predict.py 1020B
model.py 12KB
server.py 3KB
run.py 177B
requirements.txt 91B
maps.pkl 176B
.gitignore 1KB
albert_zh
__init__.py 111B
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
bert_utils.py 4KB
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 54KB
optimization.py 12KB
tokenization.py 14KB
README.md 19KB
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 8KB
config_file 235B
README.md 252B
data_utils.py 9KB
result
ner_predict.utf8 1.82MB
共 52 条
- 1
资源评论
- m0_574699052024-03-12发现一个宝藏资源,赶紧冲冲冲!支持大佬~
- KPのTiara2024-04-03资源有很好的参考价值,总算找到了自己需要的资源啦。
盈梓的博客
- 粉丝: 6968
- 资源: 1405
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于tensorflow多特征融合的微表情识别python源码.zip
- 基于yolov8实现人脸检测的python源码+运行说明.zip
- Micron Memory DDR3 SDRAM 全系列AD集成库(原理图库+PCB封装库).IntLib
- 基于tensorflow多特征融合的微表情识别python源码+详细使用说明.zip
- TensorRT部署DETR项目工程C++源码.zip
- Word文字处理软件练习题及答案.doc
- Word普通信纸信纸格式可打印.doc
- TensorRT部署DETR项目工程python源码.zip
- WPSexcel如何做柏拉图.doc
- 基于protel99se设计的PCB封装库PROTEL PCB封装库器件库常用芯片接插件电子元器件封装(1260个).lib
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功