duyntnet commited on
Commit
ff19752
·
verified ·
1 Parent(s): 4e5d886

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +90 -0
README.md ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ language:
4
+ - en
5
+ pipeline_tag: text-generation
6
+ inference: false
7
+ tags:
8
+ - transformers
9
+ - gguf
10
+ - imatrix
11
+ - mpt-7b-storywriter
12
+ ---
13
+ Quantizations of https://huggingface.co/mosaicml/mpt-7b-storywriter
14
+
15
+ Note: not sure why but Q2_K, Q3_K_S, Q4_0 and Q5_0 gave error during quantizations: "ggml_validate_row_data: found nan value at block xxx", so I skipped those quants.
16
+
17
+ # From original readme
18
+
19
+ ## How to Use
20
+
21
+ Note: This model requires that `trust_remote_code=True` be passed to the `from_pretrained` method. This is because we use a custom model architecture that is not yet part of the `transformers` package.
22
+
23
+ It includes options for many training efficiency features such as [FlashAttention (Dao et al. 2022)](https://arxiv.org/pdf/2205.14135.pdf), [ALiBi](https://arxiv.org/abs/2108.12409), QK LayerNorm, and more.
24
+
25
+ ```python
26
+ import transformers
27
+ model = transformers.AutoModelForCausalLM.from_pretrained(
28
+ 'mosaicml/mpt-7b-storywriter',
29
+ trust_remote_code=True
30
+ )
31
+ ```
32
+
33
+ To use the optimized [triton implementation](https://github.com/openai/triton) of FlashAttention, you can load the model on GPU (`cuda:0`) with `attn_impl='triton'` and with `bfloat16` precision:
34
+ ```python
35
+ import torch
36
+ import transformers
37
+
38
+ name = 'mosaicml/mpt-7b-storywriter'
39
+
40
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
41
+ config.attn_config['attn_impl'] = 'triton'
42
+ config.init_device = 'cuda:0' # For fast initialization directly on GPU!
43
+
44
+ model = transformers.AutoModelForCausalLM.from_pretrained(
45
+ name,
46
+ config=config,
47
+ torch_dtype=torch.bfloat16, # Load model weights in bfloat16
48
+ trust_remote_code=True
49
+ )
50
+ ```
51
+
52
+ Although the model was trained with a sequence length of 2048 and finetuned with a sequence length of 65536,
53
+ ALiBi enables users to increase the maximum sequence length during finetuning and/or inference. For example:
54
+ ```python
55
+ import transformers
56
+
57
+ name = 'mosaicml/mpt-7b'
58
+
59
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
60
+ config.max_seq_len = 83968 # (input + output) tokens can now be up to 83968
61
+
62
+ model = transformers.AutoModelForCausalLM.from_pretrained(
63
+ name,
64
+ config=config,
65
+ trust_remote_code=True
66
+ )
67
+ ```
68
+
69
+ This model was trained with the [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) tokenizer.
70
+
71
+ ```python
72
+ from transformers import AutoTokenizer
73
+ tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neox-20b")
74
+ ```
75
+
76
+ The model can then be used, for example, within a text-generation pipeline.
77
+ Note: when running Torch modules in lower precision, it is best practice to use the [torch.autocast context manager](https://pytorch.org/docs/stable/amp.html).
78
+
79
+ ```python
80
+ from transformers import pipeline
81
+
82
+ pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda:0')
83
+
84
+ with torch.autocast('cuda', dtype=torch.bfloat16):
85
+ print(
86
+ pipe('Here is a recipe for vegan banana bread:\n',
87
+ max_new_tokens=100,
88
+ do_sample=True,
89
+ use_cache=True))
90
+ ```