Text Generation
Transformers
PyTorch
Safetensors
English
hf_olmo
conversational
custom_code
OLMo-7B-Instruct / README.md
jacobmorrison's picture
Update README.md
2d50cde verified
|
raw
history blame
11.3 kB
metadata
license: apache-2.0
datasets:
  - allenai/dolma
  - allenai/tulu-v2-sft-mixture
  - allenai/ultrafeedback_binarized_cleaned
language:
  - en
OLMo Logo

Model Card for OLMo 7B Instruct

OLMo is a series of Open Language Models designed to enable the science of language models. The OLMo base models are trained on the Dolma dataset. The adapted versions are trained on the Tulu SFT mixture and, for the Instruct version, a cleaned version of the UltraFeedback dataset. We release all code, checkpoints, logs (coming soon), and details involved in training these models.

OLMo 7B Instruct and OLMo SFT are two adapted versions of these models trained for better question answering. They show the performance gain that OLMo base models can achieve with existing fine-tuning techniques.

Model Details

We release two adapted model versions: The base models related to this adapted model are the following:

Model Training Method(s) Datasets Context Length
OLMo 7B SFT SFT Tulu 2 SFT Mix 2048
OLMo 7B Instruct SFT + DPO Tulu 2 SFT Mix + Ultrafeedback Cleaned 2048

The base models related to this adapted model are the following:

Size Training Tokens Layers Hidden Size Attention Heads Context Length
OLMo 1B 3 Trillion 16 2048 16 2048
OLMo 7B 2.5 Trillion 32 4096 32 2048
OLMo 7B Twin 2T 2 Trillion 32 4096 32 2048

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:

import hf_olmo

from transformers import AutoModelForCausalLM, AutoTokenizer
olmo = AutoModelForCausalLM.from_pretrained("allenai/OLMo-7B-Instruct")
tokenizer = AutoTokenizer.from_pretrained("allenai/OLMo-7B-Instruct")
chat = [
    { "role": "user", "content": "What is language modeling?" },
]
prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
# optional verifying cuda
# inputs = {k: v.to('cuda') for k,v in inputs.items()}
# olmo = olmo.to('cuda')
response = olmo.generate(input_ids=inputs.to(olmo.device), max_new_tokens=100, do_sample=True, top_k=50, top_p=0.95)
print(tokenizer.batch_decode(response, skip_special_tokens=True)[0])
>> '<|user|>\nWhat is language modeling?\n<|assistant|>\nLanguage modeling is a type of natural language processing (NLP) task or machine learning task that...'

Alternatively, with the pipeline abstraction:

import hf_olmo

from transformers import pipeline
olmo_pipe = pipeline("text-generation", model="allenai/OLMo-7B-Instruct")
print(olmo_pipe("What is language modeling?"))
>> '[{'generated_text': 'What is language modeling?\nLanguage modeling is a type of natural language processing (NLP) task...'}]'

Or, you can make this slightly faster by quantizing the model, e.g. AutoModelForCausalLM.from_pretrained("allenai/OLMo-7B-Instruct", 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`

Evaluation

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

Model MMLU 0-shot ↑ AlpacaEval %win ↑ ToxiGen % Toxic ↓ TruthfulQA %Info+True ↑
OLMo (base) 28.3 - 81.4 31.6
MPT Chat 33.8 46.8 0.1 42.7
Falcon Instruct 25.2 14.0 70.7 27.2
RPJ-INCITE Chat 27.0 38.0 46.4 53.0
Llama-2-Chat 7B 46.8 87.3 0.0 26.3
AI2 Tulu 2 7B 50.4 73.9 7.0 51.7
AI2 Tulu 2 7B DPO 50.7 85.1 0.5 - *
OLMo 7B SFT 47.3 57.0 14.4 41.2
OLMo 7B Instruct 46.2 69.3 1.7 52.0

*Following Ivision et al. 2023, we do not report Tulu 2 TruthfulQA scores due to test set contamination.

Model Details

Data

For training data details, please see the Dolma, Tulu 2, and UltraFeedback documentation.

Architecture

Hyperparameters

The hyperparameters for the two phases of training are below. Certainly! Here's the table with SFT and DPO as rows:

Learning Rate Beta Epochs Warmup Weight Decay Gradient Clipping Maximum Sequence Length
SFT 2 × 10^-6 N/A 3 Linear warmup for the first 3% of total training time, then cooldown to 0 0 0 2048
DPO 5 × 10^-7 0.1 3 Linear warmup for the first 10% of total training time, then cooldown to 0 0 0 2048

Compared to Tulu 2, DPO hyperparameters are the same. SFT is lower LR and 3 epochs instead of 2 (and 2k length instead of 8k).

Bias, Risks, and Limitations

The adapted OLMo models do not include a specific safety filter or safety training data. While our model shows good scores relative to its peers on ToxiGen, 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 Jacob, {nathanl, jacobm} at allenai dot org.