{"notes":[{"id":"transformers/gpt_1","category":"transformers","legacyPath":"transformers/1806-gpt_1","legacySlug":"1806-gpt_1","legacyPaths":[],"title":"GPT-1","subtitle":"Twelve-Layer Decoder","author":"Z. Yuan","paperDate":"2018","publishedOn":"2024-05-05","paperTitle":"Improving Language Understanding by Generative Pre-Training","paperUrl":"https://openai.com/index/language-unsupervised/","bibliography":{"title":"Improving Language Understanding by Generative Pre-Training","authors":["Alec Radford","Karthik Narasimhan","Tim Salimans","Ilya Sutskever"],"url":"https://openai.com/index/language-unsupervised/","pdfUrl":"https://cdn.openai.com/research-covers/language-unsupervised/language_understanding_paper.pdf","codeUrl":"https://github.com/openai/finetune","preprint":null,"publication":{"venue":"OpenAI","year":2018,"kind":"report","url":"https://openai.com/index/language-unsupervised/"},"citation":"@techreport{transformersgpt12018,\n  title = {{Improving Language Understanding by Generative Pre-Training}},\n  author = {Alec Radford and Karthik Narasimhan and Tim Salimans and Ilya Sutskever},\n  year = {2018},\n  institution = {OpenAI},\n  url = {https://openai.com/index/language-unsupervised/}\n}\n","citationPath":"/content/papers/citations/transformers/gpt_1.634f01e1da35.bib"},"thumbnail":{"src":"/content/papers/assets/09638f2c9f2ddf16a7510c19cd888dd53d93ebd8746b94742b311fdb192fc66a.jpg","width":1224,"height":620},"locale":"en","path":"/content/papers/en/transformers/gpt_1.d7c445890019.md","headings":[{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"1-lack-of-labeled-data","text":"1. Lack of Labeled Data","depth":3},{"id":"2-task-inconsistency","text":"2. Task Inconsistency","depth":3},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"model-architecture","text":"Model Architecture","depth":3},{"id":"pre-training-strategy","text":"Pre-training Strategy","depth":3},{"id":"fine-tuning-strategy","text":"Fine-tuning Strategy","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"why-is-the-transformer-effective","text":"Why is the Transformer Effective?","depth":3},{"id":"which-part-is-effective","text":"Which Part is Effective?","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"transformers/transformer","relation":"background","topic":"From language pretraining to in-context learning"},{"id":"transformers/gpt_2","relation":"next","topic":"From language pretraining to in-context learning"}]},{"id":"transformers/transformer","category":"transformers","legacyPath":"transformers/1706-transformer","legacySlug":"1706-transformer","legacyPaths":[],"title":"Transformer","subtitle":"The Dawn of a New Era","author":"Z. Yuan","paperDate":"2017-06-12","publishedOn":"2024-05-05","paperTitle":"Attention Is All You Need","paperUrl":"https://arxiv.org/abs/1706.03762","bibliography":{"title":"Attention Is All You Need","authors":["Ashish Vaswani","Noam Shazeer","Niki Parmar","Jakob Uszkoreit","Llion Jones","Aidan N. Gomez","Lukasz Kaiser","Illia Polosukhin"],"url":"https://arxiv.org/abs/1706.03762","pdfUrl":"https://arxiv.org/pdf/1706.03762","codeUrl":null,"preprint":{"id":"1706.03762","submittedOn":"2017-06-12","url":"https://arxiv.org/abs/1706.03762"},"publication":{"venue":"NeurIPS (NIPS)","year":2017,"kind":"conference","url":"https://proceedings.neurips.cc/paper_files/paper/2017/hash/3f5ee243547dee91fbd053c1c4a845aa-Abstract.html"},"citation":"@misc{transformerstransformer2017,\n  title = {{Attention Is All You Need}},\n  author = {Ashish Vaswani and Noam Shazeer and Niki Parmar and Jakob Uszkoreit and Llion Jones and Aidan N. Gomez and Lukasz Kaiser and Illia Polosukhin},\n  year = {2017},\n  eprint = {1706.03762},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/1706.03762}\n}\n","citationPath":"/content/papers/citations/transformers/transformer.86c0068d96fd.bib"},"thumbnail":{"src":"/content/papers/assets/29a55cb05497bdd9bbb3f3a96b7ed6656fda3552fa6a0fa5eb29e8e899c1acc1.jpg","width":756,"height":1080},"locale":"en","path":"/content/papers/en/transformers/transformer.420ab06f9af4.md","headings":[{"id":"problem-definition","text":"Problem Definition","depth":2},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"model-design","text":"Model Design","depth":3},{"id":"input-layer","text":"Input Layer","depth":3},{"id":"positional-encoding","text":"Positional Encoding","depth":3},{"id":"self-attention-mechanism","text":"Self-Attention Mechanism","depth":3},{"id":"multi-head-attention-mechanism","text":"Multi-Head Attention Mechanism","depth":3},{"id":"cross-attention-mechanism","text":"Cross-Attention Mechanism","depth":3},{"id":"feed-forward-network","text":"Feed-Forward Network","depth":3},{"id":"layer-normalization","text":"Layer Normalization","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"why-use-self-attention","text":"Why Use Self-Attention?","depth":3},{"id":"experimental-results-machine-translation","text":"Experimental Results: Machine Translation","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"transformers/flashattention","relation":"next","topic":"Attention memory and computation"},{"id":"transformers/bert","relation":"next","topic":"Pretraining bidirectional language representations"},{"id":"transformers/gpt_1","relation":"next","topic":"From language pretraining to in-context learning"}]},{"id":"transformers/gpt_2","category":"transformers","legacyPath":"transformers/1902-gpt_2","legacySlug":"1902-gpt_2","legacyPaths":[],"title":"GPT-2","subtitle":"Forty-Eight Layers of Decoders","author":"Z. Yuan","paperDate":"2019","publishedOn":"2024-05-24","paperTitle":"Language models are unsupervised multitask learners","paperUrl":"https://openai.com/index/better-language-models/","bibliography":{"title":"Language models are unsupervised multitask learners","authors":["Alec Radford","Jeffrey Wu","Rewon Child","David Luan","Dario Amodei","Ilya Sutskever"],"url":"https://openai.com/index/better-language-models/","pdfUrl":"https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf","codeUrl":"https://github.com/openai/gpt-2","preprint":null,"publication":{"venue":"OpenAI","year":2019,"kind":"report","url":"https://openai.com/index/better-language-models/"},"citation":"@techreport{transformersgpt22019,\n  title = {{Language models are unsupervised multitask learners}},\n  author = {Alec Radford and Jeffrey Wu and Rewon Child and David Luan and Dario Amodei and Ilya Sutskever},\n  year = {2019},\n  institution = {OpenAI},\n  url = {https://openai.com/index/better-language-models/}\n}\n","citationPath":"/content/papers/citations/transformers/gpt_2.f680e2d5a366.bib"},"thumbnail":{"src":"/content/papers/assets/e9f22b4511e15494c184fe4b81e763a07d74e80f1f8dcb9c4619d8c0ddff9866.jpg","width":804,"height":312},"locale":"en","path":"/content/papers/en/transformers/gpt_2.8bce4934551e.md","headings":[{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"fragility","text":"Fragility","depth":3},{"id":"limitations-of-narrow-experts","text":"Limitations of Narrow Experts","depth":3},{"id":"lack-of-generalization","text":"Lack of Generalization","depth":3},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"model-design","text":"Model Design","depth":3},{"id":"multitask-learning","text":"Multitask Learning","depth":3},{"id":"diverse-data","text":"Diverse Data","depth":3},{"id":"optimized-bpe-encoding","text":"Optimized BPE Encoding","depth":3},{"id":"byte-level-bpe","text":"Byte-Level BPE","depth":4},{"id":"discussion","text":"Discussion","depth":2},{"id":"model-sizes","text":"Model Sizes","depth":3},{"id":"zero-shot-performance","text":"Zero-Shot Performance","depth":3},{"id":"various-experiments","text":"Various Experiments","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"transformers/gpt_1","relation":"background","topic":"From language pretraining to in-context learning"},{"id":"transformers/gpt_3","relation":"next","topic":"From language pretraining to in-context learning"}]}],"text":"The original Transformer architecture has two parts: an encoder and a decoder.\n\nOpenAI took a different route from that starting point: **a decoder-only architecture**.\n\n## Defining the Problem\n\nThe authors identified several issues with current NLP models:\n\n### 1. Lack of Labeled Data\n\nIn the field of NLP, while data is abundant, labeled data is scarce. This is particularly problematic when working on specific tasks such as specialized domain question answering (QA) or machine translation (MT), where the lack of corresponding labeled data makes training difficult.\n\nOne way around the shortage of labels is a kind of “text continuation”: predict the next token. The targets come from the text itself, so this is commonly called self-supervised learning today, though not all unsupervised learning is self-supervision. You can keep collecting text without manually labeling every example. But that leads to another problem: the pre-training task and the eventual target task differ.\n\n### 2. Task Inconsistency\n\nIn NLP models, there are typically two stages: pre-training and fine-tuning. Pre-training involves letting the model learn from large amounts of text data, while fine-tuning involves training the model further on specific tasks. The inconsistency between these two stages is problematic.\n\nIn pre-training, the model learns to predict the next token, but in fine-tuning it may need to answer a question or compare two sentences. Earlier transfer methods often added a separate architecture and parameters for each target task, making the process cumbersome to manage.\n\nThe authors instead pre-train one Transformer decoder and transform sentence pairs or multiple-choice problems into sequences it can read. Fine-tuning adds a linear output layer and delimiter-token embeddings, with few task-specific architectural changes.\n\n## Solving the Problem\n\n### Model Architecture\n\n![Figure 1: the 12-layer decoder and training objectives on the left, task-specific input sequences on the right](/content/papers/assets/09638f2c9f2ddf16a7510c19cd888dd53d93ebd8746b94742b311fdb192fc66a.jpg)\n\nFigure 1 shows the shared 12-layer decoder and its language-model and task-classification outputs on the left. On the right, classification, entailment, similarity and multiple-choice inputs become token sequences. Entailment places a delimiter between the two sentences; similarity evaluates both orders and adds their representations; multiple-choice questions score each candidate answer. The configuration is as follows:\n\n- 12 decoder-only blocks with causal self-attention and FFNs, without encoder–decoder cross-attention.\n- Each decoder layer has 768 feature dimensions and 12 attention heads.\n- The hidden layer in the feed-forward network (FFN) uses 3072 neurons.\n- Sequence length is 512.\n- Dropout rate is 0.1.\n- Modified L2 regularization with coefficient 0.01 is applied to non-bias, non-gain weights.\n- Gelu activation function is used.\n- Position encoding uses learnable positional embeddings.\n- Text is pre-tokenized with the [**spaCy tokenizer**](https://spacy.io/api/tokenizer), then represented with BPE using 40,000 merges.\n\nTraining was conducted using:\n\n- Adam optimizer.\n- Maximum learning rate of 2.5e-4, linearly increasing over the first 2000 steps, then using cosine annealing to 0.\n- Training runs for 100 epochs on batches of 64 contiguous 512-token sequences.\n\n### Pre-training Strategy\n\nTraining uses unlabeled pretraining followed by supervised task-specific fine-tuning. GPT-1 pretrains on BooksCorpus; the 1B Word Benchmark below is discussed as an alternative corpus, not mixed into GPT-1 training.\n\n1. [**BooksCorpus**](https://arxiv.org/abs/1506.06724):\n   It contains over 7,000 unique unpublished books covering various genres like adventure, fantasy, and romance. Importantly, it includes long stretches of contiguous text, allowing the model to learn long-range dependencies.\n\n2. [**1B Word Benchmark**](https://www.statmt.org/lm-benchmark/):\n   Similar to methods used by [ELMo](https://arxiv.org/abs/1802.05365), this dataset is roughly the same size but reorganized at the sentence level to disrupt long-range structure.\n\n### Fine-tuning Strategy\n\nThe authors did not build an elaborate new architecture for each fine-tuning task. Instead, as Figure 1 shows, they turn each task's input into a token sequence: entailment joins a premise and hypothesis with a delimiter; semantic similarity evaluates both sentence orders and combines their representations; multiple choice scores each candidate answer. A linear classifier is then added. The same decoder is reused across these layouts, rather than training four different model architectures.\n\nDuring fine-tuning, the supervised task objective is accompanied by an auxiliary next-token language-model objective weighted 0.5. Unless otherwise specified, pre-training hyperparameters are reused. Classifier dropout is 0.1; most tasks use a learning rate of 6.25e-5 and batch size 32.\n\n## Discussion\n\nThe complete method achieved the then-best result on 9 of 12 evaluated datasets. Overall RACE accuracy was 59.0%, versus the previous 53.3%, but RTE accuracy was 56.0%, below the previous 61.7%. These results support the combination of language-model pre-training, input transformations and supervised fine-tuning; they do not isolate the decoder architecture as the only cause. The authors also examined zero-shot behavior.\n\n### Why is the Transformer Effective?\n\n![Figure 2: transferred layer count and RACE/MultiNLI performance on the left; pre-training updates and zero-shot performance on the right](/content/papers/assets/95249a4d0b378c1bf2f71bfd1fb07050cffe45ae8bf7a06ded567962c9ec8b02.jpg)\n\nFigure 2 (left) compares RACE and MultiNLI as more pre-trained layers are transferred. Solid lines are development scores and dashed lines are training scores. Both development curves generally rise with transfer depth, supporting the authors' interpretation that embeddings and successive layers help on these tasks.\n\n---\n\nFigure 2 (right) is a different experiment: task-specific heuristics use language-model scores **without supervised fine-tuning**. The horizontal axis counts pre-training updates; scores are normalized between random guessing and the then-best single model. Solid lines represent the Transformer, dashed lines the LSTM. Most curves rise, but vary substantially by task. They are not the fine-tuned accuracies plotted on the left.\n\n### Which Part is Effective?\n\n![Table 5: ablations of pre-training, the auxiliary language-model objective and an LSTM replacement across eight tasks](/content/papers/assets/0f45103f59647defb0d7833061ad87aea6c5cd6016be95e11711f912f0a33d22.jpg)\n\nTo identify which components contributed most to the model's performance, the authors conducted three different ablation studies. Results are shown in Table 5 of the paper:\n\n1. **Impact of the Auxiliary Language Model Objective:**\n\n   - Removing the auxiliary language-model objective lowers the MNLI, QNLI, RTE and QQP scores. QQP tests semantic equivalence of question pairs, not question answering.\n   - The authors saw a greater benefit on larger datasets, yet the unweighted eight-metric average is **75.0** without the auxiliary objective versus **74.7** for the full model. It does not improve every metric or the reported average.\n\n2. **Comparison Between Transformer and LSTM:**\n\n   - Replacing the Transformer with a single-layer, 2048-unit LSTM lowers Table 5's unweighted average from **74.7** to **69.1**, a 5.6-point difference.\n   - LSTM outperformed the Transformer only on the MRPC dataset.\n\n3. **Importance of Pre-training:**\n   - Without pre-training, every listed task score falls. Table 5’s eight-metric average drops from 74.7 to 59.9, a loss of 14.8 score points, not a relative decline of 14.8%.\n\n## Conclusion\n\nThis was OpenAI's first large-scale pre-trained Transformer language model. By learning from long stretches of unlabeled BooksCorpus text and then fine-tuning on specific tasks, it showed how one reusable model could achieve strong language-understanding results. The paper reports then-best results on 9 of 12 datasets, while RTE falls short and the auxiliary objective does not help every metric.\n\nGPT-1's success showed the promise of pre-training followed by fine-tuning across different NLP tasks. Figure 1's input transformations are as important to this story as the 12-layer decoder: the experiments do not attribute every gain to the decoder alone. This line of work laid groundwork for later, larger GPT-2 and GPT-3 models, and for using general representations across a wider range of language tasks.\n","imageSizes":{"/content/papers/assets/09638f2c9f2ddf16a7510c19cd888dd53d93ebd8746b94742b311fdb192fc66a.jpg":{"width":1224,"height":620},"/content/papers/assets/95249a4d0b378c1bf2f71bfd1fb07050cffe45ae8bf7a06ded567962c9ec8b02.jpg":{"width":1224,"height":652},"/content/papers/assets/0f45103f59647defb0d7833061ad87aea6c5cd6016be95e11711f912f0a33d22.jpg":{"width":1514,"height":434}}}
