Pytorch实施Google AI的2018年Bert,带有简单的注释
BERT 2018 BERT:深层双向变压器的预训练,用于语言理解纸网址:https://arxiv.org/abs/1810.04805
Google AI的BERT论文显示了各种NLP任务(新的17 NLP任务SOTA)的惊人结果,包括在Squad v1.1 QA任务上的人类F1分数胜过。本文证明,具有适当语言模型训练方法的先前语言模型的替代方法可以用作变压器(自我注意)的编码器。更重要的是,他们向我们表明,这种预训练的语言模型可以转移到任何NLP任务中,而无需进行特定任务模型体系结构。
这个惊人的结果将是NLP历史记录中的记录,我希望有关伯特的更多论文将很快发表。
此存储库是Bert的实施。代码非常简单,易于迅速理解。其中一些代码基于带注释的变压器
目前,该项目正在进行进度。并且该代码尚未验证。
pip install bert-pytorch
注意:您的语料库应在一行中准备两个句子( t)分隔符
Welcome to the t the junglen
I can stay t here all nightn
或令牌化语料库(象征性不在包装中)
Wel_ _come _to _the t _the _junglen
_I _can _stay t _here _all _nightn
bert-vocab -c data/corpus.small -o data/vocab.smallbert -c data/corpus.small -v data/vocab.small -o output/bert.model在本文中,作者展示了新的语言模型培训方法,它们是“掩盖语言模型”和“预测下一个句子”。
原始论文:3.3.1任务#1:蒙版LM
Input Sequence : The man went to [MASK] store with [MASK] dog
Target Sequence : the his
根据子规则下的下方,随机15%的输入令牌将更改为某些东西
[MASK]令牌[RANDOM]令牌(另一个单词)原始论文:3.3.2任务#2:下一个句子预测
Input : [CLS] the man went to the store [SEP] he bought a gallon of milk [SEP]
Label : Is Next
Input = [CLS] the man heading to the store [SEP] penguin [MASK] are flight ##less birds [SEP]
Label = NotNext
“这句话可以连续连接吗?”
了解两个文本句子之间的关系,这不是通过语言建模直接捕获的
Junseong Kim,Scatter Lab([email protected] / [email protected])
该项目按照许可证文件写的Apache 2.0许可证
版权所有2018 Junseong Kim,Scatter Lab,各自的BERT贡献者
版权(C)2018 Alexander Rush:带注释的Trasnformer