Stable LM 2 12BStable LM 2 12B 是一个拥有121亿参数的仅解码器语言模型,它在包含2万亿tokens的多样化多语言及代码数据集上进行了两轮预训练。
请注意:商业用途请参考 https://stability.ai/membership。
注意:本模型需要 transformers>=4.40.0
通过以下代码片段开始使用 Stable LM 2 12B 生成文本:
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("stabilityai/stablelm-2-12b")
model = AutoModelForCausalLM.from_pretrained(
"stabilityai/stablelm-2-12b",
torch_dtype="auto",
)
model.cuda()
inputs = tokenizer("The weather is always wonderful", return_tensors="pt").to(model.device)
tokens = model.generate(
**inputs,
max_new_tokens=64,
temperature=0.70,
top_p=0.95,
do_sample=True,
)
print(tokenizer.decode(tokens[0], skip_special_tokens=True))from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("stabilityai/stablelm-2-12b")
model = AutoModelForCausalLM.from_pretrained(
"stabilityai/stablelm-2-12b",
torch_dtype="auto",
attn_implementation="flash_attention_2",
)
model.cuda()
inputs = tokenizer("The weather is always wonderful", return_tensors="pt").to(model.device)
tokens = model.generate(
**inputs,
max_new_tokens=64,
temperature=0.70,
top_p=0.95,
do_sample=True,
)
print(tokenizer.decode(tokens[0], skip_special_tokens=True))Stable LM 2 12B 模型是基于 Transformer 解码器架构的自回归语言模型。lm@stability.ai该模型是一个仅含解码器的 Transformer,其架构如下:
| 参数数量 | 隐藏层大小 | 层数 | 注意力头数 | KV 头数 | 序列长度 |
|---|---|---|---|---|---|
| 12,143,605,760 | 5120 | 40 | 32 | 8 | 4096 |
tiktoken.cl100k_base 扩展的 BPE 分词器。根据 Liu & Low (2023) 的研究结果,我们将数字拆分为单独的 tokens。该数据集由 HuggingFace Hub 上可用的开源大规模数据集的过滤混合组成:Falcon RefinedWeb 提取版(Penedo et al., 2023)、RedPajama-Data(Together Computer., 2023)和 The Pile(Gao et al., 2020)(后两者均不含 Books3 子集),以及 StarCoder(Li et al., 2023)。我们进一步使用来自 CulturaX(Nguyen et al., 2023)的多语言数据(特别是其 OSCAR 语料库)以及 Yuan & Liu (2022) 风格的重组数据来补充我们的训练。
Stable LM 2 12B 进行微调。该模型在上述数据集上以 bfloat16 精度进行预训练,使用 AdamW 优化器,并采用 Arcade100k 分词器(词汇量为 100,352)进行训练。完整的超参数选择详情,请参见项目的 GitHub 仓库 - config*。
硬件:Stable LM 2 12B 的训练在 Stability AI 集群上进行,该集群包含 384 块 NVIDIA H100 GPU(AWS P5 实例)。
软件:我们使用 gpt-neox 的一个分支(EleutherAI, 2021),在 2D 并行(数据并行和张量并行)模式下进行训练,并结合 ZeRO-1(Rajbhandari et al., 2019),同时依赖 flash-attention 以及 FlashAttention-2(Dao et al., 2023)中的 SwiGLU 和 Rotary Embedding 内核。
该模型旨在用作特定应用微调的基础模型。开发人员必须对模型进行评估和微调,以确保其在下游应用中安全运行。商业用途请参考 https://stability.ai/membership。
作为基础模型,本模型可能会表现出不可靠、不安全或其他不良行为,在部署前必须通过评估和微调进行纠正。尽管已应用数据清洗过滤器,预训练数据集仍可能包含冒犯性或不适当内容,这些内容可能会在模型生成的文本中体现。我们建议用户在生产系统中使用这些模型时保持谨慎。如果模型不适合您的应用,或者可能对他人造成故意或非故意伤害的任何应用,请勿使用。
@article{bellagente2024stable,
title={Stable LM 2 1.6 B Technical Report},
author={Bellagente, Marco and Tow, Jonathan and Mahan, Dakota and Phung, Duy and Zhuravinskyi, Maksym and Adithyan, Reshinth and Baicoianu, James and Brooks, Ben and Cooper, Nathan and Datta, Ashish and others},
journal={arXiv preprint arXiv:2402.17834},
year={2024}
}