allenai/OLMo-7B

By allenai

🎯 Task: Text Generation⚖️ apache-2.0📦 transformers

Model Card

mof-class1-qualified

OLMo Logo

Model Card for OLMo 7B

For transformers versions v4.40.0 or newer, we suggest using OLMo 7B HF instead.

OLMo is a series of Open Language Models designed to enable the science of language models. The OLMo models are trained on the Dolma dataset. We release all code, checkpoints, logs (coming soon), and details involved in training these models.

A new version of this model with a 24 point improvement on MMLU is available here.

Model Details

The core models released in this batch are the following:

SizeTraining TokensLayersHidden SizeAttention HeadsContext Length
OLMo 1B3 Trillion162048162048
OLMo 7B2.5 Trillion324096322048
OLMo 7B Twin 2T2 Trillion324096322048

We are releasing many checkpoints for these models, for every 1000 traing steps. The naming convention is step1000-tokens4B. In particular, we focus on four revisions of the 7B models:

NameHF RepoModel RevisionTokensNote
OLMo 7Ballenai/OLMo-7Bmain2.5TThe base OLMo 7B model
OLMo 7B (not annealed)allenai/OLMo-7Bstep556000-tokens2460B2.5Tlearning rate not annealed to 0
OLMo 7B-2Tallenai/OLMo-7Bstep452000-tokens2000B2TOLMo checkpoint at 2T tokens
OLMo-7B-Twin-2Tallenai/OLMo-7B-Twin-2Tmain2TTwin version on different hardware

To load a specific model revision with HuggingFace, simply add the argument revision:

from hf_olmo import OLMoForCausalLM  # pip install ai2-olmo

olmo = OLMoForCausalLM.from_pretrained("allenai/OLMo-7B", revision="step1000-tokens4B")

All revisions/branches are listed in the file revisions.txt. Or, you can access all the revisions for the models via the following code snippet:

from huggingface_hub import list_repo_refs
out = list_repo_refs("allenai/OLMo-7B")
branches = [b.name for b in out.branches]

A few revisions were lost due to an error, but the vast majority are present.

Model Description

  • Developed by: Allen Institute for AI (AI2)
  • Supported by: Databricks, Kempner Institute for the Study of Natural and Artificial Intelligence at Harvard University, AMD, CSC (Lumi Supercomputer), UW
  • Model type: a Transformer style autoregressive language model.
  • Language(s) (NLP): English
  • License: The code and model are released under Apache 2.0.
  • Contact: Technical inquiries: olmo at allenai dot org. Press: press at allenai dot org
  • Date cutoff: Feb./March 2023 based on Dolma dataset version.

Model Sources

Uses

Inference

Quickly get inference running with the following required installation:

pip install ai2-olmo

Now, proceed as usual with HuggingFace:

from hf_olmo import OLMoForCausalLM, OLMoTokenizerFast

olmo = OLMoForCausalLM.from_pretrained("allenai/OLMo-7B")
tokenizer = OLMoTokenizerFast.from_pretrained("allenai/OLMo-7B")
message = ["Language modeling is"]
inputs = tokenizer(message, return_tensors='pt', return_token_type_ids=False)
# optional verifying cuda
# inputs = {k: v.to('cuda') for k,v in inputs.items()}
# olmo = olmo.to('cuda')
response = olmo.generate(**inputs, max_new_tokens=100, do_sample=True, top_k=50, top_p=0.95)
print(tokenizer.batch_decode(response, skip_special_tokens=True)[0])
>> 'Language modeling is the first step to build natural language generation...'

You can make this slightly faster by quantizing the model, e.g. AutoModelForCausalLM.from_pretrained("allenai/OLMo-7B", torch_dtype=torch.float16, load_in_8bit=True) (requires bitsandbytes). The quantized model is more sensitive to typing / cuda, so it is recommended to pass the inputs as inputs.input_ids.to('cuda') to avoid potential issues.

