{
  "id": "607baf97b999",
  "url": "https://lilianweng.github.io/posts/2019-01-31-lm/",
  "source_excel_row": 1602,
  "source_url": "https://lilianweng.github.io/posts/2019-01-31-lm/",
  "is_paid_flag": "",
  "images": [
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/elmo-and-bert.png",
      "bytes": 929637,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-5e717a51b0a5329fa972.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/elmo-and-bert.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/nmt-recap.png",
      "bytes": 268193,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-bcfb5637b30440671005.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/nmt-recap.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/CoVe.png",
      "bytes": 183059,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-7365015a0a10cc69acd8.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/CoVe.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/ELMo-biLSTM.png",
      "bytes": 473871,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-9d994d94aa3f953655fe.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/ELMo-biLSTM.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/CVT.png",
      "bytes": 244780,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-4b7c5a8a25f1aef4e33a.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/CVT.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/CVT-example.png",
      "bytes": 269806,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-7ad146452781a398f651.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/CVT-example.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/ULMFiT.png",
      "bytes": 1588495,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-2208e66f87d45609e14a.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/ULMFiT.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/OpenAI-GPT-transformer-decoder.png",
      "bytes": 516917,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-e495e282eb1d3f3e9144.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/OpenAI-GPT-transformer-decoder.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/GPT-classification.png",
      "bytes": 51037,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-8a0f9752f056eb917bbf.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/GPT-classification.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/GPT-downstream-tasks.png",
      "bytes": 272909,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-b96d2353529c40b14aef.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/GPT-downstream-tasks.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/transformer-encoder-2.png",
      "bytes": 100122,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-e2ee524fbebc06b6e190.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/transformer-encoder-2.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/language-model-comparison.png",
      "bytes": 227696,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-5d14984c36bf66c73897.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/language-model-comparison.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/BERT-input-embedding.png",
      "bytes": 87898,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-08c8fd1e0c80108aa470.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/BERT-input-embedding.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/BERT-downstream-tasks.png",
      "bytes": 415583,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-c58896fcdd52fc06c2a0.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/BERT-downstream-tasks.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/T5.png",
      "bytes": 253294,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-7970b3c999effb6f02b6.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/T5.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/GPT3-train-data.png",
      "bytes": 88113,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-85fc2d78dbd4ba853f15.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/GPT3-train-data.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/GPT3-eval.png",
      "bytes": 282592,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-dd77dfe447995839038a.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/GPT3-eval.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/XLNet-two-stream-attention.png",
      "bytes": 384564,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-3be7c9763f11993ba7a6.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/XLNet-two-stream-attention.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/XLNet-glue.png",
      "bytes": 76634,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-e529afcc9a2bd0fb2fae.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/XLNet-glue.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/BART.png",
      "bytes": 180008,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-8045a59ac9bcdcc697fc.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/BART.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/BART-perf.png",
      "bytes": 258219,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-c0273e122159d4c19386.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/BART-perf.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/ELECTRA-overview.png",
      "bytes": 88004,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-8bf9b1628b286eb863de.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/ELECTRA-overview.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://lilianweng.github.io/posts/2019-01-31-lm/ELECTRA-perf.png",
      "bytes": 138525,
      "reused": true,
      "local_path": "attachments/607baf97b999/images/body-76b71f8459361bdc98c5.png",
      "src": "https://lilianweng.github.io/posts/2019-01-31-lm/ELECTRA-perf.png",
      "alt": "",
      "downloaded": true
    }
  ],
  "videos": [
    {
      "url": "https://www.youtube.com/watch?v=l5einDQ-Ttc",
      "src": "https://www.youtube.com/watch?v=l5einDQ-Ttc",
      "status": "ok",
      "kind": "single_video",
      "local_path": "attachments/607baf97b999/videos/repair-l5einDQ-Ttc.mp4",
      "bytes": 19398754,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "139.221000",
      "reused": false
    }
  ],
  "body_markdown": "[Updated on 2019-02-14: add\nULMFiT\nand\nGPT-2\n.]\n[Updated on 2020-02-29: add\nALBERT\n.]\n[Updated on 2020-10-25: add\nRoBERTa\n.]\n[Updated on 2020-12-13: add\nT5\n.]\n[Updated on 2020-12-30: add\nGPT-3\n.]\n[Updated on 2021-11-13: add\nXLNet\n,\nBART\nand\nELECTRA\n; Also updated the\nSummary\nsection.]\nI guess they are Elmo & Bert? (Image source:\nhere\n)\nWe have seen amazing progress in NLP in 2018. Large-scale pre-trained language modes like\nOpenAI GPT\nand\nBERT\nhave achieved great performance on a variety of language tasks using generic model architectures. The idea is similar to how ImageNet classification pre-training helps many vision tasks (*). Even better than vision classification pre-training, this simple and powerful approach in NLP does not require labeled data for pre-training, allowing us to experiment with increased training scale, up to our very limit.\n(*) He et al. (2018)\nfound\nthat pre-training might not be necessary for image segmentation task.\nIn my previous NLP\npost on word embedding\n, the introduced embeddings are not context-specific — they are learned based on word concurrency but not sequential context. So in two sentences, “\nI am eating an apple\n” and “\nI have an Apple phone\n”, two “apple” words refer to very different things but they would still share the same word embedding vector.\nDespite this, early adoption of word embeddings in problem-solving is to use them as additional features for an existing task-specific model and in a way the improvement is bounded.\nIn this post, we will discuss how various approaches were proposed to make embeddings dependent on context, and to make them easier and cheaper to be applied to downstream tasks in general form.\nCoVe\n#\nCoVe\n(\nMcCann et al. 2017\n), short for\nContextual Word Vectors\n, is a type of word embeddings learned by an encoder in an\nattentional seq-to-seq\nmachine translation model.\nDifferent from traditional word embeddings introduced\nhere\n, CoVe word representations are functions of the entire input sentence.\nNMT Recap\n#\nHere the Neural Machine Translation (\nNMT\n) model is composed of a standard, two-layer, bidirectional LSTM encoder and an attentional two-layer unidirectional LSTM decoder. It is pre-trained on the English-German translation task. The encoder learns and optimizes the embedding vectors of English words in order to translate them to German. With the intuition that the encoder should capture high-level semantic and syntactic meanings before transforming words into another language, the encoder output is used to provide contextualized word embeddings for various downstream language tasks.\nThe NMT base model used in CoVe.\nA sequence of $n$ words in source language (English): $x = [x_1, \\dots, x_n]$.\nA sequence of $m$ words in target language (German): $y = [y_1, \\dots, y_m]$.\nThe\nGloVe\nvectors of source words: $\\text{GloVe}(x)$.\nRandomly initialized embedding vectors of target words: $z = [z_1, \\dots, z_m]$.\nThe biLSTM encoder outputs a sequence of hidden states: $h = [h_1, \\dots, h_n] = \\text{biLSTM}(\\text{GloVe}(x))$ and $h_t = [\\overrightarrow{h}_t; \\overleftarrow{h}_t]$ where the forward LSTM computes $\\overrightarrow{h}_t = \\text{LSTM}(x_t, \\overrightarrow{h}_{t-1})$ and the backward computation gives us $\\overleftarrow{h}_t = \\text{LSTM}(x_t, \\overleftarrow{h}_{t-1})$.\nThe attentional decoder outputs a distribution over words: $p(y_t \\mid H, y_1, \\dots, y_{t-1})$ where $H$ is a stack of hidden states $\\{h\\}$ along the time dimension:\n$$\n\\begin{aligned}\n\\text{decoder hidden state: } s_t &= \\text{LSTM}([z_{t-1}; \\tilde{h}_{t-1}], s_{t-1}) \\\\\n\\text{attention weights: } \\alpha_t &= \\text{softmax}(H(W_1 s_t + b_1)) \\\\\n\\text{context-adjusted hidden state: } \\tilde{h}_t &= \\tanh(W_2[H^\\top\\alpha_t;s_t] + b_2) \\\\\n\\text{decoder output: } p(y_t\\mid H, y_1, \\dots, y_{t-1}) &= \\text{softmax}(W_\\text{out} \\tilde{h}_t + b_\\text{out})\n\\end{aligned}\n$$\nUse CoVe in Downstream Tasks\n#\nThe hidden states of NMT encoder are defined as\ncontext vectors\nfor other language tasks:\n$$\n\\text{CoVe}(x) = \\text{biLSTM}(\\text{GloVe}(x))\n$$\nThe paper proposed to use the concatenation of GloVe and CoVe for question-answering and classification tasks. GloVe learns from the ratios of global word co-occurrences, so it has no sentence context, while CoVe is generated by processing text sequences is able to capture the contextual information.\n$$\nv = [\\text{GloVe}(x); \\text{CoVe}(x)]\n$$\nGiven a downstream task, we first generate the concatenation of GloVe + CoVe vectors of input words and then feed them into the task-specific models as additional features.\nThe CoVe embeddings are generated by an encoder trained for machine translation task. The encoder can be plugged into any downstream task-specific model. (Image source:\noriginal paper\n)\nSummary\n: The limitation of CoVe is obvious: (1) pre-training is bounded by available datasets on the supervised translation task; (2) the contribution of CoVe to the final performance is constrained by the task-specific model architecture.\nIn the following sections, we will see that ELMo overcomes issue (1) by unsupervised pre-training and OpenAI GPT & BERT further overcome both problems by unsupervised pre-training + using generative model architecture for different downstream tasks.\nELMo\n#\nELMo\n, short for\nEmbeddings from Language Model\n(\nPeters, et al, 2018\n) learns contextualized word representation by pre-training a language model in an\nunsupervised\nway.\nBidirectional Language Model\n#\nThe bidirectional Language Model (\nbiLM\n) is the foundation for ELMo. While the input is a sequence of $n$ tokens, $(x_1, \\dots, x_n)$, the language model learns to predict the probability of next token given the history.\nIn the forward pass, the history contains words before the target token,\n$$\np(x_1, \\dots, x_n) = \\prod_{i=1}^n p(x_i \\mid x_1, \\dots, x_{i-1})\n$$\nIn the backward pass, the history contains words after the target token,\n$$\np(x_1, \\dots, x_n) = \\prod_{i=1}^n p(x_i \\mid x_{i+1}, \\dots, x_n)\n$$\nThe predictions in both directions are modeled by multi-layer LSTMs with hidden states $\\overrightarrow{\\mathbf{h}}_{i,\\ell}$ and $\\overleftarrow{\\mathbf{h}}_{i,\\ell}$ for input token $x_i$ at the layer level $\\ell=1,\\dots,L$.\nThe final layer’s hidden state $\\mathbf{h}_{i,L} = [\\overrightarrow{\\mathbf{h}}_{i,L}; \\overleftarrow{\\mathbf{h}}_{i,L}]$ is used to output the probabilities over tokens after softmax normalization. They share the embedding layer and the softmax layer, parameterized by $\\Theta_e$ and $\\Theta_s$ respectively.\nThe biLSTM base model of ELMo. (Image source: recreated based on the figure in [\"Neural Networks, Types, and Functional Programming\"](http://colah.github.io/posts/2015-09-NN-Types-FP/) by Christopher Olah.)\nThe model is trained to minimize the negative log likelihood (= maximize the log likelihood for true words) in both directions:\n$$\n\\begin{aligned}\n\\mathcal{L} = - \\sum_{i=1}^n \\Big( \n\\log p(x_i \\mid x_1, \\dots, x_{i-1}; \\Theta_e, \\overrightarrow{\\Theta}_\\text{LSTM}, \\Theta_s) + \\\\\n\\log p(x_i \\mid x_{i+1}, \\dots, x_n; \\Theta_e, \\overleftarrow{\\Theta}_\\text{LSTM}, \\Theta_s) \\Big)\n\\end{aligned}\n$$\nELMo Representations\n#\nOn top of a $L$-layer biLM, ELMo stacks all the hidden states across layers together by learning a task-specific linear combination. The hidden state representation for the token $x_i$ contains $2L+1$ vectors:\n$$\nR_i = \\{ \\mathbf{h}_{i,\\ell} \\mid \\ell = 0, \\dots, L \\}\n$$\nwhere $\\mathbf{h}_{0, \\ell}$ is the embedding layer output and $\\mathbf{h}_{i, \\ell} = [\\overrightarrow{\\mathbf{h}}_{i,\\ell}; \\overleftarrow{\\mathbf{h}}_{i,\\ell}]$.\nThe weights, $\\mathbf{s}^\\text{task}$, in the linear combination are learned for each end task and normalized by softmax. The scaling factor $\\gamma^\\text{task}$ is used to correct the misalignment between the distribution of biLM hidden states and the distribution of task specific representations.\n$$\nv_i = f(R_i; \\Theta^\\text{task}) = \\gamma^\\text{task} \\sum_{\\ell=0}^L s^\\text{task}_i \\mathbf{h}_{i,\\ell}\n$$\nTo evaluate what kind of information is captured by hidden states across different layers, ELMo is applied on semantic-intensive and syntax-intensive tasks respectively using representations in different layers of biLM:\nSemantic task\n: The\nword sense disambiguation (WSD)\ntask emphasizes the meaning of a word given a context. The biLM top layer is better at this task than the first layer.\nSyntax task\n: The\npart-of-speech\n(POS) tagging\ntask aims to infer the grammatical role of a word in one sentence. A higher accuracy can be achieved by using the biLM first layer than the top layer.\nThe comparison study indicates that syntactic information is better represented at lower layers while semantic information is captured by higher layers. Because different layers tend to carry different type of information,\nstacking them together helps\n.\nUse ELMo in Downstream Tasks\n#\nSimilar to how\nCoVe\ncan help different downstream tasks, ELMo embedding vectors are included in the input or lower levels of task-specific models. Moreover, for some tasks (i.e.,\nSNLI\nand\nSQuAD\n, but not\nSRL\n), adding them into the output level helps too.\nThe improvements brought up by ELMo are largest for tasks with a small supervised dataset. With ELMo, we can also achieve similar performance with much less labeled data.\nSummary\n: The language model pre-training is unsupervised and theoretically the pre-training can be scaled up as much as possible since the unlabeled text corpora are abundant. However, it still has the dependency on task-customized models and thus the improvement is only incremental, while searching for a good model architecture for every task remains non-trivial.\nCross-View Training\n#\nIn ELMo the unsupervised pre-training and task-specific learning happen for two independent models in two separate training stages.\nCross-View Training\n(abbr.\nCVT\n;\nClark et al., 2018\n) combines them into one unified semi-supervised learning procedure where the representation of a biLSTM encoder is improved by both supervised learning with labeled data and unsupervised learning with unlabeled data on auxiliary tasks.\nModel Architecture\n#\nThe model consists of a two-layer bidirectional LSTM encoder and a primary prediction module. During training, the model is fed with labeled and unlabeled data batches alternatively.\nOn\nlabeled examples\n, all the model parameters are updated by standard supervised learning. The loss is the standard cross entropy.\nOn\nunlabeled examples\n, the primary prediction module still can produce a “soft” target, even though we cannot know exactly how accurate they are. In a couple of auxiliary tasks, the predictor only sees and processes a restricted view of the input, such as only using encoder hidden state representation in one direction. The auxiliary task outputs are expected to match the primary prediction target for a full view of input.\nIn this way, the encoder is forced to distill the knowledge of the full context into partial representation. At this stage, the biLSTM encoder is backpropagated but the primary prediction module is\nfixed\n. The loss is to minimize the distance between auxiliary and primary predictions.\nThe overview of semi-supervised language model cross-view training. (Image source:\noriginal paper\n)\nMulti-Task Learning\n#\nWhen training for multiple tasks simultaneously, CVT adds several extra primary prediction models for additional tasks. They all share the same sentence representation encoder.\nDuring supervised training, once one task is randomly selected, parameters in its corresponding predictor and the representation encoder are updated.\nWith unlabeled data samples, the encoder is optimized jointly across all the tasks by minimizing the differences between auxiliary outputs and primary prediction for every task.\nThe multi-task learning encourages better generality of representation and in the meantime produces a nice side-product: all-tasks-labeled examples from unlabeled data. They are precious data labels considering that cross-task labels are useful but fairly rare.\nUse CVT in Downstream Tasks\n#\nTheoretically the primary prediction module can take any form, generic or task-specific design. The examples presented in the CVT paper include both cases.\nIn sequential tagging tasks (classification for every token) like\nNER\nor\nPOS\ntagging, the predictor module contains two fully connected layers and a softmax layer on the output to produce a probability distribution over class labels.\nFor each token $\\mathbf{x}_i$, we take the corresponding hidden states in two layers, $\\mathbf{h}_1^{(i)}$ and $\\mathbf{h}_2^{(i)}$:\n$$\n\\begin{aligned}\np_\\theta(y_i \\mid \\mathbf{x}_i) \n&= \\text{NN}(\\mathbf{h}^{(i)}) \\\\\n&= \\text{NN}([\\mathbf{h}_1^{(i)}; \\mathbf{h}_2^{(i)}]) \\\\\n&= \\text{softmax} \\big( \\mathbf{W}\\cdot\\text{ReLU}(\\mathbf{W'}\\cdot[\\mathbf{h}_1^{(i)}; \\mathbf{h}_2^{(i)}]) + \\mathbf{b} \\big)\n\\end{aligned}\n$$\nThe auxiliary tasks are only fed with forward or backward LSTM state in the first layer. Because they only observe partial context, either on the left or right, they have to learn like a language model, trying to predict the next token given the context. The\nfwd\nand\nbwd\nauxiliary tasks only take one direction. The\nfuture\nand\npast\ntasks take one step further in forward and backward direction, respectively.\n$$\n\\begin{aligned}\np_\\theta^\\text{fwd}(y_i \\mid \\mathbf{x}_i) &= \\text{NN}^\\text{fwd}(\\overrightarrow{\\mathbf{h}}^{(i)}) \\\\\np_\\theta^\\text{bwd}(y_i \\mid \\mathbf{x}_i) &= \\text{NN}^\\text{bwd}(\\overleftarrow{\\mathbf{h}}^{(i)}) \\\\\np_\\theta^\\text{future}(y_i \\mid \\mathbf{x}_i) &= \\text{NN}^\\text{future}(\\overrightarrow{\\mathbf{h}}^{(i-1)}) \\\\\np_\\theta^\\text{past}(y_i \\mid \\mathbf{x}_i) &= \\text{NN}^\\text{past}(\\overleftarrow{\\mathbf{h}}^{(i+1)})\n\\end{aligned}\n$$\nThe sequential tagging task depends on four auxiliary prediction models, their inputs only involving hidden states in one direction: forward, backward, future and past. (Image source:\noriginal paper\n)\nNote that if the primary prediction module has dropout, the dropout layer works as usual when training with labeled data, but it is not applied when generating “soft” target for auxiliary tasks during training with unlabeled data.\nIn the machine translation task, the primary prediction module is replaced with a standard unidirectional LSTM decoder with attention. There are two auxiliary tasks: (1) apply dropout on the attention weight vector by randomly zeroing out some values; (2) predict the future word in the target sequence. The primary prediction for auxiliary tasks to match is the best predicted target sequence produced by running the fixed primary decoder on the input sequence with\nbeam search\n.\nULMFiT\n#\nThe idea of using generative pretrained LM + task-specific fine-tuning was first explored in ULMFiT (\nHoward & Ruder, 2018\n), directly motivated by the success of using ImageNet pre-training for computer vision tasks. The base model is\nAWD-LSTM\n.\nULMFiT follows three steps to achieve good transfer learning results on downstream language classification tasks:\nGeneral LM pre-training\n: on Wikipedia text.\nTarget task LM fine-tuning\n: ULMFiT proposed two training techniques for stabilizing the fine-tuning process. See below.\nDiscriminative fine-tuning\nis motivated by the fact that different layers of LM capture different types of information (see\ndiscussion\nabove). ULMFiT proposed to tune each layer with different learning rates, $\\{\\eta^1, \\dots, \\eta^\\ell, \\dots, \\eta^L\\}$, where $\\eta$ is the base learning rate for the first layer, $\\eta^\\ell$ is for the $\\ell$-th layer and there are $L$ layers in total.\nSlanted triangular learning rates (STLR)\nrefer to a special learning rate scheduling that first linearly increases the learning rate and then linearly decays it. The increase stage is short so that the model can converge to a parameter space suitable for the task fast, while the decay period is long allowing for better fine-tuning.\nTarget task classifier fine-tuning\n: The pretrained LM is augmented with two standard feed-forward layers and a softmax normalization at the end to predict a target label distribution.\nConcat pooling\nextracts max-polling and mean-pooling over the history of hidden states and concatenates them with the final hidden state.\nGradual unfreezing\nhelps to avoid catastrophic forgetting by gradually unfreezing the model layers starting from the last one. First the last layer is unfrozen and fine-tuned for one epoch. Then the next lower layer is unfrozen. This process is repeated until all the layers are tuned.\nThree training stages of ULMFiT. (Image source:\noriginal paper\n)\nGPT\n#\nFollowing the similar idea of ELMo, OpenAI\nGPT\n, short for\nGenerative Pre-training Transformer\n(\nRadford et al., 2018\n), expands the unsupervised language model to a much larger scale by training on a giant collection of free text corpora. Despite of the similarity, GPT has two major differences from ELMo.\nThe model architectures are different: ELMo uses a shallow concatenation of independently trained left-to-right and right-to-left multi-layer LSTMs, while GPT is a multi-layer transformer decoder.\nThe use of contextualized embeddings in downstream tasks are different: ELMo feeds embeddings into models customized for specific tasks as additional features, while GPT fine-tunes the same base model for all end tasks.\nTransformer Decoder as Language Model\n#\nCompared to the\noriginal transformer\narchitecture, the\ntransformer decoder\nmodel discards the encoder part, so there is only one single input sentence rather than two separate source and target sequences.\nThis model applies multiple transformer blocks over the embeddings of input sequences. Each block contains a masked\nmulti-headed self-attention\nlayer and a\npointwise feed-forward\nlayer. The final output produces a distribution over target tokens after softmax normalization.\nThe transformer decoder model architecture in OpenAI GPT.\nThe loss is the negative log-likelihood, same as\nELMo\n, but without backward computation. Let’s say, the context window of the size $k$ is located before the target word and the loss would look like:\n$$\n\\mathcal{L}_\\text{LM} = -\\sum_{i} \\log p(x_i\\mid x_{i-k}, \\dots, x_{i-1})\n$$\nByte Pair Encoding\n#\nByte Pair Encoding\n(\nBPE\n) is used to encode the input sequences. BPE was originally proposed as a data compression algorithm in 1990s and then was adopted to solve the open-vocabulary issue in machine translation, as we can easily run into rare and unknown words when translating into a new language. Motivated by the intuition that rare and unknown words can often be decomposed into multiple subwords, BPE finds the best word segmentation by iteratively and greedily merging frequent pairs of characters.\nSupervised Fine-Tuning\n#\nThe most substantial upgrade that OpenAI GPT proposed is to get rid of the task-specific model and use the pre-trained language model directly!\nLet’s take classification as an example. Say, in the labeled dataset, each input has $n$ tokens, $\\mathbf{x} = (x_1, \\dots, x_n)$, and one label $y$. GPT first processes the input sequence $\\mathbf{x}$ through the pre-trained transformer decoder and the last layer output for the last token $x_n$ is $\\mathbf{h}_L^{(n)}$. Then with only one new trainable weight matrix $\\mathbf{W}_y$, it can predict a distribution over class labels.\n$$\nP(y\\mid x_1, \\dots, x_n) = \\text{softmax}(\\mathbf{h}_L^{(n)}\\mathbf{W}_y)\n$$\nThe loss is to minimize the negative log-likelihood for true labels. In addition, adding the LM loss as an auxiliary loss is found to be beneficial, because:\n(1) it helps accelerate convergence during training and\n(2) it is expected to improve the generalization of the supervised model.\n$$\n\\begin{aligned}\n\\mathcal{L}_\\text{cls} &= \\sum_{(\\mathbf{x}, y) \\in \\mathcal{D}} \\log P(y\\mid x_1, \\dots, x_n) = \\sum_{(\\mathbf{x}, y) \\in \\mathcal{D}} \\log \\text{softmax}(\\mathbf{h}_L^{(n)}(\\mathbf{x})\\mathbf{W}_y) \\\\\n\\mathcal{L}_\\text{LM} &= -\\sum_{i} \\log p(x_i\\mid x_{i-k}, \\dots, x_{i-1}) \\\\\n\\mathcal{L} &= \\mathcal{L}_\\text{cls} + \\lambda \\mathcal{L}_\\text{LM}\n\\end{aligned}\n$$\nWith similar designs, no customized model structure is needed for other end tasks (see Fig. 7). If the task input contains multiple sentences, a special delimiter token (\n$\n) is added between each pair of sentences. The embedding for this delimiter token is a new parameter we need to learn, but it should be pretty minimal.\nFor the sentence similarity task, because the ordering does not matter, both orderings are included. For the multiple choice task, the context is paired with every answer candidate.\nTraining objects in slightly modified GPT transformer models for downstream tasks. (Image source:\noriginal paper\n)\nSummary\n: It is super neat and encouraging to see that such a general framework is capable to beat SOTA on most language tasks at that time (June 2018). At the first stage, generative pre-training of a language model can absorb as much free text as possible. Then at the second stage, the model is fine-tuned on specific tasks with a small labeled dataset and a minimal set of new parameters to learn.\nOne limitation of GPT is its uni-directional nature — the model is only trained to predict the future left-to-right context.\nBERT\n#\nBERT\n, short for\nBidirectional Encoder Representations from Transformers\n(\nDevlin, et al., 2019\n) is a direct descendant to\nGPT\n: train a large language model on free text and then fine-tune on specific tasks without customized network architectures.\nCompared to GPT, the largest difference and improvement of BERT is to make training\nbi-directional\n. The model learns to predict both context on the left and right. The paper according to the ablation study claimed that:\n“bidirectional nature of our model is the single most important new contribution”\nPre-training Tasks\n#\nThe model architecture of BERT is a multi-layer bidirectional Transformer encoder.\nRecap of Transformer Encoder model architecture. (Image source:\nTransformer paper\n)\nTo encourage the bi-directional prediction and sentence-level understanding, BERT is trained with two tasks instead of the basic language task (that is, to predict the next token given context).\n*\nTask 1: Mask language model (MLM)\nFrom\nWikipedia\n: “A cloze test (also cloze deletion test) is an exercise, test, or assessment consisting of a portion of language with certain items, words, or signs removed (cloze text), where the participant is asked to replace the missing language item. … The exercise was first described by W.L. Taylor in 1953.”\nIt is unsurprising to believe that a representation that learns the context around a word rather than just after the word is able to better capture its meaning, both syntactically and semantically. BERT encourages the model to do so by training on the\n“mask language model” task\n:\nRandomly mask 15% of tokens in each sequence. Because if we only replace masked tokens with a special placeholder\n[MASK]\n, the special token would never be encountered during fine-tuning. Hence, BERT employed several heuristic tricks:\n(a) with 80% probability, replace the chosen words with\n[MASK]\n;\n(b) with 10% probability, replace with a random word;\n(c) with 10% probability, keep it the same.\nThe model only predicts the missing words, but it has no information on which words have been replaced or which words should be predicted. The output size is only 15% of the input size.\nTask 2: Next sentence prediction\nMotivated by the fact that many downstream tasks involve the understanding of relationships between sentences (i.e.,\nQA\n,\nNLI\n), BERT added another auxiliary task on training a\nbinary classifier\nfor telling whether one sentence is the next sentence of the other:\nSample sentence pairs (A, B) so that:\n(a) 50% of the time, B follows A;\n(b) 50% of the time, B does not follow A.\nThe model processes both sentences and output a binary label indicating whether B is the next sentence of A.\nThe training data for both auxiliary tasks above can be trivially generated from any monolingual corpus. Hence the scale of training is unbounded. The training loss is the sum of the mean masked LM likelihood and mean next sentence prediction likelihood.\nComparison of BERT, OpenAI GPT and ELMo model architectures. (Image source:\noriginal paper\n)\nInput Embedding\n#\nThe input embedding is the sum of three parts:\nWordPiece tokenization embeddings\n: The\nWordPiece\nmodel\nwas originally proposed for Japanese or Korean segmentation problem. Instead of using naturally split English word, they can be further divided into smaller sub-word units so that it is more effective to handle rare or unknown words. Please read\nlinked\npapers\nfor the optimal way to split words if interested.\nSegment embeddings\n: If the input contains two sentences, they have sentence A embeddings and sentence B embeddings respectively and they are separated by a special character\n[SEP]\n; Only sentence A embeddings are used if the input only contains one sentence.\nPosition embeddings\n: Positional embeddings are learned rather than hard-coded.\nBERT input representation. (Image source:\noriginal paper\n)\nNote that the first token is always forced to be\n[CLS]\n— a placeholder that will be used later for prediction in downstream tasks.\nUse BERT in Downstream Tasks\n#\nBERT fine-tuning requires only a few new parameters added, just like OpenAI GPT.\nFor classification tasks, we get the prediction by taking the final hidden state of the special first token\n[CLS]\n, $\\mathbf{h}^\\text{[CLS]}_L$, and multiplying it with a small weight matrix, $\\text{softmax}(\\mathbf{h}^\\text{[CLS]}_L \\mathbf{W}_\\text{cls})$.\nFor\nQA\ntasks like SQuAD, we need to predict the text span in the given paragraph for an given question. BERT predicts two probability distributions of every token, being the start and the end of the text span. Only two new small matrices, $\\mathbf{W}_\\text{s}$ and $\\mathbf{W}_\\text{e}$, are newly learned during fine-tuning and $\\text{softmax}(\\mathbf{h}^\\text{(i)}_L \\mathbf{W}_\\text{s})$ and $\\text{softmax}(\\mathbf{h}^\\text{(i)}_L \\mathbf{W}_\\text{e})$ define two probability distributions.\nOverall the add-on part for end task fine-tuning is very minimal — one or two weight matrices to convert the Transform hidden states to an interpretable format. Check the paper for implementation details for other cases.\nTraining objects in slightly modified BERT models for downstream tasks.  (Image source:\noriginal paper\n)\nA summary table compares differences between fine-tuning of\nOpenAI GPT\nand BERT.\n|              |\nOpenAI GPT\n|\nBERT\n|\n| Special char |\n[SEP]\nand\n[CLS]\nare only introduced at fine-tuning stage. |\n[SEP]\nand\n[CLS]\nand sentence A/B embeddings are learned at the pre-training stage. |\n| Training process | 1M steps, batch size 32k words. | 1M steps, batch size 128k words. |\n| Fine-tuning  | lr = 5e-5 for all fine-tuning tasks. | Use task-specific lr for fine-tuning. |\nALBERT\n#\nALBERT\n(\nLan, et al. 2019\n), short for\nA Lite BERT\n, is a light-weighted version of\nBERT\nmodel. An ALBERT model can be trained 1.7x faster with 18x fewer parameters, compared to a BERT model of similar configuration. ALBERT incorporates three changes as follows: the first two help reduce parameters and memory consumption and hence speed up the training speed, while the third one proposes a more chanllenging training task to replace the next sentence prediction (NSP) objective.\nFactorized Embedding Parameterization\n#\nIn BERT, the WordPiece tokenization embedding size $E$ is configured to be the same as the hidden state size $H$. That is saying, if we want to increase the model size (larger $H$), we need to learn a larger tokenization embedding too, which is expensive because it depends on the vocabulary size ($V$).\nConceptually, because the tokenization embedding is expected to learn\ncontext-independent\nrepresentation and the hidden states are\ncontext-dependent\n, it makes sense to separate the size of the hidden layers from the size of vocabulary embedding. Using factorized embedding parameterization, the large vocabulary embedding matrix of size $V \\times H$ is decomposed into two small matrices of size $V \\times E$ and $E \\times H$. Given $H \\gt E$ or even $H \\gg E$, factorization can result in significant parameter reduction.\nCross-layer Parameter Sharing\n#\nParameter sharing across layers can happen in many ways: (a) only share feed-forward part; (b) only share attention parameters; or (c) share all the parameters. This technique reduces the number of parameters by a ton and does not damage the performance too much.\nSentence-Order Prediction (SOP)\n#\nInterestingly, the\nnext sentence prediction (NSP)\ntask of BERT turned out to be too easy. ALBERT instead adopted a sentence-order prediction (SOP)\nself-supervised\nloss,\nPositive sample: two consecutive segments from the same document.\nNegative sample: same as above, but the segment order is switched.\nFor the NSP task, the model can make reasonable predictions if it is able to detect topics when A and B are from different contexts. In comparison, SOP is harder as it requires the model to fully understand the coherence and ordering between segments.\nGPT-2\n#\nThe\nOpenAI\nGPT-2\nlanguage model is a direct successor to\nGPT\n. GPT-2 has 1.5B parameters, 10x more than the original GPT, and it achieves SOTA results on 7 out of 8 tested language modeling datasets in a\nzero-shot transfer setting\nwithout any task-specific fine-tuning. The pre-training dataset contains 8 million Web pages collected by crawling qualified outbound links from\nReddit\n. Large improvements by OpenAI GPT-2 are specially noticeable on small datasets and datasets used for measuring\nlong-term dependency\n.\nZero-Shot Transfer\n#\nThe pre-training task for GPT-2 is solely language modeling. All the downstream language tasks are framed as predicting conditional probabilities and there is no task-specific fine-tuning.\nText generation is straightforward using LM.\nMachine translation task, for example, English to Chinese, is induced by conditioning LM on pairs of “English sentence = Chinese sentence” and “the target English sentence =” at the end.\nFor example, the conditional probability to predict might look like:\nP(? | I like green apples. = 我喜欢绿苹果。 A cat meows at him. = 一只猫对他喵。It is raining cats and dogs. =\")\nQA task is formatted similar to translation with pairs of questions and answers in the context.\nSummarization task is induced by adding\nTL;DR:\nafter the articles in the context.\nBPE on Byte Sequences\n#\nSame as the original GPT, GPT-2 uses\nBPE\nbut on\nUTF-8\nbyte sequences. Each byte can represent 256 different values in 8 bits, while UTF-8 can use up to 4 bytes for one character, supporting up to $2^{31}$ characters in total. Therefore, with byte sequence representation we only need a vocabulary of size 256 and do not need to worry about pre-processing, tokenization, etc. Despite of the benefit, current byte-level LMs still have non-negligible performance gap with the SOTA word-level LMs.\nBPE merges frequently co-occurred byte pairs in a greedy manner. To prevent it from generating multiple versions of common words (i.e.\ndog.\n,\ndog!\nand\ndog?\nfor the word\ndog\n), GPT-2 prevents BPE from merging characters across categories (thus\ndog\nwould not be merged with punctuations like\n.\n,\n!\nand\n?\n). This tricks help increase the quality of the final byte segmentation.\nUsing the byte sequence representation, GPT-2 is able to assign a probability to any Unicode string, regardless of any pre-processing steps.\nModel Modifications\n#\nCompared to GPT, other than having many more transformer layers and parameters, GPT-2 incorporates only a few architecture modifications:\nLayer normalization\nwas moved to the input of each sub-block, similar to a residual unit of type\n“building block”\n(differently from the original type\n“bottleneck”\n, it has batch normalization applied before weight layers).\nAn additional layer normalization was added after the final self-attention block.\nA modified initialization was constructed as a function of the model depth.\nThe weights of residual layers were initially scaled by a factor of $1/ \\sqrt{N}$ where N is the number of residual layers.\nUse larger vocabulary size and context size.\nRoBERTa\n#\nRoBERTa\n(short for\nR\nobustly\no\nptimized\nBERT\na\npproach;\nLiu, et al. 2019\n) refers to a new receipt for training BERT to achieve better results, as they found that the original BERT model is significantly undertrained. The receipt contains the following learnings:\nTrain for longer with bigger batch size.\nRemove the\nnext sentence prediction (NSP)\ntask.\nUse longer sequences in training data format. The paper found that using individual sentences as inputs hurts downstream performance. Instead we should use multiple sentences sampled contiguously to form longer segments.\nChange the masking pattern dynamically. The original BERT applies masking once during the data preprocessing stage, resulting in a static mask across training epochs. RoBERTa applies masks in 10 different ways across 40 epochs.\nRoBERTa also added a new dataset\nCommonCrawl News\nand further confirmed that pretraining with\nmore data helps\nimprove the performance on downstream tasks. It was trained with the\nBPE on byte sequences\n, same as in\nGPT-2\n. They also found that choices of hyperparameters have a big impact on the model performance.\nT5\n#\nThe language model\nT5\nis short for\n“Text-to-Text Transfer Transformer”\n(\nRaffel et al., 2020\n). The encoder-decoder implementation follows the\noriginal Transformer\narchitecture: tokens → embedding → encoder → decoder → output. T5 adopts the framework “Natural Language Decathlon” (\nMcCann et al., 2018\n), where many common NLP tasks are translated into question-answering over a context. Instead of an explicit QA format, T5 uses short task prefixes to distinguish task intentions and separately fine-tunes the model on every individual task. The text-to-text framework enables easier transfer learning evaluation with the same model on a diverse set of tasks.\nA diagram of T5 task evaluation. The text-to-text framework casts every task into a generic form: feeding input text to predict some target text. (Image source:\nRaffel et al., 2020\n)\nThe model is trained on Web corpus extracted from Apr 2019 with various filters applied. The model is fine-tuned for each downstream task separately via “adapter layers” (add an extra layer for training) or “gradual unfreezing” (see\nULMFiT\n). Both fine-tuning approaches only update partial parameters while keeping the majority of the model parameters unchanged. T5-11B achieved SOTA results on many NLP tasks.\nAs the authors mentioned in the paper “…our goal is not to propose new methods but instead to provide a comprehensive perspective on where the field stands”, the T5 long paper described a lot of training setup and evaluation processes in detail, a good read for people who are interested in training a LM from scratch.\nGPT-3\n#\nGPT-3\n(\nBrown et al., 2020\n) has the same architecture as\nGPT-2\nbut contains 175B parameters, 10x larger than GPT-2 (1.5B). In addition, GPT-3 uses alternating dense and locally banded sparse attention patterns, same as in\nsparse transformer\n. In order to fit such a huge model across multiple GPUs, GPT-3 is trained with partitions along both width and depth dimension. The training data is a filtered version of Common Crawl mixed with a few other high-quality curated datasets. To avoid the contamination that downstream tasks might appear in the training data, the authors attempted to remove all the overlaps with all the studied benchmark dataset from the training dataset. Unfortunately the filtering process is not perfect due to a bug.\nTraining datasets for GPT-3. Note that the occurrence of each dataset during training is not proportional to the dataset size.  (Table source:\nBrown et al., 2020\n)\nFor all the downstream evaluation, GPT-3 is tested in the few-shot setting without any gradient-based fine-tuning. Here the few-shot examples are provided as part of the prompt. GPT-3 achieves strong performance on many NLP datasets, comparable with fine-tuned BERT models.\nThe evaluation performance increases with the model size and the number of examples. (Image source:\nBrown et al., 2020\n)\nXLNet\n#\nThe\nAutoregressive (AR)\nmodel such as GPT and\nautoencoder (AE)\nmodel such as BERT are two most common ways for language modeling. However, each has their own disadvantages: AR does not learn the bidirectional context, which is needed by downstream tasks like reading comprehension and AE assumes masked positions are independent given all other unmasked tokens which oversimplifies the long context dependency.\nXLNet\n(\nYang et al. 2019\n) generalizes the AE method to incorporate the benefits of AR. XLNet proposed the\npermutation language modeling\nobjective. For a text sequence, it samples a factorization order $\\mathbf{z}$ and decomposes the likelihood $p_\\theta(\\mathbf{x})$ according to this factorization order,\n$$\n\\begin{aligned}\n\\mathcal{L}_\\text{XLNet} \n&= - \\mathbb{E}_{\\mathbf{z} \\sim \\mathcal{Z}_T} \\Big[ \\sum_{t=1}^T \\log p_\\theta (X_{z_t} = x \\mid \\mathbf{x}_{\\mathbf{z}_{<{t}}})\\Big] \\\\\n&= - \\mathbb{E}_{\\mathbf{z} \\sim \\mathcal{Z}_T} \\Big[ \\log \\frac{ \\exp(e(x)^\\top \\color{red}{h_\\theta (\\mathbf{x}_{\\mathbf{z}_{<{t}}})}) }{ \\sum_{x'} \\exp(e(x')^\\top \\color{red}{h_\\theta (\\mathbf{x}_{\\mathbf{z}_{<{t}}})}) } \\Big] \\\\\n&= - \\mathbb{E}_{\\mathbf{z} \\sim \\mathcal{Z}_T} \\Big[ \\log \\frac{ \\exp(e(x)^\\top \\color{blue}{g_\\theta (\\mathbf{x}_{\\mathbf{z}_{<{t}}}, z_t)}) }{ \\sum_{x'} \\exp(e(x')^\\top \\color{blue}{g_\\theta (\\mathbf{x}_{\\mathbf{z}_{<{t}}}, z_t)}) } \\Big]\n\\end{aligned}\n$$\nwhere $\\mathcal{Z}_T$ is a set of all possible permutation of length $T$;  $z_t$ and $\\mathbf{z}_{<t}$  denote the $t$-th element and the first $t-1$ elements of a permutation $\\mathbf{z} \\in \\mathcal{Z}_T$.\nNote that the naive representation of the hidden state of the context, $h_\\theta (\\mathbf{x}_{\\mathbf{z}_{<t}})$ in red, does not depend on which position the model tries to predict, as the permutation breaks the default ordering. Therefore, XLNet re-parameterized it to a function of the target position too, $g_\\theta (\\mathbf{x}_{\\mathbf{z}_{<t}}, z_t)$ in blue.\nHowever,  two different requirements on  $g_\\theta (\\mathbf{x}_{\\mathbf{z}_{<t}}, z_t)$ lead to a two-stream self-attention design to accommodate:\nWhen predicting $x_{z_t}$, it should only encode the position $z_t$ but not the content $x_{z_t}$; otherwise it is trivial. This is wrapped into the “query representation”  $g_{z_t} = g_\\theta (\\mathbf{x}_{\\mathbf{z}_{<t}}, z_t)$ does not encode $x_{z_t}$.\nWhen predicting $x_j$ where $j > t$, it should encode the content $x_{z_t}$ as well to provide the full context. This is the “content representation” $h_{z_t} = h_\\theta(\\mathbf{x}_{\\leq t})$.\nThe illustration of two-stream self-attention mechanism in XLNet. (Image source:\nYang et al. 2019\n)\nConceptually, the two streams of representations are updated as follows,\n$$\n\\begin{aligned}\ng_{z_t}^{(m)} &\\gets \\text{Attention}(Q = g^{(m-1)}_{z_t}, KV=\\mathbf{h}^{(m-1)}_{\\color{red}{\\mathbf{z}_{<{t}}}}; \\theta) &\\text{(query stream: use }z_t\\text{ but cannot see }x_{z_t}\\text{)}\\\\\nh_{z_t}^{(m)} &\\gets \\text{Attention}(Q = h^{(m-1)}_{z_t}, KV=\\mathbf{h}^{(m-1)}_{\\color{blue}{\\mathbf{z}_{\\leq t}}}; \\theta) &\\text{(content stream: use both }x_{z_t}\\text{ and }x_{z_t}\\text{)}\\\\\n\\end{aligned}\n$$\nGiven the difficulty of optimization in permutation language modeling, XLNet is set to only predict the last chunk of tokens in a factorization order.\nThe name in XLNet actually comes from\nTransformer-XL\n. It incorporates the design of Transformer-XL to extend the attention span by reusing hidden states from previous segments.\nComparison of model performance of XLNet with a couple other language models on GLUE, all single-task, no ensembles. (Image source:\nYang et al. 2019\n)\nBART\n#\nBART\n(\nLewis et al., 2019\n) is a denoising autoencoder to recover the original text from a randomly corrupted version. It combines\nB\nidirectional and\nA\nuto\nR\negressive\nT\nransformer: precisely, jointly training BERT-like bidirectional encoder and GPT-like autoregressive decoder together. The loss is simply just to minimize the negative log-likelihood.\nA schematic comparison of BART with BERT and GPT. (Image source:\nLewis et al., 2019\n)\nThey experimented with a variety of noising transformations, including token masking, token deletion, text infilling (i.e. A randomly sampled text span, which may contain multiple tokens, is replaced with a\n[MASK]\ntoken), sentence permutation, documentation rotation (i.e. A document is rotated to begin with a random token.). The best noising approach they discovered is text infilling and sentence shuffling.\nComparison of different language modeling pre-training objectives. (Image source:\nLewis et al., 2019\n)\nLearnings from their experiments:\nThe performance of pre-training methods varies significantly across downstream tasks.\nToken masking is crucial, as the performance is poor when only sentence permutation or documentation rotation is applied.\nLeft-to-right pre-training improves generation.\nBidirectional encoders are crucial for SQuAD.\nThe pre-training objective is not the only important factor. Architectural improvements such as relative-position embeddings or segment-level recurrence matter too.\nAutoregressive language models perform best on ELI5.\nBART achieves the most consistently strong performance.\nELECTRA\n#\nMost current pre-training large language models demand a lot of computation resources, raising concerns about their cost and accessibility.\nELECTRA\n(“Efficiently Learning an Encoder that Classifies Token Replacements Accurately”;\nClark et al. 2020\n) aims to improve the\npre-training efficiency\n, which frames the language modeling as a discrimination task instead of generation task.\nIllustration of ELECTRA model architecture. (Image source:\nClark et al. 2020\n)\nELECTRA proposes a new pretraining task, called “Replaced Token Detection” (RTD). Let’s randomly sample $k$ positions to be masked. Each selected token in the original text is replaced by a plausible alternative predicted by a small language model, known as the generator $G$. The discriminator $D$ predicts whether each token is original or replaced.\n$$\n\\begin{aligned}\n\\boldsymbol{m} &= [m_1, \\dots, m_k] \\text{ where } m_i \\sim \\text{unif}\\{1, n\\}\\text{ for } i=1, \\dots, k \\\\\n\\boldsymbol{x}^\\text{masked} &= \\text{REPLACE}(\\boldsymbol{x}, \\boldsymbol{m}, \\texttt{[MASK]}) \\\\\n\\boldsymbol{x}^\\text{corrupt} &= \\text{REPLACE}(\\boldsymbol{x}, \\boldsymbol{m}, \\tilde{\\boldsymbol{x}}) \\text{ where } \\tilde{x}_t \\sim p_G(x_i \\mid \\boldsymbol{x}^\\text{masked}) \\text{ for } i \\in \\boldsymbol{m} \\\\\n\\end{aligned}\n$$\nThe loss for the generator is the negative log-likelihood just as in other language models. The loss for the discriminator is the cross-entropy. Note that the generator is not adversarially trained to fool the discriminator but simply to optimize the NLL, since their experiments show negative results.\n$$\n\\begin{aligned}\n\\mathcal{L}_\\text{MLM}(\\mathbf{x}, \\theta_G) &= \\mathbb{E}\\Big(\\sum_{i \\in \\boldsymbol{m}} -\\log p_G (x_i \\mid \\boldsymbol{x}^\\text{masked} )\\Big) \\\\\n\\mathcal{L}_\\text{Disc}(\\mathbf{x}, \\theta_D) &= \\mathbb{E}\\Big( - \\mathbb{1}[x^\\text{corrupt}_t = x_t] \\log D(\\boldsymbol{x}^\\text{corrupt}, t) - \\mathbb{1}[x^\\text{corrupt}_t \\neq x_t] \\log (1 - \\log D(\\boldsymbol{x}^\\text{corrupt}, t))  \\Big)\n\\end{aligned}\n$$\nThey found it more beneficial to only share the embeddings between generator & discriminator while using a small generator (1/4 to 1/2 the discriminator size), rather than sharing all the weights (i.e. two models have to be the same size then). In addition, joint training of the generator and discriminator works better than two-stage training of each alternatively.\nAfter pretraining the generator is discarded and only the ELECTRA discriminator is fine-tuned further for downstream tasks. The following table shows ELECTRA’s performance on the GLUE dev set.\nComparison of ELECTRA with other language models on the GLUE dev set. (Image source:\nClark et al. 2020\n)\nSummary\n#\nBase model\nPretraining Tasks\nCoVe\nseq2seq NMT model\nsupervised learning using translation dataset.\nELMo\ntwo-layer biLSTM\nnext token prediction\nCVT\ntwo-layer biLSTM\nsemi-supervised learning using both labeled and unlabeled datasets\nULMFiT\nAWD-LSTM\nautoregressive pretraining on Wikitext-103\nGPT\nTransformer decoder\nnext token prediction\nBERT\nTransformer encoder\nmask language model + next sentence prediction\nALBERT\nsame as BERT but light-weighted\nmask language model + sentence order prediction\nGPT-2\nTransformer decoder\nnext token prediction\nRoBERTa\nsame as BERT\nmask language model (dynamic masking)\nT5\nTransformer encoder + decoder\npre-trained on a multi-task mixture of unsupervised and supervised tasks and for which each task is converted into a text-to-text format.\nGPT-3\nTransformer decoder\nnext token prediction\nXLNet\nsame as BERT\npermutation language modeling\nBART\nBERT encoder + GPT decoder\nreconstruct text from a noised version\nELECTRA\nsame as BERT\nreplace token detection\nMetric: Perplexity\n#\nPerplexity is often used as an intrinsic evaluation metric for gauging how well a language model can capture the real word distribution conditioned on the context.\nA\nperplexity\nof a discrete proability distribution $p$ is defined as the exponentiation of the entropy:\n$$\n2^{H(p)} = 2^{-\\sum_x p(x) \\log_2 p(x)}\n$$\nGiven a sentence with $N$ words, $s = (w_1, \\dots, w_N)$, the entropy looks as follows, simply assuming that each word has the same frequency, $\\frac{1}{N}$:\n$$\nH(s) = -\\sum_{i=1}^N P(w_i) \\log_2  p(w_i)  = -\\sum_{i=1}^N \\frac{1}{N} \\log_2  p(w_i)\n$$\nThe perplexity for the sentence becomes:\n$$\n\\begin{aligned}\n2^{H(s)} &= 2^{-\\frac{1}{N} \\sum_{i=1}^N \\log_2  p(w_i)}\n= (2^{\\sum_{i=1}^N \\log_2  p(w_i)})^{-\\frac{1}{N}}\n= (p(w_1) \\dots p(w_N))^{-\\frac{1}{N}}\n\\end{aligned}\n$$\nA good language model should predict high word probabilities. Therefore, the smaller perplexity the better.\nCommon Tasks and Datasets\n#\nQuestion-Answering\nSQuAD\n(Stanford Question Answering Dataset): A reading comprehension dataset, consisting of questions posed on a set of Wikipedia articles, where the answer to every question is a span of text.\nRACE\n(ReAding Comprehension from Examinations): A large-scale reading comprehension dataset with more than 28,000 passages and nearly 100,000 questions. The dataset is collected from English examinations in China, which are designed for middle school and high school students.\nSee\nmore QA datasets in a later post\n.\nCommonsense Reasoning\nStory Cloze Test\n: A commonsense reasoning framework for evaluating story understanding and generation. The test requires a system to choose the correct ending to multi-sentence stories from two options.\nSWAG\n(Situations With Adversarial Generations): multiple choices; contains 113k sentence-pair completion examples that evaluate grounded common-sense inference\nNatural Language Inference (NLI)\n: also known as\nText Entailment\n, an exercise to discern in logic whether one sentence can be inferred from another.\nRTE\n(Recognizing Textual Entailment): A set of datasets initiated by text entailment challenges.\nSNLI\n(Stanford Natural Language Inference): A collection of 570k human-written English sentence pairs manually labeled for balanced classification with the labels\nentailment\n,\ncontradiction\n, and\nneutral\n.\nMNLI\n(Multi-Genre NLI): Similar to SNLI, but with a more diverse variety of text styles and topics, collected from transcribed speech, popular fiction, and government reports.\nQNLI\n(Question NLI): Converted from SQuAD dataset to be a binary classification task over pairs of (question, sentence).\nSciTail\n: An entailment dataset created from multiple-choice science exams and web sentences.\nNamed Entity Recognition (NER)\n: labels sequences of words in a text which are the names of things, such as person and company names, or gene and protein names\nCoNLL 2003 NER task\n: consists of newswire from the Reuters, concentrating on four types of named entities: persons, locations, organizations and names of miscellaneous entities.\nOntoNotes 5.0\n: This corpus contains text in English, Arabic and Chinese, tagged with four different entity types (PER, LOC, ORG, MISC).\nReuters Corpus\n: A large collection of Reuters News stories.\nFine-Grained NER (FGN)\nSentiment Analysis\nSST\n(Stanford Sentiment Treebank)\nIMDb\n: A large dataset of movie reviews with binary sentiment classification labels.\nSemantic Role Labeling (SRL)\n: models the predicate-argument structure of a sentence, and is often described as answering “Who did what to whom”.\nCoNLL-2004 & CoNLL-2005\nSentence similarity\n: also known as\nparaphrase detection\nMRPC\n(MicRosoft Paraphrase Corpus): It contains pairs of sentences extracted from news sources on the web, with annotations indicating whether each pair is semantically equivalent.\nQQP\n(Quora Question Pairs)\nSTS Benchmark: Semantic Textual Similarity\nSentence Acceptability\n: a task to annotate sentences for grammatical acceptability.\nCoLA\n(Corpus of Linguistic Acceptability): a binary single-sentence classification task.\nText Chunking\n: To divide a text in syntactically correlated parts of words.\nCoNLL-2000\nPart-of-Speech (POS) Tagging\n: tag parts of speech to each token, such as noun, verb, adjective, etc.\nthe Wall Street Journal portion of the Penn Treebank (Marcus et al., 1993).\nMachine Translation\n:  See\nStandard NLP\npage.\nWMT 2015 English-Czech data (Large)\nWMT 2014 English-German data (Medium)\nIWSLT 2015 English-Vietnamese data (Small)\nCoreference Resolution\n: cluster mentions in text that refer to the same underlying real world entities.\nCoNLL-2012\nLong-range Dependency\nLAMBADA\n(LAnguage Modeling Broadened to Account for Discourse Aspects): A collection of narrative passages extracted from the BookCorpus and the task is to predict the last word, which require at least 50 tokens of context for a human to successfully predict.\nChildren’s Book Test\n: is built from books that are freely available in\nProject Gutenberg\n. The task is to predict the missing word among 10 candidates.\nMulti-task benchmark\nGLUE multi-task benchmark:\nhttps://gluebenchmark.com\ndecaNLP benmark:\nhttps://decanlp.com\nUnsupervised pretraining dataset\nBooks corpus\n: The corpus contains “over 7,000 unique unpublished books from a variety of genres including Adventure, Fantasy, and Romance.”\n1B Word Language Model Benchmark\nEnglish Wikipedia\n: ~2500M words\nCited as:\n@article{weng2019LM,\n  title   = \"Generalized Language Models\",\n  author  = \"Weng, Lilian\",\n  journal = \"lilianweng.github.io\",\n  year    = \"2019\",\n  url     = \"https://lilianweng.github.io/posts/2019-01-31-lm/\"\n}\nReference\n#\n[1] Bryan McCann, et al.\n“Learned in translation: Contextualized word vectors.”\nNIPS. 2017.\n[2] Kevin Clark et al.\n“Semi-Supervised Sequence Modeling with Cross-View Training.”\nEMNLP 2018.\n[3] Matthew E. Peters, et al.\n“Deep contextualized word representations.”\nNAACL-HLT 2017.\n[4] OpenAI Blog\n“Improving Language Understanding with Unsupervised Learning”\n, June 11, 2018.\n[5] OpenAI Blog\n“Better Language Models and Their Implications.”\nFeb 14, 2019.\n[6] Jeremy Howard and Sebastian Ruder.\n“Universal language model fine-tuning for text classification.”\nACL 2018.\n[7] Alec Radford et al.\n“Improving Language Understanding by Generative Pre-Training”\n. OpenAI Blog, June 11, 2018.\n[8] Jacob Devlin, et al.\n“BERT: Pre-training of deep bidirectional transformers for language understanding.”\narXiv:1810.04805 (2018).\n[9] Mike Schuster, and Kaisuke Nakajima.\n“Japanese and Korean voice search.”\nICASSP. 2012.\n[10] Google’s Neural Machine Translation System: Bridging the Gap between Human and Machine Translation\n[11] Ashish Vaswani, et al.\n“Attention is all you need.”\nNIPS 2017.\n[12] Peter J. Liu, et al.\n“Generating wikipedia by summarizing long sequences.”\nICLR 2018.\n[13] Sebastian Ruder.\n“10 Exciting Ideas of 2018 in NLP”\nDec 2018.\n[14] Alec Radford, et al.\n“Language Models are Unsupervised Multitask Learners.”\n. 2019.\n[15] Rico Sennrich, et al.\n“Neural machine translation of rare words with subword units.”\narXiv preprint arXiv:1508.07909. 2015.\n[16] Zhenzhong Lan, et al.\n“ALBERT: A Lite BERT for Self-supervised Learning of Language Representations.”\narXiv Preprint arXiv:1909.11942 (2019).\n[17] Yinhan Liu, et al.\n“RoBERTa: A Robustly Optimized BERT Pretraining Approach.”\narXiv Preprint arXiv:1907.11692 (2019).\n[18] Tom B Brown, et al.\n“Language Models are Few-Shot Learners”\nNeuriPS 2020.\n[19] Zhilin Yang et al.\n“XLNet: Generalized Autoregressive Pretraining for Language Understanding.”\nNeuriPS 2019.\n[20] Mike Lewis et al.\n“BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension.”\nACL 2020.\n[21] Kevin Clark et al.\n“ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators.”\nICLR 2020.\n[22] Colin Raffel, et al.\n“Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer”\nJMLR 2020.",
  "repair_version": 2,
  "repaired_at": "2026-10-14T11:43:17Z",
  "title": "Generalized Language Models | Lil'Log",
  "audio": [],
  "code_blocks": [
    {
      "file": "attachments/607baf97b999/code/body-000.txt",
      "chars": 214,
      "language": "text"
    }
  ],
  "papers": [
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1810.04805",
      "bytes": 775166,
      "reused": true,
      "local_path": "papers/repair/33769e0bafc9f0c73baa.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1811.08883",
      "bytes": 788571,
      "reused": true,
      "local_path": "papers/repair/db0e3c5521e5a1800c77.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1708.00107",
      "bytes": 446263,
      "reused": true,
      "local_path": "papers/repair/e2c0a99965fb6abdde60.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1802.05365",
      "bytes": 425880,
      "reused": true,
      "local_path": "papers/repair/c4dc3d740cad43df1dd2.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1809.08370",
      "bytes": 811545,
      "reused": true,
      "local_path": "papers/repair/459221e6be389ff8d946.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1801.06146",
      "bytes": 979417,
      "reused": true,
      "local_path": "papers/repair/f99f602eebf2965d0ed0.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1708.02182",
      "bytes": 185413,
      "reused": true,
      "local_path": "papers/repair/f2555bb43fcea5781c7c.pdf"
    },
    {
      "status": "http_403",
      "url": "https://s3-us-west-2.amazonaws.com/openai-assets/research-covers/language-unsupervised/language_understanding_paper.pdf",
      "retried_at": "2026-10-20T18:10:14Z"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1706.03762",
      "bytes": 2215244,
      "reused": true,
      "local_path": "papers/repair/c3ab01e47e614fe3cf33.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1801.10198",
      "bytes": 1134703,
      "reused": true,
      "local_path": "papers/repair/fe35dee079dad5528221.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1508.07909",
      "bytes": 193216,
      "reused": true,
      "local_path": "papers/repair/a5d0ca76205630ec8110.pdf"
    },
    {
      "status": "ok",
      "url": "https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/37842.pdf",
      "bytes": 144257,
      "reused": true,
      "local_path": "papers/repair/0eab031e51f81c92fda2.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1609.08144.pdf",
      "bytes": 1688289,
      "reused": true,
      "local_path": "papers/repair/29316aab6d109d3a9ea6.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1909.11942",
      "bytes": 419105,
      "reused": true,
      "local_path": "papers/repair/9c6f91591bd290ea5163.pdf"
    },
    {
      "status": "download_error",
      "url": "https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf",
      "reason": "ConnectionError: HTTPSConnectionPool(host='d4mucfpksywv.cloudfront.net', port=443): Max retries exceeded with url: /better-language-models/language_models_are_unsupervised_multitask_learners.pdf (C",
      "retried_at": "2026-10-20T22:25:42Z"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1607.06450",
      "bytes": 612446,
      "reused": true,
      "local_path": "papers/repair/52a2360d9b658baa64ff.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1603.05027",
      "bytes": 1166414,
      "reused": true,
      "local_path": "papers/repair/780d6bd86240bf248474.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1512.03385",
      "bytes": 819383,
      "reused": true,
      "local_path": "papers/repair/523013cf51110acbfe60.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1907.11692",
      "bytes": 209675,
      "reused": true,
      "local_path": "papers/repair/8acd467c11db68744d3f.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1910.10683",
      "bytes": 1190021,
      "reused": true,
      "local_path": "papers/repair/4e0745eb290124ed9e02.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1806.08730",
      "bytes": 1187133,
      "reused": true,
      "local_path": "papers/repair/e2a98f1a611cef094a63.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/2005.14165",
      "bytes": 6768044,
      "reused": true,
      "local_path": "papers/repair/0c1629d8d07d676c2aae.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1906.08237",
      "bytes": 761790,
      "reused": true,
      "local_path": "papers/repair/e1dc08bfcdc2d830fa23.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/1910.13461",
      "bytes": 296072,
      "reused": true,
      "local_path": "papers/repair/006bd94b666a1c81bc24.pdf"
    },
    {
      "status": "ok",
      "url": "https://arxiv.org/pdf/2003.10555",
      "bytes": 497999,
      "reused": true,
      "local_path": "papers/repair/95df7a9ffe51e8dc3c44.pdf"
    }
  ],
  "actual_video_files": [],
  "body_chars": 53020,
  "expected_body_images": 23,
  "discovery_status": "ok",
  "delivery_status": "partial",
  "missing_reason": "download_error；http_403",
  "raw_html": "attachments/607baf97b999/pages/source.html",
  "local_html": "attachments/607baf97b999/pages/article.html",
  "body_base_path": "attachments/607baf97b999/pages/",
  "body_markdown_path": "attachments/607baf97b999/pages/article.md",
  "links": [
    {
      "href": "https://www.youtube.com/watch?v=l5einDQ-Ttc",
      "label": "here",
      "type": "a"
    },
    {
      "href": "https://blog.openai.com/language-unsupervised/",
      "label": "OpenAI GPT",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1810.04805",
      "label": "BERT",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1811.08883",
      "label": "found",
      "type": "a"
    },
    {
      "href": "https://lilianweng.github.io/posts/2017-10-15-word-embedding/",
      "label": "post on word embedding",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1708.00107",
      "label": "McCann et al. 2017",
      "type": "a"
    },
    {
      "href": "https://lilianweng.github.io/posts/2018-06-24-attention/",
      "label": "attentional seq-to-seq",
      "type": "a"
    },
    {
      "href": "https://github.com/THUNLP-MT/MT-Reading-List",
      "label": "NMT",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1802.05365",
      "label": "Peters, et al, 2018",
      "type": "a"
    },
    {
      "href": "https://en.wikipedia.org/wiki/Part-of-speech_tagging",
      "label": "part-of-speech",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1809.08370",
      "label": "Clark et al., 2018",
      "type": "a"
    },
    {
      "href": "https://en.wikipedia.org/wiki/Beam_search",
      "label": "beam search",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1801.06146",
      "label": "Howard & Ruder, 2018",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1708.02182",
      "label": "AWD-LSTM",
      "type": "a"
    },
    {
      "href": "https://s3-us-west-2.amazonaws.com/openai-assets/research-covers/language-unsupervised/language_understanding_paper.pdf",
      "label": "Radford et al., 2018",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1706.03762",
      "label": "original transformer",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1801.10198",
      "label": "transformer decoder",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1508.07909",
      "label": "BPE",
      "type": "a"
    },
    {
      "href": "https://en.wikipedia.org/wiki/Cloze_test",
      "label": "Wikipedia",
      "type": "a"
    },
    {
      "href": "https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/37842.pdf",
      "label": "WordPiece",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/pdf/1609.08144.pdf",
      "label": "model",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1909.11942",
      "label": "Lan, et al. 2019",
      "type": "a"
    },
    {
      "href": "https://lilianweng.github.io/posts/2019-11-10-self-supervised/",
      "label": "self-supervised",
      "type": "a"
    },
    {
      "href": "https://blog.openai.com/better-language-models/",
      "label": "OpenAI",
      "type": "a"
    },
    {
      "href": "https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf",
      "label": "GPT-2",
      "type": "a"
    },
    {
      "href": "https://www.reddit.com/",
      "label": "Reddit",
      "type": "a"
    },
    {
      "href": "https://en.wikipedia.org/wiki/UTF-8",
      "label": "UTF-8",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1607.06450",
      "label": "Layer normalization",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1603.05027",
      "label": "“building block”",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1512.03385",
      "label": "“bottleneck”",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1907.11692",
      "label": "Liu, et al. 2019",
      "type": "a"
    },
    {
      "href": "https://commoncrawl.org/2016/10/news-dataset-available/",
      "label": "CommonCrawl News",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1910.10683",
      "label": "Raffel et al., 2020",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1806.08730",
      "label": "McCann et al., 2018",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/2005.14165",
      "label": "Brown et al., 2020",
      "type": "a"
    },
    {
      "href": "https://lilianweng.github.io/posts/2020-04-07-the-transformer-family/",
      "label": "sparse transformer",
      "type": "a"
    },
    {
      "href": "https://papers.nips.cc/paper/2020/hash/1457c0d6bfcb4967418bfb8ac142f64a-Abstract.html",
      "label": "Brown et al., 2020",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1906.08237",
      "label": "Yang et al. 2019",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/1910.13461",
      "label": "Lewis et al., 2019",
      "type": "a"
    },
    {
      "href": "https://arxiv.org/abs/2003.10555",
      "label": "Clark et al. 2020",
      "type": "a"
    },
    {
      "href": "https://en.wikipedia.org/wiki/Perplexity",
      "label": "perplexity",
      "type": "a"
    },
    {
      "href": "https://rajpurkar.github.io/SQuAD-explorer/",
      "label": "SQuAD",
      "type": "a"
    },
    {
      "href": "http://www.qizhexie.com/data/RACE_leaderboard",
      "label": "RACE",
      "type": "a"
    },
    {
      "href": "https://lilianweng.github.io/posts/2020-10-29-odqa/",
      "label": "more QA datasets in a later post",
      "type": "a"
    },
    {
      "href": "http://cs.rochester.edu/nlp/rocstories/",
      "label": "Story Cloze Test",
      "type": "a"
    },
    {
      "href": "https://rowanzellers.com/swag/",
      "label": "SWAG",
      "type": "a"
    },
    {
      "href": "https://aclweb.org/aclwiki/Textual_Entailment_Resource_Pool",
      "label": "RTE",
      "type": "a"
    },
    {
      "href": "https://nlp.stanford.edu/projects/snli/",
      "label": "SNLI",
      "type": "a"
    },
    {
      "href": "https://www.nyu.edu/projects/bowman/multinli/",
      "label": "MNLI",
      "type": "a"
    },
    {
      "href": "https://gluebenchmark.com/tasks",
      "label": "QNLI",
      "type": "a"
    },
    {
      "href": "http://data.allenai.org/scitail/",
      "label": "SciTail",
      "type": "a"
    },
    {
      "href": "https://www.clips.uantwerpen.be/conll2003/",
      "label": "CoNLL 2003 NER task",
      "type": "a"
    },
    {
      "href": "https://catalog.ldc.upenn.edu/LDC2013T19",
      "label": "OntoNotes 5.0",
      "type": "a"
    },
    {
      "href": "https://trec.nist.gov/data/reuters/reuters.html",
      "label": "Reuters Corpus",
      "type": "a"
    },
    {
      "href": "https://nlp.stanford.edu/sentiment/index.html",
      "label": "SST",
      "type": "a"
    },
    {
      "href": "http://ai.stanford.edu/~amaas/data/sentiment/",
      "label": "IMDb",
      "type": "a"
    },
    {
      "href": "http://www.lsi.upc.edu/~srlconll/",
      "label": "CoNLL-2004 & CoNLL-2005",
      "type": "a"
    },
    {
      "href": "https://www.microsoft.com/en-us/download/details.aspx?id=52398",
      "label": "MRPC",
      "type": "a"
    },
    {
      "href": "https://data.quora.com/First-Quora-Dataset-Release-Question-Pairs",
      "label": "QQP",
      "type": "a"
    },
    {
      "href": "https://nyu-mll.github.io/CoLA/",
      "label": "CoLA",
      "type": "a"
    },
    {
      "href": "https://www.clips.uantwerpen.be/conll2000/chunking/",
      "label": "CoNLL-2000",
      "type": "a"
    },
    {
      "href": "https://nlp.stanford.edu/projects/nmt/",
      "label": "Standard NLP",
      "type": "a"
    },
    {
      "href": "http://conll.cemantix.org/2012/data.html",
      "label": "CoNLL-2012",
      "type": "a"
    },
    {
      "href": "http://clic.cimec.unitn.it/lambada/",
      "label": "LAMBADA",
      "type": "a"
    },
    {
      "href": "https://research.fb.com/downloads/babi/",
      "label": "Children’s Book Test",
      "type": "a"
    },
    {
      "href": "https://www.gutenberg.org/",
      "label": "Project Gutenberg",
      "type": "a"
    },
    {
      "href": "https://gluebenchmark.com/",
      "label": "https://gluebenchmark.com",
      "type": "a"
    },
    {
      "href": "https://decanlp.com/",
      "label": "https://decanlp.com",
      "type": "a"
    },
    {
      "href": "https://googlebooks.byu.edu/",
      "label": "Books corpus",
      "type": "a"
    },
    {
      "href": "http://www.statmt.org/lm-benchmark/",
      "label": "1B Word Language Model Benchmark",
      "type": "a"
    },
    {
      "href": "https://en.wikipedia.org/wiki/Wikipedia:Database_download",
      "label": "English Wikipedia",
      "type": "a"
    },
    {
      "href": "http://ruder.io/10-exciting-ideas-of-2018-in-nlp/",
      "label": "“10 Exciting Ideas of 2018 in NLP”",
      "type": "a"
    }
  ],
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": ""
  }
}