我们推出了 OLMo 2 1B,它是 OLMo 2 系列中规模最小的模型。 OLMo 2 在 OLMo-mix-1124 上进行预训练,并在训练中期使用 Dolmino-mix-1124。
OLMo 2 是开源语言模型(Open Language Models)系列的最新成果,旨在助力语言模型科学研究。 我们已在 GitHub 上发布了所有代码、检查点、日志以及相关训练细节。
| 规模 | 训练 tokens | 层数 | 隐藏层大小 | 注意力头数 | 上下文长度 |
|---|---|---|---|---|---|
| OLMo 2-1B | 4 万亿 | 16 | 2048 | 16 | 4096 |
| OLMo 2-7B | 4 万亿 | 32 | 4096 | 32 | 4096 |
| OLMo 2-13B | 5 万亿 | 40 | 5120 | 40 | 4096 |
| OLMo 2-32B | 6 万亿 | 64 | 5120 | 40 | 4096 |
本次发布的核心模型包括以下内容:
OLMo 2 1B 在 transformers v4.48 或更高版本中受支持:
pip install transformers>=4.48如果使用 vLLM,在 v0.7.4 版本发布前,您需要从主分支进行安装。
您可以使用标准的 HuggingFace transformers 库来使用 OLMo:
from transformers import AutoModelForCausalLM, AutoTokenizer
olmo = AutoModelForCausalLM.from_pretrained("allenai/OLMo-2-0425-1B")
tokenizer = AutoTokenizer.from_pretrained("allenai/OLMo-2-0425-1B")
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 a key component of any text-based application, but its effectiveness...'为了获得更快的性能,您可以使用以下方法对模型进行量化:
AutoModelForCausalLM.from_pretrained("allenai/OLMo-2-0425-1B",
torch_dtype=torch.float16,
load_in_8bit=True) # Requires bitsandbytes量化模型对数据类型和 CUDA 操作更为敏感。为避免潜在问题,建议使用以下方式将输入直接传递至 CUDA:
inputs.input_ids.to('cuda')我们已发布这些模型的检查点。对于预训练,命名规范为stage1-stepXXX-tokensYYYB。对于包含“汤料”成分的检查点,命名规范为stage2-ingredientN-stepXXX-tokensYYYB
要使用HuggingFace加载特定的模型版本,只需添加参数revision:
olmo = AutoModelForCausalLM.from_pretrained("allenai/OLMo-2-0425-1B", revision="stage1-step140000-tokens294B")或者,您可以通过以下代码片段访问模型的所有修订版本:
from huggingface_hub import list_repo_refs
out = list_repo_refs("allenai/OLMo-2-0425-1B")
branches = [b.name for b in out.branches]模型微调可基于最终检查点(此模型的main修订版)或多个中间检查点进行。目前提供两种微调方案。
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更多文档,请参见 GitHub README。
olmo@allenai.org。媒体联络:press@allenai.orgOLMo 2 1B 的核心模型结果如下。
| 指令模型 | 平均值 | 浮点运算次数×10²³ | AE2 | BBH | DROP | GSM8K | IFE | MATH | MMLU | Safety | PQA | TQA |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 闭源 API 模型 | ||||||||||||
| GPT-3.5 Turbo 0125 | 60.5 | n/a | 38.7 | 66.6 | 70.2 | 74.3 | 66.9 | 41.2 | 70.2 | 69.1 | 45.0 | 62.9 |
| GPT 4o Mini 0724 | 65.7 | n/a | 49.7 | 65.9 | 36.3 | 83.0 | 83.5 | 67.9 | 82.2 | 84.9 | 39.0 | 64.8 |
| 开源权重模型 1-1.7B 参数 | ||||||||||||
| SmolLM2 1.7B | 34.2 | 1.1 | 5.8 | 39.8 | 30.9 | 45.3 | 51.6 | 20.3 | 34.3 | 52.4 | 16.4 | 45.3 |
| Gemma 3 1B | 38.3 | 1.2 | 20.4 | 39.4 | 25.1 | 35.0 | 60.6 | 40.3 | 38.9 | 70.2 | 9.6 | 43.8 |
| Llama 3.1 1B | 39.3 | 6.7 | 10.1 | 40.2 | 32.2 | 45.4 | 54.0 | 21.6 | 46.7 | 87.2 | 13.8 | 41.5 |
| Qwen 2.5 1.5B | 41.7 | 1.7 | 7.4 | 45.8 | 13.4 | 66.2 | 44.2 | 40.6 | 59.7 | 77.6 | 15.5 | 46.5 |
| 完全开源模型 | ||||||||||||
| OLMo 1B 0724 | 24.4 | 0.22 | 2.4 | 29.9 | 27.9 | 10.8 | 25.3 | 2.2 | 36.6 | 52.0 | 12.1 | 44.3 |
| OLMo 2 1B | 42.7 | 0.35 | 9.1 | 35.0 | 34.6 | 68.3 | 70.1 | 20.7 | 40.0 | 87.6 | 12.9 | 48.7 |
| OLMo 2 1B | OLMo 2 7B | OLMo 2 13B | OLMo 2 32B | |
|---|---|---|---|---|
| 预训练阶段 1 | 4 万亿 tokens (1 个 epoch) | 4 万亿 tokens (1 个 epoch) | 5 万亿 tokens (1.2 个 epochs) | 6 万亿 tokens (1.5 个 epochs) |
| 预训练阶段 2 | 500 亿 tokens | 500 亿 tokens(3 次运行) 已合并 | 1000 亿 tokens(3 次运行) 3000 亿 tokens(1 次运行) 已合并 | 1000 亿 tokens(3 次运行) 3000 亿 tokens(1 次运行) 已合并 |
| 后训练 | SFT+DPO+GRPO (偏好混合数据集) | SFT + DPO + PPO (偏好混合数据集) | SFT + DPO + PPO (偏好混合数据集) | SFT + DPO + GRPO (偏好混合数据集) |
与任何基础或微调语言模型一样,人工智能可能会被用户提示生成有害和敏感内容。此类内容也可能在无意中产生,尤其是在涉及偏差的情况下,因此我们建议用户在应用此技术时考虑相关风险。此外,OLMo 或任何大型语言模型(LLM)的许多陈述往往不准确,因此事实应予以核实。
@misc{olmo20242olmo2furious,
title={{2 OLMo 2 Furious}},
author={Team OLMo and Pete Walsh and Luca Soldaini and Dirk Groeneveld and Kyle Lo and Shane Arora and Akshita Bhagia and Yuling Gu and Shengyi Huang and Matt Jordan and Nathan Lambert and Dustin Schwenk and Oyvind Tafjord and Taira Anderson and David Atkinson and Faeze Brahman and Christopher Clark and Pradeep Dasigi and Nouha Dziri and Michal Guerquin and Hamish Ivison and Pang Wei Koh and Jiacheng Liu and Saumya Malik and William Merrill and Lester James V. Miranda and Jacob Morrison and Tyler Murray and Crystal Nam and Valentina Pyatkin and Aman Rangapur and Michael Schmitz and Sam Skjonsberg and David Wadden and Christopher Wilhelm and Michael Wilson and Luke Zettlemoyer and Ali Farhadi and Noah A. Smith and Hannaneh Hajishirzi},
year={2024},
eprint={2501.00656},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2501.00656},
}若本模型卡片存在错误,请联系 olmo@allenai.org。