Note, you may see the following error if ai2-olmo is not installed correctly, which is caused by internal Python check naming. We'll update the code soon to make this error clearer.

    raise ImportError(
ImportError: This modeling file requires the following packages that were not found in your environment: hf_olmo. Run `pip install hf_olmo`

Fine-tuning

Model fine-tuning can be done from the final checkpoint (the main revision of this model) or many intermediate checkpoints. Two recipes for tuning are available.

  1. Fine-tune with the OLMo repository:
torchrun --nproc_per_node=8 scripts/train.py {path_to_train_config} \
    --data.paths=[{path_to_data}/input_ids.npy] \
    --data.label_mask_paths=[{path_to_data}/label_mask.npy] \
    --load_path={path_to_checkpoint} \
    --reset_trainer_state

For more documentation, see the GitHub readme.

  1. Further fine-tuning support is being developing in AI2's Open Instruct repository. Details are here.

Evaluation

Core model results for the 7B model are found below.

Llama 7BLlama 2 7BFalcon 7BMPT 7BOLMo 7B (ours)
arc_challenge44.539.847.546.548.5
arc_easy57.057.770.470.565.4
boolq73.173.574.674.273.4
copa85.087.086.085.090
hellaswag74.574.575.977.676.4
openbookqa49.848.453.048.650.2
piqa76.376.478.577.378.4
sciq89.590.893.993.793.8
winogrande68.267.368.969.967.9
Core tasks average68.768.472.171.571.6
truthfulQA (MC2)33.938.534.03336.0
MMLU (5 shot MC)31.545.024.030.828.3
GSM8k (mixed eval.)10.0 (8shot CoT)12.0 (8shot CoT)4.0 (5 shot)4.5 (5 shot)8.5 (8shot CoT)
Full average57.859.359.259.359.8

And for the 1B model:

taskrandomStableLM 2 1.6b*Pythia 1BTinyLlama 1.1BOLMo 1B (ours)
arc_challenge2543.8133.1134.7834.45
arc_easy2563.6850.1853.1658.07
boolq5076.661.864.660.7
copa5084727879
hellaswag2568.244.758.762.5
openbookqa2545.837.843.646.4
piqa507469.171.173.7
sciq2594.78690.588.1
winogrande5064.953.358.958.9
Average36.1168.4156.4461.4862.42

*Unlike OLMo, Pythia, and TinyLlama, StabilityAI has not disclosed yet the data StableLM was trained on, making comparisons with other efforts challenging.

Model Details

Data

For training data details, please see the Dolma documentation.

Architecture

OLMo 7B architecture with peer models for comparison.

OLMo 7BLlama 2 7BOpenLM 7BFalcon 7BPaLM 8B
d_model40964096409645444096
num heads3232327116
num layers3232323232
MLP ratio~8/3~8/3~8/344
LayerNorm typenon-parametric LNRMSNormparametric LNparametric LNparametric LN
pos embeddingsRoPERoPERoPERoPERoPE
attention variantfullGQAfullMQAMQA
biasesnonenonein LN onlyin LN onlynone
block typesequentialsequentialsequentialparallelparallel
activationSwiGLUSwiGLUSwiGLUGeLUSwiGLU
sequence length20484096204820482048
batch size (instances)2160102420482304512
batch size (tokens)~4M~4M~4M~4M~1M
weight tyingnonononoyes

Hyperparameters

AdamW optimizer parameters are shown below.

SizePeak LRBetasEpsilonWeight Decay
1B4.0E-4(0.9, 0.95)1.0E-50.1
7B3.0E-4(0.9, 0.99)1.0E-50.1

Optimizer settings comparison with peer models.

OLMo 7BLlama 2 7BOpenLM 7BFalcon 7B
warmup steps5000200020001000
peak LR3.0E-043.0E-043.0E-046.0E-04
minimum LR3.0E-053.0E-053.0E-051.2E-05
weight decay0.10.10.10.1
beta10.90.90.90.99
beta20.950.950.950.999
epsilon1.0E-051.0E-051.0E-051.0E-05
LR schedulelinearcosinecosinecosine
gradient clippingglobal 1.0global 1.0global 1.0global 1.0
gradient reduce dtypeFP32FP32FP32BF16
optimizer state dtypeFP32most likely FP32FP32FP32

Environmental Impact

OLMo 7B variants were either trained on MI250X GPUs at the LUMI supercomputer, or A100-40GB GPUs provided by MosaicML. A summary of the environmental impact. Further details are available in the paper.

GPU TypePower Consumption From GPUsCarbon Intensity (kg CO₂e/KWh)Carbon Emissions (tCO₂eq)
OLMo 7B TwinMI250X (LUMI supercomputer)135 MWh0*0*
OLMo 7BA100-40GB (MosaicML)104 MWh0.65675.05

Bias, Risks, and Limitations

Like any base language model or fine-tuned model without safety filtering, it is relatively easy for a user to prompt these models to generate harmful and generally sensitive content. Such content can also be produced unintentionally, especially in the case of bias, so we recommend users consider the risks of applications of this technology.

Otherwise, many facts from OLMo or any LLM will often not be true, so they should be checked.

Citation

BibTeX:

@article{Groeneveld2023OLMo,
  title={OLMo: Accelerating the Science of Language Models},
  author={Groeneveld, Dirk and Beltagy, Iz and Walsh, Pete and Bhagia, Akshita and Kinney, Rodney and Tafjord, Oyvind and Jha, Ananya Harsh and Ivison, Hamish and Magnusson, Ian and Wang, Yizhong and Arora, Shane and Atkinson, David and Authur, Russell and Chandu, Khyathi and Cohan, Arman and Dumas, Jennifer and Elazar, Yanai and Gu, Yuling and Hessel, Jack and Khot, Tushar and Merrill, William and Morrison, Jacob and Muennighoff, Niklas and Naik, Aakanksha and Nam, Crystal and Peters, Matthew E. and Pyatkin, Valentina and Ravichander, Abhilasha and Schwenk, Dustin and Shah, Saurabh and Smith, Will and Subramani, Nishant and Wortsman, Mitchell and Dasigi, Pradeep and Lambert, Nathan and Richardson, Kyle and Dodge, Jesse and Lo, Kyle and Soldaini, Luca and Smith, Noah A. and Hajishirzi, Hannaneh},
  journal={Preprint},
  year={2024}
}

APA:

Groeneveld, D., Beltagy, I., Walsh, P., Bhagia, A., Kinney, R., Tafjord, O., Jha, A., Ivison, H., Magnusson, I., Wang, Y., Arora, S., Atkinson, D., Authur, R., Chandu, K., Cohan, A., Dumas, J., Elazar, Y., Gu, Y., Hessel, J., Khot, T., Merrill, W., Morrison, J., Muennighoff, N., Naik, A., Nam, C., Peters, M., Pyatkin, V., Ravichander, A., Schwenk, D., Shah, S., Smith, W., Subramani, N., Wortsman, M., Dasigi, P., Lambert, N., Richardson, K., Dodge, J., Lo, K., Soldaini, L., Smith, N., & Hajishirzi, H. (2024). OLMo: Accelerating the Science of Language Models. Preprint.

Model Card Contact

For errors in this model card, contact Nathan or Akshita, {nathanl, akshitab} at allenai dot org.

Architecture & Tags

transformerspytorchsafetensorshf_olmotext-generationcustom_codeenautotrain_compatibleregion:us