RichardErkhov commited on
Commit
c179683
·
verified ·
1 Parent(s): 8b480ac

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +225 -0
README.md ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ h2o-danube3-4b-chat - bnb 8bits
11
+ - Model creator: https://huggingface.co/h2oai/
12
+ - Original model: https://huggingface.co/h2oai/h2o-danube3-4b-chat/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ language:
20
+ - en
21
+ library_name: transformers
22
+ license: apache-2.0
23
+ tags:
24
+ - gpt
25
+ - llm
26
+ - large language model
27
+ - h2o-llmstudio
28
+ thumbnail: >-
29
+ https://h2o.ai/etc.clientlibs/h2o/clientlibs/clientlib-site/resources/images/favicon.ico
30
+ pipeline_tag: text-generation
31
+ ---
32
+
33
+
34
+
35
+ <div style="width: 90%; max-width: 600px; margin: 0 auto; overflow: hidden; background-color: white">
36
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/636d18755aaed143cd6698ef/LAzQu_f5WOX7vqKl4yDsY.png"
37
+ alt="Slightly cropped image"
38
+ style="width: 102%; height: 102%; object-fit: cover; object-position: center; margin: -5% -5% -5% -5%;">
39
+ </div>
40
+
41
+ ## Summary
42
+
43
+
44
+ h2o-danube3-4b-chat is a chat fine-tuned model by H2O.ai with 4 billion parameters. We release two versions of this model:
45
+
46
+ | Model Name | Description |
47
+ |:-----------------------------------------------------------------------------------|:----------------|
48
+ | [h2oai/h2o-danube3-4b-base](https://huggingface.co/h2oai/h2o-danube3-4b-base) | Base model |
49
+ | [h2oai/h2o-danube3-4b-chat](https://huggingface.co/h2oai/h2o-danube3-4b-chat) | Chat model |
50
+
51
+ This model was trained using [H2O LLM Studio](https://github.com/h2oai/h2o-llmstudio).
52
+
53
+ Can be run natively and fully offline on phones - try it yourself with [H2O AI Personal GPT](https://h2o.ai/platform/danube/personal-gpt/).
54
+
55
+ ## Model Architecture
56
+
57
+ We adjust the Llama 2 architecture for a total of around 4b parameters. For details, please refer to our [Technical Report](https://arxiv.org/abs/2407.09276). We use the Mistral tokenizer with a vocabulary size of 32,000 and train our model up to a context length of 8,192.
58
+
59
+ The details of the model architecture are:
60
+
61
+ | Hyperparameter | Value |
62
+ |:----------------|:-------|
63
+ | n_layers | 24 |
64
+ | n_heads | 32 |
65
+ | n_query_groups | 8 |
66
+ | n_embd | 3840 |
67
+ | vocab size | 32000 |
68
+ | sequence length | 8192 |
69
+
70
+ ## Usage
71
+
72
+ To use the model with the `transformers` library on a machine with GPUs, first make sure you have the `transformers` library installed.
73
+
74
+ ```bash
75
+ pip install transformers>=4.42.3
76
+ ```
77
+
78
+ ```python
79
+ import torch
80
+ from transformers import pipeline
81
+
82
+ pipe = pipeline(
83
+ "text-generation",
84
+ model="h2oai/h2o-danube3-4b-chat",
85
+ torch_dtype=torch.bfloat16,
86
+ device_map="auto",
87
+ )
88
+
89
+ # We use the HF Tokenizer chat template to format each message
90
+ # https://huggingface.co/docs/transformers/main/en/chat_templating
91
+ messages = [
92
+ {"role": "user", "content": "Why is drinking water so healthy?"},
93
+ ]
94
+ prompt = pipe.tokenizer.apply_chat_template(
95
+ messages,
96
+ tokenize=False,
97
+ add_generation_prompt=True,
98
+ )
99
+ res = pipe(
100
+ prompt,
101
+ return_full_text=False,
102
+ max_new_tokens=256,
103
+ )
104
+ print(res[0]["generated_text"])
105
+ ```
106
+
107
+ This will apply and run the correct prompt format out of the box:
108
+
109
+ ```
110
+ <|prompt|>Why is drinking water so healthy?</s><|answer|>
111
+ ```
112
+
113
+ Alternatively, one can also run it via:
114
+
115
+ ```python
116
+ import torch
117
+ from transformers import AutoModelForCausalLM, AutoTokenizer
118
+
119
+ model_name = "h2oai/h2o-danube3-4b-chat"
120
+
121
+ tokenizer = AutoTokenizer.from_pretrained(
122
+ model_name,
123
+ )
124
+ model = AutoModelForCausalLM.from_pretrained(
125
+ model_name,
126
+ torch_dtype=torch.bfloat16,
127
+ device_map="auto",
128
+ trust_remote_code=True,
129
+ )
130
+
131
+ messages = [
132
+ {"role": "user", "content": "Why is drinking water so healthy?"},
133
+ ]
134
+ prompt = tokenizer.apply_chat_template(
135
+ messages,
136
+ tokenize=False,
137
+ add_generation_prompt=True,
138
+ )
139
+ inputs = tokenizer(
140
+ prompt, return_tensors="pt", add_special_tokens=False
141
+ ).to("cuda")
142
+
143
+ # generate configuration can be modified to your needs
144
+ tokens = model.generate(
145
+ input_ids=inputs["input_ids"],
146
+ attention_mask=inputs["attention_mask"],
147
+ min_new_tokens=2,
148
+ max_new_tokens=256,
149
+ )[0]
150
+
151
+ tokens = tokens[inputs["input_ids"].shape[1]:]
152
+ answer = tokenizer.decode(tokens, skip_special_tokens=True)
153
+ print(answer)
154
+ ```
155
+
156
+ ## Quantization and sharding
157
+
158
+ You can load the models using quantization by specifying ```load_in_8bit=True``` or ```load_in_4bit=True```. Also, sharding on multiple GPUs is possible by setting ```device_map=auto```.
159
+
160
+ ## Model Architecture
161
+
162
+ ```
163
+ LlamaForCausalLM(
164
+ (model): LlamaModel(
165
+ (embed_tokens): Embedding(32000, 3840, padding_idx=0)
166
+ (layers): ModuleList(
167
+ (0-23): 24 x LlamaDecoderLayer(
168
+ (self_attn): LlamaSdpaAttention(
169
+ (q_proj): Linear(in_features=3840, out_features=3840, bias=False)
170
+ (k_proj): Linear(in_features=3840, out_features=960, bias=False)
171
+ (v_proj): Linear(in_features=3840, out_features=960, bias=False)
172
+ (o_proj): Linear(in_features=3840, out_features=3840, bias=False)
173
+ (rotary_emb): LlamaRotaryEmbedding()
174
+ )
175
+ (mlp): LlamaMLP(
176
+ (gate_proj): Linear(in_features=3840, out_features=10240, bias=False)
177
+ (up_proj): Linear(in_features=3840, out_features=10240, bias=False)
178
+ (down_proj): Linear(in_features=10240, out_features=3840, bias=False)
179
+ (act_fn): SiLU()
180
+ )
181
+ (input_layernorm): LlamaRMSNorm()
182
+ (post_attention_layernorm): LlamaRMSNorm()
183
+ )
184
+ )
185
+ (norm): LlamaRMSNorm()
186
+ )
187
+ (lm_head): Linear(in_features=3840, out_features=32000, bias=False)
188
+ )
189
+ ```
190
+
191
+ ## Benchmarks
192
+
193
+ ### 🤗 Open LLM Leaderboard v1
194
+
195
+ | Benchmark | acc_n |
196
+ |:--------------|:--------:|
197
+ | Average | 61.42 |
198
+ | ARC-challenge | 58.96 |
199
+ | Hellaswag | 80.36 |
200
+ | MMLU | 54.74 |
201
+ | TruthfulQA | 47.79 |
202
+ | Winogrande | 76.48 |
203
+ | GSM8K | 50.18 |
204
+
205
+ ### MT-Bench
206
+
207
+ ```
208
+ First Turn: 7.28
209
+ Second Turn: 5.69
210
+ Average: 6.49
211
+ ```
212
+
213
+ ## Disclaimer
214
+
215
+ 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.
216
+
217
+ - 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.
218
+ - 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.
219
+ - 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.
220
+ - 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.
221
+ - 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.
222
+ - 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.
223
+
224
+ 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.
225
+