Upload folder using huggingface_hub
Browse files- README.md +207 -0
- config.json +7 -0
- generation_config.json +7 -0
- model.bin +3 -0
- special_tokens_map.json +26 -0
- tokenizer.json +0 -0
- tokenizer_config.json +46 -0
- vocabulary.json +0 -0
README.md
ADDED
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
library_name: transformers
|
5 |
+
license: apache-2.0
|
6 |
+
tags:
|
7 |
+
- gpt
|
8 |
+
- llm
|
9 |
+
- large language model
|
10 |
+
- h2o-llmstudio
|
11 |
+
thumbnail: >-
|
12 |
+
https://h2o.ai/etc.clientlibs/h2o/clientlibs/clientlib-site/resources/images/favicon.ico
|
13 |
+
pipeline_tag: text-generation
|
14 |
+
---
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
<div style="width: 90%; max-width: 600px; margin: 0 auto; overflow: hidden; background-color: white">
|
19 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/636d18755aaed143cd6698ef/LAzQu_f5WOX7vqKl4yDsY.png"
|
20 |
+
alt="Slightly cropped image"
|
21 |
+
style="width: 102%; height: 102%; object-fit: cover; object-position: center; margin: -5% -5% -5% -5%;">
|
22 |
+
</div>
|
23 |
+
|
24 |
+
## Summary
|
25 |
+
|
26 |
+
|
27 |
+
h2o-danube3-4b-chat is a chat fine-tuned model by H2O.ai with 4 billion parameters. We release two versions of this model:
|
28 |
+
|
29 |
+
| Model Name | Description |
|
30 |
+
|:-----------------------------------------------------------------------------------|:----------------|
|
31 |
+
| [h2oai/h2o-danube3-4b-base](https://huggingface.co/h2oai/h2o-danube3-4b-base) | Base model |
|
32 |
+
| [h2oai/h2o-danube3-4b-chat](https://huggingface.co/h2oai/h2o-danube3-4b-chat) | Chat model |
|
33 |
+
|
34 |
+
This model was trained using [H2O LLM Studio](https://github.com/h2oai/h2o-llmstudio).
|
35 |
+
|
36 |
+
Can be run natively and fully offline on phones - try it yourself with [H2O AI Personal GPT](https://h2o.ai/platform/danube/personal-gpt/).
|
37 |
+
|
38 |
+
## Model Architecture
|
39 |
+
|
40 |
+
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.
|
41 |
+
|
42 |
+
The details of the model architecture are:
|
43 |
+
|
44 |
+
| Hyperparameter | Value |
|
45 |
+
|:----------------|:-------|
|
46 |
+
| n_layers | 24 |
|
47 |
+
| n_heads | 32 |
|
48 |
+
| n_query_groups | 8 |
|
49 |
+
| n_embd | 3840 |
|
50 |
+
| vocab size | 32000 |
|
51 |
+
| sequence length | 8192 |
|
52 |
+
|
53 |
+
## Usage
|
54 |
+
|
55 |
+
To use the model with the `transformers` library on a machine with GPUs, first make sure you have the `transformers` library installed.
|
56 |
+
|
57 |
+
```bash
|
58 |
+
pip install transformers>=4.42.3
|
59 |
+
```
|
60 |
+
|
61 |
+
```python
|
62 |
+
import torch
|
63 |
+
from transformers import pipeline
|
64 |
+
|
65 |
+
pipe = pipeline(
|
66 |
+
"text-generation",
|
67 |
+
model="h2oai/h2o-danube3-4b-chat",
|
68 |
+
torch_dtype=torch.bfloat16,
|
69 |
+
device_map="auto",
|
70 |
+
)
|
71 |
+
|
72 |
+
# We use the HF Tokenizer chat template to format each message
|
73 |
+
# https://huggingface.co/docs/transformers/main/en/chat_templating
|
74 |
+
messages = [
|
75 |
+
{"role": "user", "content": "Why is drinking water so healthy?"},
|
76 |
+
]
|
77 |
+
prompt = pipe.tokenizer.apply_chat_template(
|
78 |
+
messages,
|
79 |
+
tokenize=False,
|
80 |
+
add_generation_prompt=True,
|
81 |
+
)
|
82 |
+
res = pipe(
|
83 |
+
prompt,
|
84 |
+
return_full_text=False,
|
85 |
+
max_new_tokens=256,
|
86 |
+
)
|
87 |
+
print(res[0]["generated_text"])
|
88 |
+
```
|
89 |
+
|
90 |
+
This will apply and run the correct prompt format out of the box:
|
91 |
+
|
92 |
+
```
|
93 |
+
<|prompt|>Why is drinking water so healthy?</s><|answer|>
|
94 |
+
```
|
95 |
+
|
96 |
+
Alternatively, one can also run it via:
|
97 |
+
|
98 |
+
```python
|
99 |
+
import torch
|
100 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
101 |
+
|
102 |
+
model_name = "h2oai/h2o-danube3-4b-chat"
|
103 |
+
|
104 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
105 |
+
model_name,
|
106 |
+
)
|
107 |
+
model = AutoModelForCausalLM.from_pretrained(
|
108 |
+
model_name,
|
109 |
+
torch_dtype=torch.bfloat16,
|
110 |
+
device_map="auto",
|
111 |
+
trust_remote_code=True,
|
112 |
+
)
|
113 |
+
|
114 |
+
messages = [
|
115 |
+
{"role": "user", "content": "Why is drinking water so healthy?"},
|
116 |
+
]
|
117 |
+
prompt = tokenizer.apply_chat_template(
|
118 |
+
messages,
|
119 |
+
tokenize=False,
|
120 |
+
add_generation_prompt=True,
|
121 |
+
)
|
122 |
+
inputs = tokenizer(
|
123 |
+
prompt, return_tensors="pt", add_special_tokens=False
|
124 |
+
).to("cuda")
|
125 |
+
|
126 |
+
# generate configuration can be modified to your needs
|
127 |
+
tokens = model.generate(
|
128 |
+
input_ids=inputs["input_ids"],
|
129 |
+
attention_mask=inputs["attention_mask"],
|
130 |
+
min_new_tokens=2,
|
131 |
+
max_new_tokens=256,
|
132 |
+
)[0]
|
133 |
+
|
134 |
+
tokens = tokens[inputs["input_ids"].shape[1]:]
|
135 |
+
answer = tokenizer.decode(tokens, skip_special_tokens=True)
|
136 |
+
print(answer)
|
137 |
+
```
|
138 |
+
|
139 |
+
## Quantization and sharding
|
140 |
+
|
141 |
+
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```.
|
142 |
+
|
143 |
+
## Model Architecture
|
144 |
+
|
145 |
+
```
|
146 |
+
LlamaForCausalLM(
|
147 |
+
(model): LlamaModel(
|
148 |
+
(embed_tokens): Embedding(32000, 3840, padding_idx=0)
|
149 |
+
(layers): ModuleList(
|
150 |
+
(0-23): 24 x LlamaDecoderLayer(
|
151 |
+
(self_attn): LlamaSdpaAttention(
|
152 |
+
(q_proj): Linear(in_features=3840, out_features=3840, bias=False)
|
153 |
+
(k_proj): Linear(in_features=3840, out_features=960, bias=False)
|
154 |
+
(v_proj): Linear(in_features=3840, out_features=960, bias=False)
|
155 |
+
(o_proj): Linear(in_features=3840, out_features=3840, bias=False)
|
156 |
+
(rotary_emb): LlamaRotaryEmbedding()
|
157 |
+
)
|
158 |
+
(mlp): LlamaMLP(
|
159 |
+
(gate_proj): Linear(in_features=3840, out_features=10240, bias=False)
|
160 |
+
(up_proj): Linear(in_features=3840, out_features=10240, bias=False)
|
161 |
+
(down_proj): Linear(in_features=10240, out_features=3840, bias=False)
|
162 |
+
(act_fn): SiLU()
|
163 |
+
)
|
164 |
+
(input_layernorm): LlamaRMSNorm()
|
165 |
+
(post_attention_layernorm): LlamaRMSNorm()
|
166 |
+
)
|
167 |
+
)
|
168 |
+
(norm): LlamaRMSNorm()
|
169 |
+
)
|
170 |
+
(lm_head): Linear(in_features=3840, out_features=32000, bias=False)
|
171 |
+
)
|
172 |
+
```
|
173 |
+
|
174 |
+
## Benchmarks
|
175 |
+
|
176 |
+
### 🤗 Open LLM Leaderboard v1
|
177 |
+
|
178 |
+
| Benchmark | acc_n |
|
179 |
+
|:--------------|:--------:|
|
180 |
+
| Average | 61.42 |
|
181 |
+
| ARC-challenge | 58.96 |
|
182 |
+
| Hellaswag | 80.36 |
|
183 |
+
| MMLU | 54.74 |
|
184 |
+
| TruthfulQA | 47.79 |
|
185 |
+
| Winogrande | 76.48 |
|
186 |
+
| GSM8K | 50.18 |
|
187 |
+
|
188 |
+
### MT-Bench
|
189 |
+
|
190 |
+
```
|
191 |
+
First Turn: 7.28
|
192 |
+
Second Turn: 5.69
|
193 |
+
Average: 6.49
|
194 |
+
```
|
195 |
+
|
196 |
+
## Disclaimer
|
197 |
+
|
198 |
+
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.
|
199 |
+
|
200 |
+
- 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.
|
201 |
+
- 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.
|
202 |
+
- 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.
|
203 |
+
- 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.
|
204 |
+
- 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.
|
205 |
+
- 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.
|
206 |
+
|
207 |
+
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.
|
config.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"eos_token": "</s>",
|
4 |
+
"layer_norm_epsilon": 1e-05,
|
5 |
+
"multi_query_attention": true,
|
6 |
+
"unk_token": "<unk>"
|
7 |
+
}
|
generation_config.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 1,
|
4 |
+
"eos_token_id": 2,
|
5 |
+
"pad_token_id": 0,
|
6 |
+
"transformers_version": "4.42.3"
|
7 |
+
}
|
model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9839c1b117fbe8b12f18dad414d588c0afce7db1492bc80971f0e2cbb729e012
|
3 |
+
size 3965562710
|
special_tokens_map.json
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<s>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": false,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"cls_token": "</s>",
|
10 |
+
"eos_token": {
|
11 |
+
"content": "</s>",
|
12 |
+
"lstrip": false,
|
13 |
+
"normalized": false,
|
14 |
+
"rstrip": false,
|
15 |
+
"single_word": false
|
16 |
+
},
|
17 |
+
"pad_token": "<unk>",
|
18 |
+
"sep_token": "</s>",
|
19 |
+
"unk_token": {
|
20 |
+
"content": "<unk>",
|
21 |
+
"lstrip": false,
|
22 |
+
"normalized": false,
|
23 |
+
"rstrip": false,
|
24 |
+
"single_word": false
|
25 |
+
}
|
26 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": false,
|
3 |
+
"add_eos_token": false,
|
4 |
+
"add_prefix_space": false,
|
5 |
+
"added_tokens_decoder": {
|
6 |
+
"0": {
|
7 |
+
"content": "<unk>",
|
8 |
+
"lstrip": false,
|
9 |
+
"normalized": false,
|
10 |
+
"rstrip": false,
|
11 |
+
"single_word": false,
|
12 |
+
"special": true
|
13 |
+
},
|
14 |
+
"1": {
|
15 |
+
"content": "<s>",
|
16 |
+
"lstrip": false,
|
17 |
+
"normalized": false,
|
18 |
+
"rstrip": false,
|
19 |
+
"single_word": false,
|
20 |
+
"special": true
|
21 |
+
},
|
22 |
+
"2": {
|
23 |
+
"content": "</s>",
|
24 |
+
"lstrip": false,
|
25 |
+
"normalized": false,
|
26 |
+
"rstrip": false,
|
27 |
+
"single_word": false,
|
28 |
+
"special": true
|
29 |
+
}
|
30 |
+
},
|
31 |
+
"additional_special_tokens": [],
|
32 |
+
"bos_token": "<s>",
|
33 |
+
"chat_template": "{% for message in messages %}{% if message['role'] == 'system' %}{{ raise_exception('System role not supported') }}{% endif %}{% if ((message['role'] == 'user') != (loop.index0 % 2 == 0)) or ((message['role'] == 'assistant') != (loop.index0 % 2 == 1)) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if message['role'] == 'user' %}{{ '<|prompt|>' + message['content'].strip() + eos_token }}{% elif message['role'] == 'assistant' %}{{ '<|answer|>' + message['content'].strip() + eos_token }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|answer|>' }}{% endif %}",
|
34 |
+
"clean_up_tokenization_spaces": false,
|
35 |
+
"cls_token": "</s>",
|
36 |
+
"eos_token": "</s>",
|
37 |
+
"legacy": false,
|
38 |
+
"model_max_length": 1000000000000000019884624838656,
|
39 |
+
"pad_token": "<unk>",
|
40 |
+
"sep_token": "</s>",
|
41 |
+
"sp_model_kwargs": {},
|
42 |
+
"spaces_between_special_tokens": false,
|
43 |
+
"tokenizer_class": "LlamaTokenizer",
|
44 |
+
"unk_token": "<unk>",
|
45 |
+
"use_default_system_prompt": false
|
46 |
+
}
|
vocabulary.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|