Views
No views yet
1import transformers
2model = transformers.AutoModelForCausalLM.from_pretrained(
3 'mosaicml/mpt-7b-instruct-8k',
4 trust_remote_code=True
5)trust_remote_code=True be passed to the from_pretrained method.
This is because we use a custom MPT model architecture that is not yet part of the Hugging Face transformers package.
MPT includes options for many training efficiency features such as FlashAttention, ALiBi, QK LayerNorm, and more.cuda:0) with attn_impl='triton' and with bfloat16 precision:1import torch
2import transformers
3
4name = 'mosaicml/mpt-7b-instruct-8k'
5
6config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
7config.attn_config['attn_impl'] = 'triton' # change this to use triton-based FlashAttention
8config.init_device = 'cuda:0' # For fast initialization directly on GPU!
9
10model = transformers.AutoModelForCausalLM.from_pretrained(
11 name,
12 config=config,
13 torch_dtype=torch.bfloat16, # Load model weights in bfloat16
14 trust_remote_code=True
15)1import transformers
2
3name = 'mosaicml/mpt-7b-instruct-8k'
4
5config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
6config.max_seq_len = 16384 # (input + output) tokens can now be up to 16384
7
8model = transformers.AutoModelForCausalLM.from_pretrained(
9 name,
10 config=config,
11 trust_remote_code=True
12)1from transformers import AutoTokenizer
2tokenizer = AutoTokenizer.from_pretrained('mosaicml/mpt-7b-8k')1from transformers import pipeline
2
3with torch.autocast('cuda', dtype=torch.bfloat16):
4 inputs = tokenizer('Here is a recipe for vegan banana bread:\n', return_tensors="pt").to('cuda')
5 outputs = model.generate(**inputs, max_new_tokens=100)
6 print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
7
8# or using the HF pipeline
9pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda:0')
10with torch.autocast('cuda', dtype=torch.bfloat16):
11 print(
12 pipe('Here is a recipe for vegan banana bread:\n',
13 max_new_tokens=100,
14 do_sample=True,
15 use_cache=True))| Hyperparameter | Value |
|---|---|
| n_parameters | 6.7B |
| n_layers | 32 |
| n_heads | 32 |
| d_model | 4096 |
| vocab size | 50432 |
| sequence length | 2048 |
| 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% |
@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}
}