単方向制約を超えた双方向(Bidirectional)の言語モデルを構築するために、BERT では事前学習タスク/損失関数として masked language model (MLM) を採用した[8]。MLMでは部分マスクされた系列を入力としてマスク無し系列を予測し、マスク部に対応する出力に対して一致度を計算し学習する[9]。モデルはマスクされていない情報(周囲の文脈/context)のみからマスク部を予測する事前学習タスクを解くことになる[10]。
これらの自然言語理解タスクでBERTが最先端の性能を発揮できる理由は、まだよく分かっていない[15][16]。現在の研究は、注意深く選択された入力シーケンス[17][18]、プロービング分類器による内部ベクトル表現の分析[19][20]、およびアテンションウェイトによって表される関連性の結果として、BERT出力の背後にある関係を調査することに重点を置いている[15][16]。また、BERTモデルの高い性能は、それが双方向に学習されるという事実に帰する可能性もある。つまり、Transformerモデルアーキテクチャに基づくBERTが、その自己アテンション機構を使用して、訓練中にテキストの左側と右側から情報を学習するため、文脈を深く理解することができる。たとえば、fine という単語は、文脈によって2つの異なる意味を持つことがある。「I feel fine today, She has fine blond hair」(今日は良い気分だ。彼女は細いブロンドの髪をしている)。BERTは、対象となる単語 fine を囲む単語列を左右から見る。
BERTは元々、Googleの研究者Jacob Devlin、Ming-Wei Chang、Kenton Lee、Kristina Toutanovaによって発表された。この設計は、半教師ありシーケンス学習(英語版)[23]、生成的事前訓練、ELMo(英語版)[24]、ULMFit[25]などの文脈表現の事前訓練を起源とする。従来のモデルとは異なり、BERTは完全な双方向性を持つ教師なし言語表現であり、平文テキストコーパスのみを使用して事前訓練されている。word2vecやGloVe(英語版)のような文脈独立モデルは、語彙内の各単語ごとに単一の単語埋め込み表現を生成するのに対し、BERTは与えられた単語が出現するごとに文脈を考慮する。たとえば、「He is running a company」(彼は会社を経営している)と「He is running a marathon」(彼はマラソンをしている)の2つの文について、word2vecでは「running」のベクトル表現は同じであるのに対し、BERTでは文によって異なる文脈に応じた埋め込みを生成する。
^ abcdDevlin, Jacob; Chang, Ming-Wei; Lee, Kenton; Toutanova, Kristina (11 October 2018). "BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding". arXiv:1810.04805v2 [cs.CL]。
^"objective function during pre-training, where they use unidirectional language models to learn general language representations" Devlin (2018)
^"Critically ... the BERT Transformer uses bidirectional self-attention ... We note that in the literature the bidirectional Transformer is often referred to as a 'Transformer encoder' while the left-context-only version is referred to as a 'Transformer decoder' since it can be used for text generation."
^"the MLM objective enables the representation to fuse the left and the right context, which allows us to pretrain a deep bidirectional Transformer." Devlin (2018)
^"BERT alleviates the previously mentioned unidirectionality constraint by using a 'masked language model' (MLM) pre-training objective" Devlin (2018)
^"The masked language model randomly masks some of the tokens from the input, and the objective is to predict the original vocabulary id of the masked word" Devlin (2018)
^"predict the original vocabulary id of the masked word based only on its context." Devlin (2018)
^ abClark, Kevin; Khandelwal, Urvashi; Levy, Omer; Manning, Christopher D. (2019). “What Does BERT Look at? An Analysis of BERT's Attention”. Proceedings of the 2019 ACL Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP (Stroudsburg, PA, USA: Association for Computational Linguistics): 276–286. doi:10.18653/v1/w19-4828.
^Khandelwal, Urvashi; He, He; Qi, Peng; Jurafsky, Dan (2018). “Sharp Nearby, Fuzzy Far Away: How Neural Language Models Use Context”. Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers) (Stroudsburg, PA, USA: Association for Computational Linguistics): 284–294. arXiv:1805.04623. doi:10.18653/v1/p18-1027.
^Gulordava, Kristina; Bojanowski, Piotr; Grave, Edouard; Linzen, Tal; Baroni, Marco (2018). “Colorless Green Recurrent Networks Dream Hierarchically”. Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers) (Stroudsburg, PA, USA: Association for Computational Linguistics): 1195–1205. arXiv:1803.11138. doi:10.18653/v1/n18-1108.
^Giulianelli, Mario; Harding, Jack; Mohnert, Florian; Hupkes, Dieuwke; Zuidema, Willem (2018). “Under the Hood: Using Diagnostic Classifiers to Investigate and Improve how Language Models Track Agreement Information”. Proceedings of the 2018 EMNLP Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP (Stroudsburg, PA, USA: Association for Computational Linguistics): 240–248. arXiv:1808.08079. doi:10.18653/v1/w18-5426.
^Zhang, Kelly; Bowman, Samuel (2018). “Language Modeling Teaches You More than Translation Does: Lessons Learned Through Auxiliary Syntactic Task Analysis”. Proceedings of the 2018 EMNLP Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP (Stroudsburg, PA, USA: Association for Computational Linguistics): 359–361. doi:10.18653/v1/w18-5448.
^Patel, Ajay; Li, Bryan; Mohammad Sadegh Rasooli; Constant, Noah; Raffel, Colin; Callison-Burch, Chris (2022). "Bidirectional Language Models Are Also Few-shot Learners". arXiv:2209.14500 [cs.LG]。