不同预训练模型的总结对比

待更新

Albert

A Lite Bert For Self-Supervised Learning Language Representations 

https://github.com/brightmart/albert_zh

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. 

其他变化:

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,训练产生了3.5亿个训练数据(instance);每一个模型默认会训练125k步,albert_xxlarge将训练更久。

扫描二维码关注公众号,回复: 10120332 查看本文章

作为比较,roberta_zh预训练产生了2.5亿个训练数据、序列长度为256。由于albert_zh预训练生成的训练数据更多、使用的序列长度更长,

我们预计albert_zh会有比roberta_zh更好的性能表现,并且能更好处理较长的文本。

训练使用TPU v3 Pod,我们使用的是v3-256,它包含32个v3-8。每个v3-8机器,含有128G的显存。

猜你喜欢

转载自www.cnblogs.com/shona/p/12558870.html
今日推荐