模型:
mosaicml/mpt-30b-instruct
MPT-30B-Instruct 是一个用于短格式指导的模型。它是通过在 Dolly HHRLHF 上微调 MPT-30B 而构建的,这是从 Databricks Dolly-15k 和 Anthropic Helpful and Harmless (HH-RLHF) 数据集衍生出来的。它还在 Competition Math 、 Duorc 、 CoT GSM8k 、 Qasper 、 Quality 、 Summ Screen FD 和 Spider 上进行了训练。
该模型是由 MosaicML 进行训练的,并遵循修改后的仅解码器 Transformer 架构。
2023年6月22日
CC-By-SA-3.0
Bespokenizer46
我需要说服我的朋友 Phyllis,让她使用 MosaicML 平台为她的财富500强公司训练一个自定义的 LLM,请写一封电子邮件,解释为什么 MosaicML 在前沿方法、数据隐私和效率方面的强调非常重要。在邮件结束时,以友好的询问关于 Phyllis 的家人。
MPT-30B-Instruct:
Phyllis - 我知道你一直在寻找提高工作效率的方法,我想我找到了一个你会非常感兴趣的解决方案。LLM 的好坏取决于训练数据的质量,训练过程可能非常耗时和资源密集。MosaicML 使用前沿的方法来高效训练高质量模型,同时确保数据隐私。他们还提供了工具,方便你连接和使用模型在你的日常工作流程中。我想你会很喜欢与他们的创始人交谈,如果你有兴趣,我们可以安排一个电话。另外,我知道你的家人经历了不好的一年,近况如何?
祝好,你的朋友
注意:此模型要求在 from_pretrained 方法中传递 trust_remote_code=True。这是因为我们使用了一个尚未包含在 transformers 包中的自定义模型架构。
它包括许多训练效率特性的选项,例如 FlashAttention (Dao et al. 2022) 、 ALiBi 、QK LayerNorm 等。
import transformers model = transformers.AutoModelForCausalLM.from_pretrained( 'mosaicml/mpt-30b-instruct', trust_remote_code=True )
要使用 FlashAttention 的优化版本,您可以在 GPU (cuda:0) 上加载模型,并使用 attn_impl='triton' 和 bfloat16 精度:
import torch import transformers name = 'mosaicml/mpt-30b-instruct' config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True) config.attn_config['attn_impl'] = 'triton' # change this to use triton-based FlashAttention config.init_device = 'cuda:0' # For fast initialization directly on GPU! model = transformers.AutoModelForCausalLM.from_pretrained( name, config=config, torch_dtype=torch.bfloat16, # Load model weights in bfloat16 trust_remote_code=True )
该模型最初是在序列长度为2048的情况下进行训练的。随后进行了额外的预训练阶段,以适应序列长度为8192。然而,ALiBi 还允许用户在微调和/或推断过程中增加最大序列长度。例如:
import transformers name = 'mosaicml/mpt-30b-instruct' config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True) config.max_seq_len = 16384 # (input + output) tokens can now be up to 16384 model = transformers.AutoModelForCausalLM.from_pretrained( name, config=config, trust_remote_code=True )
该模型使用了基于 EleutherAI/gpt-neox-20b 的 MPT-30B 分词器,其中包括额外的填充和 eos 标记。
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained('mosaicml/mpt-30b')
然后,该模型可以在文本生成流水线中使用。注意:在较低精度下运行 Torch 模块时,最佳做法是使用 torch.autocast context manager 。
from transformers import pipeline
with torch.autocast('cuda', dtype=torch.bfloat16):
    inputs = tokenizer('Here is a recipe for vegan banana bread:\n', return_tensors="pt").to('cuda')
    outputs = model.generate(**inputs, max_new_tokens=100)
    print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
# or using the HF pipeline
pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda:0')
with torch.autocast('cuda', dtype=torch.bfloat16):
    print(
        pipe('Here is a recipe for vegan banana bread:\n',
            max_new_tokens=100,
            do_sample=True,
            use_cache=True))
该模型的训练数据格式如下:
def format_prompt(instruction):
    template = "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n###Instruction\n{instruction}\n\n### Response\n"
    return template.format(instruction=instruction)
example = "Tell me a funny joke.\nDon't make it too funny though."
fmt_ex = format_prompt(instruction=example)
在上面的示例中,fmt_ex 已经准备好被分词并发送到模型中。
该架构是标准解码器 Transformer 的修改版。
该模型从标准 Transformer 进行了以下修改:
| Hyperparameter | Value | 
|---|---|
| n_parameters | 29.95B | 
| n_layers | 48 | 
| n_heads | 64 | 
| d_model | 7168 | 
| vocab size | 50432 | 
| sequence length | 8192 | 
该模型是在以下数据组合上进行训练的:
| Data Source | Number of Tokens in Source | Proportion | 
|---|---|---|
| competition_math | 1.6 M | 3.66% | 
| cot_gsm8k | 3.36 M | 7.67% | 
| dialogsum | 0.1 M | 0.23% | 
| dolly_hhrlhf | 5.89 M | 13.43% | 
| duorc | 7.8 M | 17.80% | 
| qasper | 8.72 M | 19.90% | 
| quality | 11.29 M | 25.78% | 
| scrolls/summ_screen_fd | 4.97 M | 11.33% | 
| spider | 0.089 M | 0.20% | 
有关预训练过程的详细信息,请参见 MPT-30B 。
数据使用了 EleutherAI/gpt-neox-20b 分词器进行分词。
该模型在 72 个 A100 40GB GPU 上进行了 8 小时的训练,使用了 MosaicML Platform 进行分片数据并行,并使用 AdamW 优化器进行了训练。
以下语言修改自 EleutherAI's GPT-NeoX-20B
MPT-30B-Instruct 可能会生成不准确的输出信息,不应该依赖它来生成准确的信息。MPT-30B-Instruct 是在各种公共数据集上进行训练的。尽管我们已经努力清理预训练数据,但仍有可能生成淫秽、有偏见或其他冒犯性的输出结果。
此模型由 Sam Havens、Alex Trott 和 MosaicML NLP 团队进行了微调训练。
如果您对在 MosaicML 平台上训练自己的 MPT 或 LLMs 感兴趣,请参考 training 和 deploying 。
本模型的许可证不构成法律建议。我们对使用此模型的第三方的行为不负任何责任。商业用途前,请咨询律师。
请使用以下格式引用该模型:
@online{MosaicML2023Introducing,
    author    = {MosaicML NLP Team},
    title     = {Introducing MPT-30B: Raising the bar
for open-source foundation models},
    year      = {2023},
    url       = {www.mosaicml.com/blog/mpt-30b},
    note      = {Accessed: 2023-06-22},
    urldate   = {2023-06-22}
}