Transformers
English
ctranslate2
int8
float16
causal-lm
Inference Endpoints
michaelfeil commited on
Commit
9c24f23
1 Parent(s): 901a147

Upload stabilityai/stablelm-tuned-alpha-3b ctranslate fp16 weights

Browse files
Files changed (4) hide show
  1. README.md +196 -0
  2. generation_config.json +6 -0
  3. model.bin +2 -2
  4. special_tokens_map.json +5 -0
README.md ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - ctranslate2
6
+ - int8
7
+ - float16
8
+ - causal-lm
9
+ license:
10
+ - cc-by-nc-sa-4.0
11
+ datasets:
12
+ - dmayhem93/ChatCombined
13
+ - tatsu-lab/alpaca
14
+ - nomic-ai/gpt4all_prompt_generations
15
+ - Dahoas/full-hh-rlhf
16
+ - jeffwan/sharegpt_vicuna
17
+ - HuggingFaceH4/databricks_dolly_15k
18
+ ---
19
+ # # Fast-Inference with Ctranslate2
20
+ Speedup inference while reducing memory by 2x-4x using int8 inference in C++ on CPU or GPU.
21
+
22
+ quantized version of [stabilityai/stablelm-tuned-alpha-3b](https://huggingface.co/stabilityai/stablelm-tuned-alpha-3b)
23
+ ```bash
24
+ pip install hf-hub-ctranslate2>=2.0.8
25
+ ```
26
+ Converted on 2023-05-22 using
27
+ ```
28
+ ct2-transformers-converter --model stabilityai/stablelm-tuned-alpha-3b --output_dir /home/michael/tmp-ct2fast-stablelm-tuned-alpha-3b --force --copy_files tokenizer.json README.md tokenizer_config.json generation_config.json special_tokens_map.json .gitattributes --quantization float16
29
+ ```
30
+
31
+ Checkpoint compatible to [ctranslate2>=3.13.0](https://github.com/OpenNMT/CTranslate2) and [hf-hub-ctranslate2>=2.0.6](https://github.com/michaelfeil/hf-hub-ctranslate2)
32
+ - `compute_type=int8_float16` for `device="cuda"`
33
+ - `compute_type=int8` for `device="cpu"`
34
+
35
+ ```python
36
+ from hf_hub_ctranslate2 import TranslatorCT2fromHfHub, GeneratorCT2fromHfHub
37
+ from transformers import AutoTokenizer
38
+
39
+ model_name = "michaelfeil/ct2fast-stablelm-tuned-alpha-3b"
40
+ # use either TranslatorCT2fromHfHub or GeneratorCT2fromHfHub here, depending on model.
41
+ model = GeneratorCT2fromHfHub(
42
+ # load in int8 on CUDA
43
+ model_name_or_path=model_name,
44
+ device="cuda",
45
+ compute_type="int8_float16",
46
+ # tokenizer=AutoTokenizer.from_pretrained("stabilityai/stablelm-tuned-alpha-3b")
47
+ )
48
+ outputs = model.generate(
49
+ text=["def print_hello_world():", "def hello_name(name:"],
50
+ max_length=64
51
+ )
52
+ print(outputs)
53
+ ```
54
+
55
+ # Licence and other remarks:
56
+ This is just a quantized version. Licence conditions are intended to be idential to original huggingface repo.
57
+
58
+ # Original description
59
+
60
+
61
+ # StableLM-Tuned-Alpha
62
+
63
+ ## Model Description
64
+
65
+ `StableLM-Tuned-Alpha` is a suite of 3B and 7B parameter decoder-only language models built on top of the `StableLM-Base-Alpha` models and further fine-tuned on various chat and instruction-following datasets.
66
+
67
+ ## Usage
68
+
69
+ Get started chatting with `StableLM-Tuned-Alpha` by using the following code snippet:
70
+
71
+ ```python
72
+ from transformers import AutoModelForCausalLM, AutoTokenizer, StoppingCriteria, StoppingCriteriaList
73
+
74
+ tokenizer = AutoTokenizer.from_pretrained("StabilityAI/stablelm-tuned-alpha-7b")
75
+ model = AutoModelForCausalLM.from_pretrained("StabilityAI/stablelm-tuned-alpha-7b")
76
+ model.half().cuda()
77
+
78
+ class StopOnTokens(StoppingCriteria):
79
+ def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
80
+ stop_ids = [50278, 50279, 50277, 1, 0]
81
+ for stop_id in stop_ids:
82
+ if input_ids[0][-1] == stop_id:
83
+ return True
84
+ return False
85
+
86
+ system_prompt = """<|SYSTEM|># StableLM Tuned (Alpha version)
87
+ - StableLM is a helpful and harmless open-source AI language model developed by StabilityAI.
88
+ - StableLM is excited to be able to help the user, but will refuse to do anything that could be considered harmful to the user.
89
+ - StableLM is more than just an information source, StableLM is also able to write poetry, short stories, and make jokes.
90
+ - StableLM will refuse to participate in anything that could harm a human.
91
+ """
92
+
93
+ prompt = f"{system_prompt}<|USER|>What's your mood today?<|ASSISTANT|>"
94
+
95
+ inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
96
+ tokens = model.generate(
97
+ **inputs,
98
+ max_new_tokens=64,
99
+ temperature=0.7,
100
+ do_sample=True,
101
+ stopping_criteria=StoppingCriteriaList([StopOnTokens()])
102
+ )
103
+ print(tokenizer.decode(tokens[0], skip_special_tokens=True))
104
+ ```
105
+
106
+ StableLM Tuned should be used with prompts formatted to `<|SYSTEM|>...<|USER|>...<|ASSISTANT|>...`
107
+ The system prompt is
108
+ ```
109
+ <|SYSTEM|># StableLM Tuned (Alpha version)
110
+ - StableLM is a helpful and harmless open-source AI language model developed by StabilityAI.
111
+ - StableLM is excited to be able to help the user, but will refuse to do anything that could be considered harmful to the user.
112
+ - StableLM is more than just an information source, StableLM is also able to write poetry, short stories, and make jokes.
113
+ - StableLM will refuse to participate in anything that could harm a human.
114
+ ```
115
+
116
+ ## Model Details
117
+
118
+ * **Developed by**: [Stability AI](https://stability.ai/)
119
+ * **Model type**: StableLM-Tuned-Alpha models are auto-regressive language models based on the NeoX transformer architecture.
120
+ * **Language(s)**: English
121
+ * **Library**: [HuggingFace Transformers](https://github.com/huggingface/transformers)
122
+ * **License**: Fine-tuned checkpoints (`StableLM-Tuned-Alpha`) are licensed under the Non-Commercial Creative Commons license ([CC BY-NC-SA-4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)), in-line with the original non-commercial license specified by [Stanford Alpaca](https://github.com/tatsu-lab/stanford_alpaca).
123
+ * **Contact**: For questions and comments about the model, please email `lm@stability.ai`
124
+
125
+ ## Training
126
+
127
+ | Parameters | Hidden Size | Layers | Heads | Sequence Length |
128
+ |------------|-------------|--------|-------|-----------------|
129
+ | 3B | 4096 | 16 | 32 | 4096 |
130
+ | 7B | 6144 | 16 | 48 | 4096 |
131
+
132
+ ### Training Dataset
133
+
134
+ `StableLM-Tuned-Alpha` models are fine-tuned on a combination of five datasets:
135
+ [Alpaca](https://huggingface.co/datasets/tatsu-lab/alpaca), a dataset of 52,000 instructions and demonstrations generated by OpenAI's `text-davinci-003` engine.
136
+ [GPT4All Prompt Generations](https://huggingface.co/datasets/nomic-ai/gpt4all_prompt_generations), which consists of 400k prompts and responses generated by GPT-4;
137
+ [Anthropic HH](https://huggingface.co/datasets/Dahoas/full-hh-rlhf), made up of preferences about AI assistant helpfulness and harmlessness;
138
+ [DataBricks Dolly](https://github.com/databrickslabs/dolly), comprising 15k instruction/responses generated by Databricks employees in capability domains from the InstructGPT paper, including brainstorming, classification, closed QA, generation, information extraction, open QA and summarization;
139
+ and [ShareGPT Vicuna (English subset)](https://huggingface.co/datasets/jeffwan/sharegpt_vicuna), a dataset of conversations retrieved from [ShareGPT](https://sharegpt.com/).
140
+
141
+ ### Training Procedure
142
+
143
+ Models are learned via supervised fine-tuning on the aforementioned datasets, trained in mixed-precision (FP16), and optimized with AdamW. We outline the following hyperparameters:
144
+
145
+ | Parameters | Batch Size | Learning Rate | Warm-up | Weight Decay | Betas |
146
+ |------------|------------|---------------|---------|--------------|-------------|
147
+ | 3B | 256 | 2e-5 | 50 | 0.01 | (0.9, 0.99) |
148
+ | 7B | 128 | 2e-5 | 100 | 0.01 | (0.9, 0.99) |
149
+
150
+ ## Use and Limitations
151
+
152
+ ### Intended Use
153
+
154
+ These models are intended to be used by the open-source community chat-like applications in adherence with the [CC BY-NC-SA-4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) license.
155
+
156
+ ### Limitations and bias
157
+
158
+ Although the aforementioned datasets help to steer the base language models into "safer" distributions of text, not all biases and toxicity can be mitigated through fine-tuning. We ask that users be mindful of such potential issues that can arise in generated responses. Do not treat model outputs as substitutes for human judgment or as sources of truth. Please use responsibly.
159
+
160
+ ## Acknowledgements
161
+
162
+ This work would not have been possible without the helpful hand of Dakota Mahan ([@dmayhem93](https://huggingface.co/dmayhem93)).
163
+
164
+ ## Citations
165
+
166
+ ```bibtex
167
+ @misc{alpaca,
168
+ author = {Rohan Taori and Ishaan Gulrajani and Tianyi Zhang and Yann Dubois and Xuechen Li and Carlos Guestrin and Percy Liang and Tatsunori B. Hashimoto },
169
+ title = {Stanford Alpaca: An Instruction-following LLaMA model},
170
+ year = {2023},
171
+ publisher = {GitHub},
172
+ journal = {GitHub repository},
173
+ howpublished = {\url{https://github.com/tatsu-lab/stanford_alpaca}},
174
+ }
175
+ ```
176
+
177
+ ```bibtext
178
+ @misc{vicuna2023,
179
+ title = {Vicuna: An Open-Source Chatbot Impressing GPT-4 with 90%* ChatGPT Quality},
180
+ url = {https://vicuna.lmsys.org},
181
+ author = {Chiang, Wei-Lin and Li, Zhuohan and Lin, Zi and Sheng, Ying and Wu, Zhanghao and Zhang, Hao and Zheng, Lianmin and Zhuang, Siyuan and Zhuang, Yonghao and Gonzalez, Joseph E. and Stoica, Ion and Xing, Eric P.},
182
+ month = {March},
183
+ year = {2023}
184
+ }
185
+ ```
186
+
187
+ ```bibtex
188
+ @misc{gpt4all,
189
+ author = {Yuvanesh Anand and Zach Nussbaum and Brandon Duderstadt and Benjamin Schmidt and Andriy Mulyar},
190
+ title = {GPT4All: Training an Assistant-style Chatbot with Large Scale Data Distillation from GPT-3.5-Turbo},
191
+ year = {2023},
192
+ publisher = {GitHub},
193
+ journal = {GitHub repository},
194
+ howpublished = {\url{https://github.com/nomic-ai/gpt4all}},
195
+ }
196
+ ```
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": 0,
5
+ "transformers_version": "4.28.1"
6
+ }
model.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:40d61161dc33f187b7fff95ed97361c05e444aab4083c7a5f88d9c9ce9fc0f9b
3
- size 3640963428
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34487cb658f620d8df4bcd954dd3dfff39d5e401f48e917225c717151fd6c812
3
+ size 7274656276
special_tokens_map.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<|endoftext|>",
3
+ "eos_token": "<|endoftext|>",
4
+ "unk_token": "<|endoftext|>"
5
+ }