HuggingFace镜像/OLMo-2-1124-7B
模型介绍文件和版本分析
下载使用量0

模型详情

OLMo Logo

OLMo 2 7B 模型卡片

我们推出了 OLMo 2 系列模型,包括 7B 和 13B 版本。与原始 OLMo 7B 模型相比,该系列模型在 MMLU 评测中得分提升了 9 个百分点,其他评测指标也有所改善。这些性能提升得益于在 OLMo-mix-1124 和 Dolmino-mix-1124 数据集上的训练以及分阶段训练方法。

OLMo 是一系列开源语言模型(Open Language Models),旨在推动语言模型科学研究。这些模型均在 Dolma 数据集上训练。我们将发布所有代码、检查点、日志(即将推出)以及相关训练细节。

模型规模训练 tokens层数隐藏层大小注意力头数上下文长度
OLMo 2-7B4 万亿324096324096
OLMo 2-13B5 万亿405120404096

本次发布的核心模型包括以下版本:

阶段OLMo 2 7BOLMo 2 13B
基础模型allenai/OLMo-2-1124-7Ballenai/OLMo-2-1124-13B
监督微调(SFT)allenai/OLMo-2-1124-7B-SFTallenai/OLMo-2-1124-13B-SFT
直接偏好优化(DPO)allenai/OLMo-2-1124-7B-DPOallenai/OLMo-2-1124-13B-DPO
最终模型(RLVR)allenai/OLMo-2-1124-7B-Instructallenai/OLMo-2-1124-13B-Instruct
奖励模型(RM)allenai/OLMo-2-1124-7B-RM(与 7B 版本相同)

安装

OLMo 2 将在 Transformers 的下一个版本中得到支持,您需要通过以下方式从主分支进行安装:

pip install --upgrade git+https://github.com/huggingface/transformers.git

推理

您可以通过标准的 HuggingFace transformers 库使用 OLMo:

from transformers import AutoModelForCausalLM, AutoTokenizer
olmo = AutoModelForCausalLM.from_pretrained("allenai/OLMo-2-1124-7B")
tokenizer = AutoTokenizer.from_pretrained("allenai/OLMo-2-1124-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  a key component of any text-based application, but its effectiveness...'

为了获得更快的性能,您可以使用以下方法对模型进行量化:

AutoModelForCausalLM.from_pretrained("allenai/OLMo-2-1124-7B", 
    torch_dtype=torch.float16, 
    load_in_8bit=True)  # Requires bitsandbytes

量化模型对数据类型和 CUDA 操作更为敏感。为避免潜在问题,建议使用以下方式将输入直接传递至 CUDA:

inputs.input_ids.to('cuda')

我们已发布这些模型的检查点。对于预训练,命名规则为stepXXX-tokensYYYB。对于包含混合成分的检查点,命名规则为stage2-ingredientN-stepXXX-tokensYYYB。

要使用HuggingFace加载特定的模型版本,只需添加参数revision:

olmo = AutoModelForCausalLM.from_pretrained("allenai/OLMo-2-1124-7B", revision="step1000-tokens5B")

或者,您可以通过以下代码片段访问模型的所有修订版本:

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

微调

模型微调可基于最终检查点(此模型的main修订版)或多个中间检查点进行。目前提供两种微调方案。

  1. 使用OLMo代码库进行微调:
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 自述文件。

  1. AI2 的 Open Instruct 代码库正在开发进一步的微调支持。详情请见 此处。

模型描述

  • 开发机构: Allen Institute for AI (Ai2)
  • 模型类型: Transformer 风格的自回归语言模型。
  • 语言(自然语言处理): 英语
  • 许可证: 代码和模型均基于 Apache 2.0 许可证发布。
  • 联系方式: 技术咨询:olmo@allenai.org。媒体联络:press@allenai.org
  • 数据截止日期: 2023 年 12 月。

模型来源

  • 项目页面: https://allenai.org/olmo
  • 代码库:
    • 核心代码库(训练、推理、微调等):https://github.com/allenai/OLMo
    • 评估代码:https://github.com/allenai/OLMo-Eval
    • 进一步微调代码:https://github.com/allenai/open-instruct
  • 论文: https://arxiv.org/abs/2501.00656

评估

OLMo 2 7B 和 13B 模型的核心模型结果如下。

模型训练 FLOPs平均值ARC/CHSwagWinoGMMLUDROPNQAGIEvalGSM8kMMLUProTriviaQA
开源权重模型:
Llama-2-13B1.6·10²³54.167.383.974.955.745.638.441.528.123.981.3
Mistral-7B-v0.3n/a58.878.383.177.763.551.837.247.340.13079.3
Llama-3.1-8B7.2·10²³61.879.581.676.666.956.433.951.356.534.780.3
Mistral-Nemo-12Bn/a66.985.285.681.569.569.239.754.762.136.784.6
Qwen-2.5-7B8.2·10²³67.489.589.774.274.455.829.963.781.545.869.4
Gemma-2-9B4.4·10²³67.889.587.378.870.6633857.370.14281.8
Qwen-2.5-14B16.0·10²³72.294948079.351.537.37183.452.879.1
部分开源模型:
StableLM-2-12B2.9·10²³62.281.984.577.762.455.537.650.96229.379.9
Zamba-2-7Bn/c65.292.289.479.668.551.736.555.567.232.878.8
完全开源模型:
Amber-7B0.5·10²³35.244.974.565.524.726.118.721.84.811.759.3
OLMo-7B1.0·10²³38.346.478.168.528.327.324.823.79.212.164.1
MAP-Neo-7B2.1·10²³49.678.472.869.25839.428.945.812.525.965.1
OLMo-0424-7B0.9·10²³50.766.980.173.654.35029.643.927.722.158.8
DCLM-7B1.0·10²³56.979.882.377.364.439.328.847.546.131.372.1
OLMo-2-1124-7B1.8·10²³62.979.883.877.263.760.836.950.467.53178
OLMo-2-1124-13B4.6·10²³68.383.586.481.567.570.746.754.275.135.181.9

模型详情

预训练

OLMo 2 7BOLMo 2 13B
预训练阶段 1
(OLMo-Mix-1124)
4 万亿 tokens
(1 个 epoch)
5 万亿 tokens
(1.2 个 epochs)
预训练阶段 2
(Dolmino-Mix-1124)
500 亿 tokens(3 次运行)
已合并
1000 亿 tokens(3 次运行)
3000 亿 tokens(1 次运行)
已合并
后训练
(Tulu 3 SFT OLMo mix)
SFT + DPO + PPO
(偏好混合数据集)
SFT + DPO + PPO
(偏好混合数据集)

阶段 1:初始预训练

  • 数据集:OLMo-Mix-1124(3.9 万亿 tokens)
  • 覆盖范围:总预训练预算的 90% 以上
  • 7B 模型:约 1 个 epoch
  • 13B 模型:1.2 个 epochs(5 万亿 tokens)

阶段 2:微调

  • 数据集:Dolmino-Mix-1124(8430 亿 tokens)
  • 三种训练混合:
    • 500 亿 tokens
    • 1000 亿 tokens
    • 3000 亿 tokens
  • 混合组成:50% 高质量数据 + 学术/问答/指令/数学内容

模型合并

  • 7B 模型:3 个基于 500 亿混合数据训练的版本,通过模型融合(model souping)合并
  • 13B 模型:3 个基于 1000 亿混合数据的版本 + 1 个基于 3000 亿混合数据的版本,合并为最终检查点

偏差、风险与局限性

与任何基础语言模型或未经安全过滤的微调模型一样,这些模型很容易被用户提示生成有害和敏感内容。此类内容也可能非故意产生,尤其是在涉及偏差的情况下,因此我们建议用户在应用此技术时考虑相关风险。此外,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。