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