Paper · 2022-05-02 · cs.CL, cs.LG
OPT: Open Pre-trained Transformer Language Models
OPT is a family of decoder-only GPT-3-style Transformers from 125M to 175B parameters, trained on about 180B tokens of deduplicated web, book, Reddit and other text, with a published logbook and training code. Author-reported: OPT-175B is comparable to GPT-3 on zero- and few-shot NLP averages at about one seventh of its carbon footprint.
Language model pretrainingIn-context learningDataset curationpretraininglanguage-modelingdecoder-onlyscalingfew-shotreproducibility
arXivPDFCodeMarkdown15 min read
AI-compiled by claude-haiku-5-5 on 2026-10-19, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.
In plain words
OPT is Meta's attempt to make a GPT-3-class language model that outside researchers can study. Full access to models of this size was limited to a few well-resourced labs, which made it hard for others to look at their weights and find their weaknesses.
The models are ordinary "predict the next word" Transformers. Their size ranges from very small to very large, so you can study how behavior changes with scale. The team trained them on a large mix of text from the web, books, Wikipedia, news and Reddit conversations, after removing duplicate documents. The largest one was trained with a learning-rate schedule and optimizer settings borrowed from GPT-3. Training a model this big was hard: the hardware failed often, and the loss sometimes blew up, so the team restarted from older saved states and lowered the learning rate in places. They published a logbook of those problems along with the code.
The authors report that the largest model performs comparably to GPT-3 on standard zero- and few-shot tests on average, and that it has about one seventh of GPT-3's carbon footprint by their estimate. On several bias and toxicity tests the models do worse than GPT-3, and the authors did not add safety mitigations for this first release.
TL;DR
OPT is a suite of decoder-only Transformers with 125M to 175B parameters, trained with a GPT-3-style recipe: AdamW, a linear learning-rate decay to 10% of peak over 300B tokens, weight decay 0.1, and a batch of 0.5M to 4M tokens §2.1 §2.2 tab. 1. The corpus is about 180B tokens from RoBERTa, the Pile, and Pushshift Reddit, deduplicated with MinHash §2.3. The 175B model ran on 992 A100 80GB GPUs with FSDP and Megatron tensor parallelism §2.4. Author-reported: OPT-175B is comparable to GPT-3 on the average of standard zero- and few-shot NLP tasks §3.1 fig. 3 fig. 4, is competitive with the supervised BlenderBot 1 on the dialogue sets, most closely on ConvAI2 tab. 2, and does worse than GPT-3 on toxicity and on CrowS-Pairs §4.2 §4.4. The reported carbon footprint is 75 tCO2eq, against an estimated 500 tons for GPT-3 §6. The paper's stated values differ from the released code for the 175B learning rate and warmup length; see Paper vs code.
Problem
Large language models show zero- and few-shot abilities, but full model access was limited to a few well-resourced labs §1. This hampered outside research on robustness, bias and toxicity §1. The paper aims to give researchers weights and a comparable-size baseline, with a reproducible recipe and a transparent account of the training run §1 §6. The authors also want a model whose carbon cost is much lower than GPT-3's §1 §6.
Method
Section map of the compiled paper: §1 Introduction; §2 Method (§2.1 Models, §2.2 Training Setup, §2.3 Pre-training Corpus, §2.4 Training Efficiency, §2.5 Training Processes); §3 Evaluations (§3.1 Prompting & Few-Shot, §3.2 Dialogue); §4 Bias & Toxicity Evaluations (§4.1 to §4.5); §5 Limitations; §6 Considerations for Release; §7 Related Work; §8 Conclusion. Appendices and the datasheet and model card follow. The paper has no numbered equations or algorithm blocks. The learning-rate schedule and initialization are described in prose §2.2, and the pseudocode below is this card's reading of that prose. Figures and tables are cited by the number they get in the compiled paper.
The model is a decoder-only Transformer. The paper states the following choices §2.1 §2.2:
- ReLU activation and sequence length 2048 §2.2.
- Weights drawn from a normal distribution with mean 0 and standard deviation 0.006, with biases initialized to zero. The output-side weights of each block are scaled by 1 / sqrt(2L), where L is the number of layers §2.2.
Architecture grid tab. 1. The LaTeX source also has a commented-out 760M row, which is not part of the table:
| Model | Layers | Heads | d_model | Peak LR | Batch (tokens) |
|---|---|---|---|---|---|
| 125M | 12 | 12 | 768 | 6.0e-4 | 0.5M |
| 350M | 24 | 16 | 1024 | 3.0e-4 | 0.5M |
| 1.3B | 24 | 32 | 2048 | 2.0e-4 | 1M |
| 2.7B | 32 | 32 | 2560 | 1.6e-4 | 1M |
| 6.7B | 32 | 32 | 4096 | 1.2e-4 | 2M |
| 13B | 40 | 40 | 5120 | 1.0e-4 | 4M |
| 30B | 48 | 56 | 7168 | 1.0e-4 | 4M |
| 66B | 64 | 72 | 9216 | 0.8e-4 | 2M |
| 175B | 96 | 96 | 12288 | 1.2e-4 | 2M |
tab. 1. The text says "eight" models, but the table has nine rows §2.1 tab. 1; see Pitfalls.
The training loop, as described in words §2.2:
- Keep one global batch size for the whole run, from 0.5M to 4M tokens depending on model size tab. 1.
- Use AdamW with betas (0.9, 0.95) and weight decay 0.1 §2.2.
- Warm the learning rate linearly from 0 to its peak over the first 2000 steps for OPT-175B, or over 375M tokens for the smaller baselines §2.2.
- Decay the learning rate linearly to 10% of peak over 300B tokens §2.2.
- Apply dropout 0.1 everywhere except the embeddings, and clip the global gradient norm at 1.0 §2.2.
- Apply the mid-run changes described in §2.5: gradient clipping at 0.3 in parts of the run, learning-rate reductions, and loss-scale resets.
The learning-rate schedule as pseudocode, following the description in §2.2:
# Learning rate at a given update [§2.2] [tab. 1]
# Linear warmup, then linear decay to 10% of peak [§2.2]
def learning_rate(update, peak_lr, warmup_updates, total_updates):
# Warmup: 0 to peak over the first warmup_updates [§2.2]
if update < warmup_updates:
return peak_lr * update / warmup_updates
# Decay: linear from peak to 0.1 * peak at total_updates [§2.2]
progress = (update - warmup_updates) / (total_updates - warmup_updates)
return peak_lr - 0.9 * peak_lr * progressInitialization as pseudocode §2.2:
# Weight initialization [§2.2]
def init_weights(model, num_layers):
# Embeddings and attention/MLP input weights: N(0, 0.006^2) [§2.2]
for each input weight matrix W in model:
W = normal(mean=0.0, std=0.006)
# Output-side weights of attention and MLP: std 0.006 / sqrt(2L) [§2.2]
for each output weight matrix W in model.output_projections():
W = normal(mean=0.0, std=0.006 / sqrt(2 * num_layers))
# Biases start at zero [§2.2]
for each bias b in model:
b = 0.0Data §2.3: the corpus concatenates RoBERTa's corpus (BookCorpus, Stories and an updated CCNews v2 crawled through 28 September 2021), a subset of the Pile (CommonCrawl, DM Mathematics, Project Gutenberg, HackerNews, OpenSubtitles, OpenWebText2, USPTO and Wikipedia), and a subset of Pushshift.io Reddit. For Reddit, the authors kept only the longest comment chain in each thread, which cut that corpus by about 66%. Documents are deduplicated with MinHash LSH at Jaccard similarity 0.95 or higher. Other Pile subsets were dropped because they caused gradient-norm spikes at 1.3B scale. The text is tokenized with the GPT-2 byte-level BPE. The total is about 180B tokens §2.3. The paper adds that the Pile contains many duplicates and recommends extra deduplication for anyone using it.
Systems §2.4: training used 992 80GB A100 GPUs with Fully Sharded Data Parallel and Megatron tensor parallelism, reaching up to 147 TFLOP/s per GPU. Adam states are kept in FP32 and sharded across hosts. Weights are FP16, and dynamic loss scaling prevents underflow §2.4 fig. 1 fig. 2.
Training events §2.5: the paper reports at least 35 manual restarts and more than 100 hosts cycled out over two months due to hardware failures, and estimates 70 or more automatic restarts. For loss divergence, the team lowered the learning rate and restarted from an earlier checkpoint whose dynamic loss scale was still at least 1.0 and whose final-layer activation norm was trending down §2.5. Divergence was correlated with the loss scale collapsing to zero and with the final-layer activation norm spiking §2.5. Other attempts were a switch to vanilla SGD (abandoned), a reset of the loss scaler (helped partly), and a newer Megatron version (reduced activation-norm pressure and improved throughput) §2.5. Learning-rate and validation-perplexity curves are in fig. 1 and fig. 2.
Hyperparameters
Paper-stated values are cited to the paper. Rows marked "code only" come from the released launcher and are not stated in the paper.
| Name | Value | Where | Notes |
|---|---|---|---|
| Model sizes | 125M to 175B; see grid | tab. 1 | 9 rows in the table; "eight" in the text §2.1 |
| Layers / heads / d_model | per size | tab. 1 | 175B: 96 / 96 / 12288 |
| Activation | ReLU | §2.2 | |
| Sequence length | 2048 | §2.2 | |
| Attention / output-side init | N(0, 0.006²), output side scaled by 1/sqrt(2L) | §2.2 | |
| Biases | 0 at init | §2.2 | |
| Optimizer | AdamW | §2.2 | |
| Adam betas | (0.9, 0.95) | §2.2 | |
| Adam epsilon | 1e-8 | code only opt_baselines.py | not stated in the paper |
| Weight decay | 0.1 | §2.2 | |
| Peak learning rate | per size | tab. 1 | 175B: paper 1.2e-4; released launcher 3e-5, see Paper vs code |
| Warmup, 175B | linear over 2000 steps | §2.2 | launcher uses 375M tokens for every size, see Paper vs code |
| Warmup, smaller models | linear over 375M tokens | §2.2 | launcher implements this for all sizes |
| LR schedule | linear decay to 10% of peak | §2.2 | decay over 300B tokens |
| Total training tokens | 300B (decay horizon) | §2.2 | |
| Batch size | 0.5M to 4M tokens, constant | tab. 1 §2.2 | |
| Dropout | 0.1, not on embeddings | §2.2 | |
| Attention dropout | 0.1 | code only opt_baselines.py | the paper says dropout 0.1 "throughout" without naming attention |
| Gradient clipping | global L2 norm 1.0, lowered to 0.3 in parts of the run | §2.2 §2.5 | the 0.3 period is described, not given as a range |
| Tokenizer | GPT-2 byte-level BPE | §2.3 | |
| Position encoding | learned absolute positions, no embedding scaling | code only opt_baselines.py | the paper does not state the position scheme |
| Normalization placement | pre-LayerNorm | code only transformer_decoder_layer.py | the paper does not state it |
| Precision | FP16 weights, FP32 Adam state, dynamic loss scaling | §2.4 | |
| Hardware | 992 80GB A100 | §2.4 | |
| Corpus size | about 180B tokens | §2.3 | |
| Embedding tying | input and output embeddings shared | code only opt_baselines.py | the paper does not state it |
Results
All numbers are author-reported. The per-task zero-shot and few-shot results appear only as figures in the source, so they are described here and not tabulated.
Zero-shot and few-shot NLP §3.1 fig. 3 fig. 4 fig. 6 fig. 7. Setup: 16 standard NLP tasks, with prompts and evaluation following GPT-3 §3.1. The averages use 14 tasks, because MultiRC and WIC were removed §3.1. The paper says OPT's zero-shot average follows GPT-3's trend and that OPT roughly matched GPT-3 on 10 tasks and underperformed on ARC Challenge and MultiRC §3.1. One- and few-shot averages are similar to GPT-3 across models, but per-task behavior differs §3.1 fig. 4. The paper also reports unexplained scale effects on CB, BoolQ and WSC, where both OPT and GPT-3 sit near majority-class accuracy §3.1.
Dialogue tab. 2. Setup: greedy decoding up to 32 tokens with no prompt beyond "Person 1:" and "Person 2:" lines §3.2. Perplexity is normalized to the GPT-2 tokenizer §3.2. The OPT row is unsupervised; the other rows use BlenderBot 1's generation parameters §3.2.
| Model | Supervision | PPL ConvAI2 | PPL WW | PPL ED | PPL BST | PPL WoI | UF1 ConvAI2 | UF1 WW | UF1 ED | UF1 BST | UF1 WoI |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Reddit 2.7B | Unsup. | 18.9 | 21.0 | 11.6 | 17.4 | 18.0 | .126 | .133 | .135 | .133 | .124 |
| BlenderBot 1 | Sup. | 10.2 | 12.5 | 9.0 | 11.9 | 14.7 | .183 | .189 | .192 | .178 | .154 |
| R2C2 BlenderBot | Sup. | 10.5 | 12.4 | 9.1 | 11.7 | 14.6 | .205 | .198 | .197 | .186 | .160 |
| OPT-175B | Unsup. | 10.8 | 13.3 | 10.3 | 12.1 | 12.0 | .185 | .152 | .149 | .162 | .147 |
tab. 2. The paper reports OPT-175B on the ConvAI2 hidden test set at 10.7 perplexity and .185 UF1, and on a MultiSessionChat subset at 9.7 perplexity and .177 UF1 §3.2. It searched the pre-training corpus for the first ConvAI2 conversation and found no overlap §3.2.
Hate speech detection (ETHOS) §4.1 tab. 3. Setup: yes/no or yes/no/neither prompts, zero- to few-shot, scored by F1. "Davinci" is GPT-3 via the API.
| Setup | Davinci | OPT-175B |
|---|---|---|
| Zero-shot | .628 | .667 |
| One-shot | .616 | .713 |
| Few-shot (binary) | .354 | .759 |
| Few-shot (multiclass) | .672 | .812 |
tab. 3
CrowS-Pairs (lower is better) §4.2 tab. 4.
| Category | GPT-3 | OPT-175B |
|---|---|---|
| Gender | 62.6 | 65.7 |
| Religion | 73.3 | 68.6 |
| Race/Color | 64.7 | 68.6 |
| Sexual orientation | 76.2 | 78.6 |
| Age | 64.4 | 67.8 |
| Nationality | 61.6 | 62.9 |
| Disability | 76.7 | 76.7 |
| Physical appearance | 74.6 | 76.2 |
| Socioeconomic status | 73.8 | 76.2 |
| Overall | 67.2 | 69.5 |
tab. 4
StereoSet §4.3 tab. 5. LMS and ICAT are higher-is-better, SS is lower-is-better, and both models are normalized by token count §4.3.
| Category | Metric | Davinci | OPT-175B |
|---|---|---|---|
| Profession | LMS | 78.4 | 74.1 |
| Profession | SS | 63.4 | 62.6 |
| Profession | ICAT | 57.5 | 55.4 |
| Gender | LMS | 75.6 | 74.0 |
| Gender | SS | 66.5 | 63.6 |
| Gender | ICAT | 50.6 | 53.8 |
| Religion | LMS | 80.8 | 84.0 |
| Religion | SS | 59.0 | 59.0 |
| Religion | ICAT | 66.3 | 68.9 |
| Race | LMS | 77.0 | 74.9 |
| Race | SS | 57.4 | 56.8 |
| Race | ICAT | 65.7 | 64.8 |
| Overall | LMS | 77.6 | 74.8 |
| Overall | SS | 60.8 | 59.9 |
| Overall | ICAT | 60.8 | 60.0 |
tab. 5
RealToxicityPrompts §4.4 fig. 5. Setup: 25 continuations of 20 tokens per prompt, nucleus sampling with p = 0.9, over 10,000 sampled prompts §4.4. The paper reports that OPT has a higher toxicity rate overall than either PaLM or Davinci, and that toxicity rises with prompt toxicity for all three models §4.4 fig. 5. The figure has no numeric table in the source.
Dialogue safety §4.5 tab. 6. SaferDialogues reports PPL and F1. Unit tests report the fraction of unsafe responses across four sensitivity levels (lower is better).
| Model | SaferDialogues PPL | SaferDialogues F1 | Unit Safe | Unit Realistic | Unit Unsafe | Unit Adversarial |
|---|---|---|---|---|---|---|
| Reddit 2.7B | 16.2 | .140 | .300 | .261 | .450 | .439 |
| BlenderBot 1 | 12.4 | .161 | .028 | .150 | .250 | .194 |
| R2C2 BlenderBot | 13.8 | .160 | .022 | .133 | .289 | .222 |
| OPT-175B | 14.7 | .141 | .033 | .261 | .567 | .283 |
tab. 6
Paper vs code
Code: facebookresearch/metaseq at commit f7ffa5fd61cf90f498a36d365c13dd7f1a912ff7, MIT license. The paper links this repository for the code §6. OPT-specific configuration is in metaseq/launcher/ and projects/OPT/.
Discrepancies:
- OPT-175B peak learning rate. The paper gives 1.2e-4 tab. 1. The released launcher sets 3e-5 for the 175b size opt_job_constants.py. The launcher's values for the other sizes in the paper's table match it, including 66B at 8e-5 opt_job_constants.py. The chronicles say the learning rate was lowered several times during the 175B run, and the run is described as changing mid-flight 56_percent_update.md 27_percent_update.md. The released value may therefore not match any single phase of the run. This card does not resolve which value was used at the start of the run.
- Warmup length. The paper says 2000 steps for OPT-175B §2.2. The launcher computes warmup as 375M tokens divided by batch size for every size opt_baselines.py. For 175B that gives 178 updates, and for 125M about 715 updates. The two values differ by about an order of magnitude for the 175B model.
- Total updates. The launcher sets total updates to 300B tokens divided by batch size opt_baselines.py, which is consistent with §2.2.
- Position encoding. The paper does not describe the position scheme. The launcher uses learned absolute positional embeddings and disables embedding scaling opt_baselines.py.
- Normalization placement. The paper does not state it. The decoder layer applies LayerNorm before attention and before the MLP, adding the residual after each sub-block transformer_decoder_layer.py.
- Adam epsilon. The paper gives no epsilon. The launcher sets 1e-8 opt_baselines.py. The optimizer is decoupled AdamW, which matches §2.2 adam.py.
- Output-side initialization scaling applies only when the launcher's
--full-megatron-initflag is set opt_baselines.py. The launcher sets it, so the paper's 1/sqrt(2L) scaling is active in the released recipe utils.py multihead_attention.py. - Gradient predivide. The paper describes splitting the world-size division into two steps §2.2. The launcher does not set a predivide factor opt_baselines.py.
- Data pipeline. The paper describes MinHash deduplication §2.3. No MinHash code was found in the repository's
preprocessingfolder. The launcher reads a pre-built corpus path namedcorpus_dedup_10_10_1_0.05_exp29opt_baselines.py. - Model count. The text says "eight" models §2.1. Table 1 lists nine sizes tab. 1. The launcher also defines a 760M size that the paper's table leaves out opt_job_constants.py.
Matches, for reference: batch sizes and layer, head and width counts for all sizes; peak learning rates for all sizes except 175B; ReLU activation; AdamW with betas (0.9, 0.95) and weight decay 0.1; gradient clipping at 1.0; dropout 0.1 with no embedding dropout; linear LR decay to 10% over 300B tokens; initialization std 0.006.
Pitfalls
- The 175B learning rate has two values. Use the paper's 1.2e-4 or the released launcher's 3e-5, but say which one you chose. The paper's table and the code disagree, and the chronicles describe in-run learning-rate reductions §2.5. The logbook PDF in the repository (
projects/OPT/chronicles/OPT175B_Logbook.pdf) was not read for this card and may settle it. - The 175B warmup is either 2000 steps or 178 updates. The paper's text and the launcher disagree by an order of magnitude §2.2 opt_baselines.py.
- Mid-run changes are not in the launcher. The paper mentions reduced gradient clipping (1.0 to 0.3), learning-rate reductions, loss-scaler resets and a Megatron version change §2.2 §2.5. These are not encoded in the released launcher. The exact timing and values are in the logbook §2.5.
- Loss-spike recovery is manual. Restart from a checkpoint with loss scale at least 1.0 and falling activation norm §2.5. The paper gives no automatic rule.
- Gradient norm and loss scale are coupled. Divergence was associated with the loss scale collapsing to zero and with spikes in the final-layer activation norm §2.5. Monitoring these two quantities is the paper's only suggested early-warning signal.
- Pile subsets were dropped for stability. Subsets that caused gradient-norm spikes at 1.3B scale were removed §2.3. The exact subset choice may matter for stability.
- Attention dropout is not named in the paper. The paper says dropout 0.1 throughout, except on embeddings §2.2. The launcher applies 0.1 to attention as well opt_baselines.py. The base architecture default is 0.0 transformer_lm.py; the Megatron architecture the launcher uses sets 0.1 transformer_lm.py.
- Zero-shot averages depend on task selection. MultiRC and WIC were excluded from the averages, because the paper says these datasets seem to favor GPT-3 or OPT disproportionately §3.1. The text says "underperformed in 3 tasks" but names only ARC Challenge and MultiRC §3.1.
- GPT-3 reference numbers may not be comparable. The paper could not reproduce GPT-3's MultiRC result through the Davinci API, and it calls GPT-3's reported WIC numbers questionable §3.1. Treat cross-paper comparisons on these tasks with care.
- Small validation sets. CB has 56 examples, BoolQ 277 and WSC 104, and results on them are erratic across scale §3.1.
- The safety results are worse than GPT-3 on several measures. OPT-175B scores worse on most CrowS-Pairs categories tab. 4, higher on RealToxicityPrompts fig. 5, and worst on the Unsafe unit-test level among the dialogue models tab. 6. The paper applied no mitigations in this release §5.
- Repetition and instruction following. The paper reports that OPT often loops on greedy or sampled generation, and that declarative instructions and direct questions often produce a simulated dialogue rather than an answer §5.
- Leakage on dialogue sets is checked only partially. The paper checked one ConvAI2 conversation against the corpus and found no overlap, while noting that OPT's ConvAI2 results were surprisingly strong §3.2.
- Carbon numbers are estimates. The paper's 75 tCO2eq is its estimate for developing OPT; the authors' own estimate of total cost, including ablations, baselines and downtime, is roughly twice that §6. GPT-3's 500 tons and Gopher's 380 tons are figures the paper cites from other work §6.
- Weights are not under this card's license. The paper says access to OPT is limited to the research community under a non-commercial license §6. The repository's
projects/OPT/MODEL_LICENSE.mdis a separate Meta agreement, and the README states that use of the weights is subject to it README.md. This card covers the paper's text and code only. - Some implementation details are in the code only. Learned position embeddings, pre-LayerNorm placement, and Adam epsilon are not in the paper opt_baselines.py transformer_decoder_layer.py. An implementer working from the paper alone would get a different model.
Lineage
- Builds on: GPT-3 (arXiv:2005.14165), whose hyperparameters, prompts and few-shot evaluation setup OPT follows §2.2 §3.1. Megatron-LM model-parallel training and initialization §2.2 §2.4. The RoBERTa and Pile corpora and Pushshift Reddit for pre-training data §2.3. AdamW §2.2. Dynamic loss scaling from mixed-precision training §2.4. Fully Sharded Data Parallel §2.4.
- Compared against: GPT-3 175B (primary comparison throughout), GPT-3 via the Davinci API §3.1 §4.1. Dialogue models BlenderBot 1, R2C2 BlenderBot and Reddit 2.7B §3.2. PaLM for toxicity and dialogue §4.4 §4.5. Gopher and Chinchilla in the evaluation tables §3.1.
- Superseded by: not stated in this paper.
Source and license
Adapted from “OPT: Open Pre-trained Transformer Language Models” by Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, Todor Mihaylov, Myle Ott, Sam Shleifer, Kurt Shuster, Daniel Simig, Punit Singh Koura, Anjali Sridhar, Tianlu Wang, Luke Zettlemoyer (arXiv:2205.01068), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/facebookresearch/metaseq at commit f7ffa5fd61cf (MIT). Any quoted code is shown under that license.