maddes8cht commited on
Commit
7914603
1 Parent(s): e85e7cd

"Update README.md"

Browse files
Files changed (1) hide show
  1. README.md +267 -0
README.md CHANGED
@@ -1,3 +1,270 @@
1
  ---
 
 
 
 
 
 
 
 
 
 
 
2
  license: apache-2.0
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ library_name: transformers
5
+ tags:
6
+ - gpt
7
+ - llm
8
+ - large language model
9
+ - h2o-llmstudio
10
+ inference: false
11
+ thumbnail: >-
12
+ https://h2o.ai/etc.clientlibs/h2o/clientlibs/clientlib-site/resources/images/favicon.ico
13
  license: apache-2.0
14
+ datasets:
15
+ - OpenAssistant/oasst1
16
  ---
17
+ [![banner](https://maddes8cht.github.io/assets/buttons/Huggingface-banner.jpg)]()
18
+
19
+ ## I am still building the structure of these descriptions.
20
+
21
+ These will contain increasingly more content to help find the best models for a purpose.
22
+
23
+ # h2ogpt-gm-oasst1-en-2048-falcon-40b-v2 - GGUF
24
+ - Model creator: [h2oai](https://huggingface.co/h2oai)
25
+ - Original model: [h2ogpt-gm-oasst1-en-2048-falcon-40b-v2](https://huggingface.co/h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v2)
26
+
27
+
28
+
29
+ # About GGUF format
30
+
31
+ `gguf` is the current file format used by the [`ggml`](https://github.com/ggerganov/ggml) library.
32
+ A growing list of Software is using it and can therefore use this model.
33
+ The core project making use of the ggml library is the [llama.cpp](https://github.com/ggerganov/llama.cpp) project by Georgi Gerganov
34
+
35
+ # Quantization variants
36
+
37
+ There is a bunch of quantized files available. How to choose the best for you:
38
+
39
+ # legacy quants
40
+
41
+ Q4_0, Q4_1, Q5_0, Q5_1 and Q8 are `legacy` quantization types.
42
+ Nevertheless, they are fully supported, as there are several circumstances that cause certain model not to be compatible with the modern K-quants.
43
+ Falcon 7B models cannot be quantized to K-quants.
44
+
45
+ # K-quants
46
+
47
+ K-quants are based on the idea that the quantization of certain parts affects the quality in different ways. If you quantize certain parts more and others less, you get a more powerful model with the same file size, or a smaller file size and lower memory load with comparable performance.
48
+ So, if possible, use K-quants.
49
+ With a Q6_K you should find it really hard to find a quality difference to the original model - ask your model two times the same question and you may encounter bigger quality differences.
50
+
51
+
52
+
53
+ # Original Model Card:
54
+ # Model Card
55
+ ## Summary
56
+
57
+ This model was trained using [H2O LLM Studio](https://github.com/h2oai/h2o-llmstudio).
58
+ - Base model: [tiiuae/falcon-40b](https://huggingface.co/tiiuae/falcon-40b)
59
+ - Dataset preparation: [OpenAssistant/oasst1](https://github.com/h2oai/h2o-llmstudio/blob/1935d84d9caafed3ee686ad2733eb02d2abfce57/app_utils/utils.py#LL1896C5-L1896C28) personalized
60
+
61
+
62
+ ## Usage
63
+
64
+ To use the model with the `transformers` library on a machine with GPUs, first make sure you have the `transformers`, `accelerate` and `torch` libraries installed.
65
+
66
+ ```bash
67
+ pip install transformers==4.29.2
68
+ pip install bitsandbytes==0.39.0
69
+ pip install accelerate==0.19.0
70
+ pip install torch==2.0.0
71
+ pip install einops==0.6.1
72
+ ```
73
+
74
+ ```python
75
+ import torch
76
+ from transformers import pipeline, BitsAndBytesConfig, AutoTokenizer
77
+
78
+ model_kwargs = {}
79
+
80
+ quantization_config = None
81
+ # optional quantization
82
+ quantization_config = BitsAndBytesConfig(
83
+ load_in_8bit=True,
84
+ llm_int8_threshold=6.0,
85
+ )
86
+ model_kwargs["quantization_config"] = quantization_config
87
+
88
+ tokenizer = AutoTokenizer.from_pretrained(
89
+ "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v2",
90
+ use_fast=False,
91
+ padding_side="left",
92
+ trust_remote_code=True,
93
+ )
94
+
95
+ generate_text = pipeline(
96
+ model="h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v2",
97
+ tokenizer=tokenizer,
98
+ torch_dtype=torch.float16,
99
+ trust_remote_code=True,
100
+ use_fast=False,
101
+ device_map={"": "cuda:0"},
102
+ model_kwargs=model_kwargs,
103
+ )
104
+
105
+ res = generate_text(
106
+ "Why is drinking water so healthy?",
107
+ min_new_tokens=2,
108
+ max_new_tokens=1024,
109
+ do_sample=False,
110
+ num_beams=1,
111
+ temperature=float(0.3),
112
+ repetition_penalty=float(1.2),
113
+ renormalize_logits=True
114
+ )
115
+ print(res[0]["generated_text"])
116
+ ```
117
+
118
+ You can print a sample prompt after the preprocessing step to see how it is feed to the tokenizer:
119
+
120
+ ```python
121
+ print(generate_text.preprocess("Why is drinking water so healthy?")["prompt_text"])
122
+ ```
123
+
124
+ ```bash
125
+ <|prompt|>Why is drinking water so healthy?<|endoftext|><|answer|>
126
+ ```
127
+
128
+ Alternatively, you can download [h2oai_pipeline.py](h2oai_pipeline.py), store it alongside your notebook, and construct the pipeline yourself from the loaded model and tokenizer:
129
+
130
+ ```python
131
+ import torch
132
+ from h2oai_pipeline import H2OTextGenerationPipeline
133
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
134
+
135
+ quantization_config = None
136
+ # optional quantization
137
+ quantization_config = BitsAndBytesConfig(
138
+ load_in_8bit=True,
139
+ llm_int8_threshold=6.0,
140
+ )
141
+
142
+ tokenizer = AutoTokenizer.from_pretrained(
143
+ "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v2",
144
+ use_fast=False,
145
+ padding_side="left",
146
+ trust_remote_code=True,
147
+ )
148
+ model = AutoModelForCausalLM.from_pretrained(
149
+ "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v2",
150
+ trust_remote_code=True,
151
+ torch_dtype=torch.float16,
152
+ device_map={"": "cuda:0"},
153
+ quantization_config=quantization_config
154
+ ).eval()
155
+ generate_text = H2OTextGenerationPipeline(model=model, tokenizer=tokenizer)
156
+
157
+ res = generate_text(
158
+ "Why is drinking water so healthy?",
159
+ min_new_tokens=2,
160
+ max_new_tokens=1024,
161
+ do_sample=False,
162
+ num_beams=1,
163
+ temperature=float(0.3),
164
+ repetition_penalty=float(1.2),
165
+ renormalize_logits=True
166
+ )
167
+ print(res[0]["generated_text"])
168
+ ```
169
+
170
+
171
+ You may also construct the pipeline from the loaded model and tokenizer yourself and consider the preprocessing steps:
172
+
173
+ ```python
174
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
175
+
176
+ # Important: The prompt needs to be in the same format the model was trained with.
177
+ # You can find an example prompt in the experiment logs.
178
+ prompt = "<|prompt|>How are you?<|endoftext|><|answer|>"
179
+
180
+ quantization_config = None
181
+ # optional quantization
182
+ quantization_config = BitsAndBytesConfig(
183
+ load_in_8bit=True,
184
+ llm_int8_threshold=6.0,
185
+ )
186
+
187
+ tokenizer = AutoTokenizer.from_pretrained(
188
+ "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v2",
189
+ use_fast=False,
190
+ padding_side="left",
191
+ trust_remote_code=True,
192
+ )
193
+ model = AutoModelForCausalLM.from_pretrained(
194
+ "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v2",
195
+ trust_remote_code=True,
196
+ torch_dtype=torch.float16,
197
+ device_map={"": "cuda:0"},
198
+ quantization_config=quantization_config
199
+ ).eval()
200
+
201
+ inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to("cuda")
202
+
203
+ # generate configuration can be modified to your needs
204
+ tokens = model.generate(
205
+ **inputs,
206
+ min_new_tokens=2,
207
+ max_new_tokens=1024,
208
+ do_sample=False,
209
+ num_beams=1,
210
+ temperature=float(0.3),
211
+ repetition_penalty=float(1.2),
212
+ renormalize_logits=True
213
+ )[0]
214
+
215
+ tokens = tokens[inputs["input_ids"].shape[1]:]
216
+ answer = tokenizer.decode(tokens, skip_special_tokens=True)
217
+ print(answer)
218
+ ```
219
+
220
+ ## Model Architecture
221
+
222
+ ```
223
+ RWForCausalLM(
224
+ (transformer): RWModel(
225
+ (word_embeddings): Embedding(65024, 8192)
226
+ (h): ModuleList(
227
+ (0-59): 60 x DecoderLayer(
228
+ (ln_attn): LayerNorm((8192,), eps=1e-05, elementwise_affine=True)
229
+ (ln_mlp): LayerNorm((8192,), eps=1e-05, elementwise_affine=True)
230
+ (self_attention): Attention(
231
+ (maybe_rotary): RotaryEmbedding()
232
+ (query_key_value): Linear(in_features=8192, out_features=9216, bias=False)
233
+ (dense): Linear(in_features=8192, out_features=8192, bias=False)
234
+ (attention_dropout): Dropout(p=0.0, inplace=False)
235
+ )
236
+ (mlp): MLP(
237
+ (dense_h_to_4h): Linear(in_features=8192, out_features=32768, bias=False)
238
+ (act): GELU(approximate='none')
239
+ (dense_4h_to_h): Linear(in_features=32768, out_features=8192, bias=False)
240
+ )
241
+ )
242
+ )
243
+ (ln_f): LayerNorm((8192,), eps=1e-05, elementwise_affine=True)
244
+ )
245
+ (lm_head): Linear(in_features=8192, out_features=65024, bias=False)
246
+ )
247
+ ```
248
+
249
+ ## Model Configuration
250
+
251
+ This model was trained using H2O LLM Studio and with the configuration in [cfg.yaml](cfg.yaml). Visit [H2O LLM Studio](https://github.com/h2oai/h2o-llmstudio) to learn how to train your own large language models.
252
+
253
+ ## Disclaimer
254
+
255
+ Please read this disclaimer carefully before using the large language model provided in this repository. Your use of the model signifies your agreement to the following terms and conditions.
256
+
257
+ - Biases and Offensiveness: The large language model is trained on a diverse range of internet text data, which may contain biased, racist, offensive, or otherwise inappropriate content. By using this model, you acknowledge and accept that the generated content may sometimes exhibit biases or produce content that is offensive or inappropriate. The developers of this repository do not endorse, support, or promote any such content or viewpoints.
258
+ - Limitations: The large language model is an AI-based tool and not a human. It may produce incorrect, nonsensical, or irrelevant responses. It is the user's responsibility to critically evaluate the generated content and use it at their discretion.
259
+ - Use at Your Own Risk: Users of this large language model must assume full responsibility for any consequences that may arise from their use of the tool. The developers and contributors of this repository shall not be held liable for any damages, losses, or harm resulting from the use or misuse of the provided model.
260
+ - Ethical Considerations: Users are encouraged to use the large language model responsibly and ethically. By using this model, you agree not to use it for purposes that promote hate speech, discrimination, harassment, or any form of illegal or harmful activities.
261
+ - Reporting Issues: If you encounter any biased, offensive, or otherwise inappropriate content generated by the large language model, please report it to the repository maintainers through the provided channels. Your feedback will help improve the model and mitigate potential issues.
262
+ - Changes to this Disclaimer: The developers of this repository reserve the right to modify or update this disclaimer at any time without prior notice. It is the user's responsibility to periodically review the disclaimer to stay informed about any changes.
263
+
264
+ By using the large language model provided in this repository, you agree to accept and comply with the terms and conditions outlined in this disclaimer. If you do not agree with any part of this disclaimer, you should refrain from using the model and any content generated by it.<center>
265
+ [![GitHub](https://maddes8cht.github.io/assets/buttons/github-io-button.png)](https://maddes8cht.github.io)
266
+ [![Stack Exchange](https://stackexchange.com/users/flair/26485911.png)](https://stackexchange.com/users/26485911)
267
+ [![GitHub](https://maddes8cht.github.io/assets/buttons/github-button.png)](https://github.com/maddes8cht)
268
+ [![HuggingFace](https://maddes8cht.github.io/assets/buttons/huggingface-button.png)](https://huggingface.co/maddes8cht)
269
+ [![Twitter](https://maddes8cht.github.io/assets/buttons/twitter-button.png)](https://twitter.com/maddes1966)
270
+ </center>