GPT
11 memberslucid.models.text.gptGPT-1 family — Radford et al., 2018 (decoder-only transformer).
Radford, Alec, et al. "Improving Language Understanding by Generative Pre-Training." OpenAI Technical Report, 2018.
GPT — Generative Pre-Training — is a decoder-only transformer trained on an autoregressive (causal) language-modelling objective. Given a token sequence , the network factorises the joint distribution left-to-right and maximises
where and is the final-layer hidden state at position . Causality is enforced by an upper-triangular mask inside scaled dot-product attention, so position only attends to .
The architecture is a stack of transformer blocks
(hidden_size=768, 12 heads, intermediate_size=3072) with
learned absolute position embeddings and the tanh-approximated GELU
activation (gelu_new). Input and output token embeddings are
tied — the LM head reuses — which halves the
parameter count of the softmax layer. Unlike BERT, there is no
segment embedding and no masked-LM objective; downstream tasks are
handled by appending a task-specific delimiter sequence and reading
off the final hidden state.
Empirically, GPT established that unsupervised pre-training on a large unlabeled corpus (BookCorpus, ~800M tokens) followed by supervised fine-tuning transfers across a wide range of NLP tasks, foreshadowing the scaling-law regime later formalised by Kaplan et al. (2020). Increasing depth, width, and corpus size yields smooth, power-law improvements in held-out perplexity — the foundation that GPT-2 and GPT-3 scale up.
Classes
GPTConfig1 methodsConfiguration for every GPT-1 variant.
GPTDoubleHeadsModel2 methodsGPT-1 + LM head + multiple-choice classification head.
GPTDoubleHeadsOutput1 methodsJoint LM + multiple-choice output for GPTDoubleHeadsModel.
GPTForSequenceClassification2 methodsGPT-1 with a last-token sequence-classification head.
GPTLMHeadModel2 methodsGPT-1 with a tied causal-language-modeling head.
GPTModel4 methodsBare GPT-1 decoder-only Transformer trunk.
GPTTokenizer1 methodsGPT-1 tokenizer — pure-Python reference.
GPTTokenizerFast1 methodsGPT-1 tokenizer — C++-backed.