Upload 9 files
Browse files- README.md +145 -0
- cfg.yaml +109 -0
- config.json +29 -0
- generation_config.json +8 -0
- model.safetensors +3 -0
- special_tokens_map.json +44 -0
- tokenizer.json +0 -0
- tokenizer.model +3 -0
- tokenizer_config.json +45 -0
README.md
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
inference: false
|
12 |
+
thumbnail: https://h2o.ai/etc.clientlibs/h2o/clientlibs/clientlib-site/resources/images/favicon.ico
|
13 |
+
---
|
14 |
+
# Model Card
|
15 |
+
## Summary
|
16 |
+
|
17 |
+
h2o-danube-1.8b-chat is an chat fine-tuned model by H2O.ai with 1.8 billion parameters. We release three versions of this model:
|
18 |
+
|
19 |
+
| Model Name | Description |
|
20 |
+
|:-----------------------------------------------------------------------------------|:----------------|
|
21 |
+
| [h2oai/h2o-danube-1.8b-base](https://huggingface.co/h2oai/h2o-danube-1.8b-base) | Base model |
|
22 |
+
| [h2oai/h2o-danube-1.8b-sft](https://huggingface.co/h2oai/h2o-danube-1.8b-sft) | SFT tuned |
|
23 |
+
| [h2oai/h2o-danube-1.8b-chat](https://huggingface.co/h2oai/h2o-danube-1.8b-chat) | SFT + DPO tuned |
|
24 |
+
|
25 |
+
This model was trained using [H2O LLM Studio](https://github.com/h2oai/h2o-llmstudio).
|
26 |
+
|
27 |
+
## Model Architecture
|
28 |
+
|
29 |
+
We adjust the Llama 2 architecture for a total of around 1.8b parameters. We use the original Llama 2 tokenizer with a vocabulary size of 32,000 and train our model up to a context length of 16,384. We incorporate the sliding window attention from mistral with a size of 4,096.
|
30 |
+
|
31 |
+
The details of the model architecture are:
|
32 |
+
|
33 |
+
| Hyperparameter | Value |
|
34 |
+
|:----------------|:-------|
|
35 |
+
| n_layers | 24 |
|
36 |
+
| n_heads | 32 |
|
37 |
+
| n_query_groups | 8 |
|
38 |
+
| n_embd | 2560 |
|
39 |
+
| vocab size | 32000 |
|
40 |
+
| sequence length | 16384 |
|
41 |
+
|
42 |
+
## Usage
|
43 |
+
|
44 |
+
To use the model with the `transformers` library on a machine with GPUs, first make sure you have the `transformers` library installed.
|
45 |
+
|
46 |
+
```bash
|
47 |
+
pip install transformers==4.36.1
|
48 |
+
```
|
49 |
+
|
50 |
+
```python
|
51 |
+
import torch
|
52 |
+
from transformers import pipeline
|
53 |
+
|
54 |
+
pipe = pipeline(
|
55 |
+
"text-generation",
|
56 |
+
model="h2oai/h2o-danube-1.8b-chat",
|
57 |
+
torch_dtype=torch.bfloat16,
|
58 |
+
device_map="auto",
|
59 |
+
)
|
60 |
+
|
61 |
+
# We use the HF Tokenizer chat template to format each message
|
62 |
+
# https://huggingface.co/docs/transformers/main/en/chat_templating
|
63 |
+
messages = [
|
64 |
+
{"role": "user", "content": "Why is drinking water so healthy?"},
|
65 |
+
]
|
66 |
+
prompt = pipe.tokenizer.apply_chat_template(
|
67 |
+
messages,
|
68 |
+
tokenize=False,
|
69 |
+
add_generation_prompt=True,
|
70 |
+
)
|
71 |
+
res = pipe(
|
72 |
+
prompt,
|
73 |
+
max_new_tokens=256,
|
74 |
+
)
|
75 |
+
print(res[0]["generated_text"])
|
76 |
+
# <|system|>You are a friendly chatbot</s><|prompt|>Why is drinking water so healthy?</s><|answer|> Drinking water is healthy for several reasons: [...]
|
77 |
+
```
|
78 |
+
|
79 |
+
## Benchmarks
|
80 |
+
|
81 |
+
Commonsense, world-knowledge and reading comprehension tested in 0-shot:
|
82 |
+
|
83 |
+
| Benchmark | acc_n |
|
84 |
+
|:--------------|:--------:|
|
85 |
+
| ARC-easy | 67.51 |
|
86 |
+
| ARC-challenge | 39.25 |
|
87 |
+
| BoolQ | 77.89 |
|
88 |
+
| Hellaswag | 67.60 |
|
89 |
+
| OpenBookQA | 39.20 |
|
90 |
+
| PiQA | 76.71 |
|
91 |
+
| TriviaQA | 36.29 |
|
92 |
+
| Winogrande | 65.35 |
|
93 |
+
|
94 |
+
## Quantization and sharding
|
95 |
+
|
96 |
+
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```.
|
97 |
+
|
98 |
+
## Model Architecture
|
99 |
+
|
100 |
+
```
|
101 |
+
MistralForCausalLM(
|
102 |
+
(model): MistralModel(
|
103 |
+
(embed_tokens): Embedding(32000, 2560, padding_idx=0)
|
104 |
+
(layers): ModuleList(
|
105 |
+
(0-23): 24 x MistralDecoderLayer(
|
106 |
+
(self_attn): MistralAttention(
|
107 |
+
(q_proj): Linear(in_features=2560, out_features=2560, bias=False)
|
108 |
+
(k_proj): Linear(in_features=2560, out_features=640, bias=False)
|
109 |
+
(v_proj): Linear(in_features=2560, out_features=640, bias=False)
|
110 |
+
(o_proj): Linear(in_features=2560, out_features=2560, bias=False)
|
111 |
+
(rotary_emb): MistralRotaryEmbedding()
|
112 |
+
)
|
113 |
+
(mlp): MistralMLP(
|
114 |
+
(gate_proj): Linear(in_features=2560, out_features=6912, bias=False)
|
115 |
+
(up_proj): Linear(in_features=2560, out_features=6912, bias=False)
|
116 |
+
(down_proj): Linear(in_features=6912, out_features=2560, bias=False)
|
117 |
+
(act_fn): SiLU()
|
118 |
+
)
|
119 |
+
(input_layernorm): MistralRMSNorm()
|
120 |
+
(post_attention_layernorm): MistralRMSNorm()
|
121 |
+
)
|
122 |
+
)
|
123 |
+
(norm): MistralRMSNorm()
|
124 |
+
)
|
125 |
+
(lm_head): Linear(in_features=2560, out_features=32000, bias=False)
|
126 |
+
)
|
127 |
+
```
|
128 |
+
|
129 |
+
## Model Configuration
|
130 |
+
|
131 |
+
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.
|
132 |
+
|
133 |
+
|
134 |
+
## Disclaimer
|
135 |
+
|
136 |
+
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.
|
137 |
+
|
138 |
+
- 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.
|
139 |
+
- 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.
|
140 |
+
- 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.
|
141 |
+
- 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.
|
142 |
+
- 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.
|
143 |
+
- 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.
|
144 |
+
|
145 |
+
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.
|
cfg.yaml
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
architecture:
|
2 |
+
backbone_dtype: bfloat16
|
3 |
+
force_embedding_gradients: false
|
4 |
+
gradient_checkpointing: true
|
5 |
+
intermediate_dropout: 0.0
|
6 |
+
pretrained: true
|
7 |
+
pretrained_weights: ''
|
8 |
+
augmentation:
|
9 |
+
neftune_noise_alpha: 0.0
|
10 |
+
random_parent_probability: 0.0
|
11 |
+
skip_parent_probability: 0.0
|
12 |
+
token_mask_probability: 0.0
|
13 |
+
dataset:
|
14 |
+
add_eos_token_to_answer: true
|
15 |
+
add_eos_token_to_prompt: true
|
16 |
+
add_eos_token_to_system: true
|
17 |
+
answer_column: output_min_rank
|
18 |
+
chatbot_author: H2O.ai
|
19 |
+
chatbot_name: h2oGPT
|
20 |
+
data_sample: 1.0
|
21 |
+
data_sample_choice:
|
22 |
+
- Train
|
23 |
+
- Validation
|
24 |
+
limit_chained_samples: true
|
25 |
+
mask_prompt_labels: true
|
26 |
+
parent_id_column: parent_id
|
27 |
+
personalize: false
|
28 |
+
prompt_column:
|
29 |
+
- instruction
|
30 |
+
rejected_answer_column: output_max_rank
|
31 |
+
system_column: None
|
32 |
+
text_answer_separator: <|answer|>
|
33 |
+
text_prompt_start: <|prompt|>
|
34 |
+
text_system_start: <|system|>
|
35 |
+
train_dataframe: dpo.pq
|
36 |
+
validation_dataframe: None
|
37 |
+
validation_size: 0.01
|
38 |
+
validation_strategy: automatic
|
39 |
+
environment:
|
40 |
+
compile_model: false
|
41 |
+
deepspeed_reduce_bucket_size: 1000000
|
42 |
+
deepspeed_stage3_param_persistence_threshold: 1000000
|
43 |
+
deepspeed_stage3_prefetch_bucket_size: 1000000
|
44 |
+
find_unused_parameters: false
|
45 |
+
gpus:
|
46 |
+
- '0'
|
47 |
+
- '1'
|
48 |
+
- '2'
|
49 |
+
huggingface_branch: main
|
50 |
+
mixed_precision: true
|
51 |
+
number_of_workers: 8
|
52 |
+
seed: -1
|
53 |
+
trust_remote_code: true
|
54 |
+
use_deepspeed: false
|
55 |
+
experiment_name: h2o-danube-1.8b-chat
|
56 |
+
llm_backbone: h2oai/h2o-danube-1.8b-base
|
57 |
+
logging:
|
58 |
+
logger: Neptune
|
59 |
+
neptune_project: ''
|
60 |
+
output_directory: output/
|
61 |
+
prediction:
|
62 |
+
batch_size_inference: 0
|
63 |
+
do_sample: false
|
64 |
+
max_length_inference: 256
|
65 |
+
metric: Perplexity
|
66 |
+
metric_gpt_model: gpt-3.5-turbo-0301
|
67 |
+
metric_gpt_template: general
|
68 |
+
min_length_inference: 2
|
69 |
+
num_beams: 1
|
70 |
+
num_history: 4
|
71 |
+
repetition_penalty: 1.0
|
72 |
+
stop_tokens: ''
|
73 |
+
temperature: 0.0
|
74 |
+
top_k: 0
|
75 |
+
top_p: 1.0
|
76 |
+
problem_type: text_dpo_modeling
|
77 |
+
tokenizer:
|
78 |
+
add_prefix_space: false
|
79 |
+
add_prompt_answer_tokens: false
|
80 |
+
max_length: 16384
|
81 |
+
max_length_answer: 8192
|
82 |
+
max_length_prompt: 8192
|
83 |
+
padding_quantile: 1.0
|
84 |
+
use_fast: true
|
85 |
+
training:
|
86 |
+
batch_size: 2
|
87 |
+
beta: 0.2
|
88 |
+
differential_learning_rate: 1.0e-05
|
89 |
+
differential_learning_rate_layers: []
|
90 |
+
drop_last_batch: true
|
91 |
+
epochs: 1
|
92 |
+
evaluate_before_training: false
|
93 |
+
evaluation_epochs: 1.0
|
94 |
+
grad_accumulation: 1
|
95 |
+
gradient_clip: 10.0
|
96 |
+
learning_rate: 3.0e-06
|
97 |
+
lora: true
|
98 |
+
lora_alpha: 16
|
99 |
+
lora_dropout: 0.05
|
100 |
+
lora_r: 4
|
101 |
+
lora_target_modules: ''
|
102 |
+
loss_function: DPOLoss
|
103 |
+
optimizer: AdamW
|
104 |
+
save_best_checkpoint: false
|
105 |
+
schedule: Cosine
|
106 |
+
train_validation_data: false
|
107 |
+
use_flash_attention_2: true
|
108 |
+
warmup_epochs: 0.05
|
109 |
+
weight_decay: 0.0
|
config.json
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "h2oai/h2o-danube-1.8b-chat",
|
3 |
+
"architectures": [
|
4 |
+
"MistralForCausalLM"
|
5 |
+
],
|
6 |
+
"attention_dropout": 0.0,
|
7 |
+
"bos_token_id": 1,
|
8 |
+
"eos_token_id": 2,
|
9 |
+
"hidden_act": "silu",
|
10 |
+
"hidden_size": 2560,
|
11 |
+
"initializer_range": 0.02,
|
12 |
+
"intermediate_size": 6912,
|
13 |
+
"max_position_embeddings": 16384,
|
14 |
+
"model_type": "mistral",
|
15 |
+
"num_attention_heads": 32,
|
16 |
+
"num_hidden_layers": 24,
|
17 |
+
"num_key_value_heads": 8,
|
18 |
+
"pad_token_id": 0,
|
19 |
+
"pretraining_tp": 1,
|
20 |
+
"rms_norm_eps": 1e-05,
|
21 |
+
"rope_scaling": null,
|
22 |
+
"rope_theta": 10000.0,
|
23 |
+
"sliding_window": 4096,
|
24 |
+
"tie_word_embeddings": false,
|
25 |
+
"torch_dtype": "bfloat16",
|
26 |
+
"transformers_version": "4.36.2",
|
27 |
+
"use_cache": true,
|
28 |
+
"vocab_size": 32000
|
29 |
+
}
|
generation_config.json
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.36.2",
|
7 |
+
"repetition_penalty": 1.1
|
8 |
+
}
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2a9a72b0fb854d00c0f624f640376ba95c46746350187c6352bf5f4159c8d936
|
3 |
+
size 3662427808
|
special_tokens_map.json
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<s>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": false,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"cls_token": {
|
10 |
+
"content": "</s>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": false,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"eos_token": {
|
17 |
+
"content": "</s>",
|
18 |
+
"lstrip": false,
|
19 |
+
"normalized": false,
|
20 |
+
"rstrip": false,
|
21 |
+
"single_word": false
|
22 |
+
},
|
23 |
+
"pad_token": {
|
24 |
+
"content": "<unk>",
|
25 |
+
"lstrip": false,
|
26 |
+
"normalized": false,
|
27 |
+
"rstrip": false,
|
28 |
+
"single_word": false
|
29 |
+
},
|
30 |
+
"sep_token": {
|
31 |
+
"content": "</s>",
|
32 |
+
"lstrip": false,
|
33 |
+
"normalized": false,
|
34 |
+
"rstrip": false,
|
35 |
+
"single_word": false
|
36 |
+
},
|
37 |
+
"unk_token": {
|
38 |
+
"content": "<unk>",
|
39 |
+
"lstrip": false,
|
40 |
+
"normalized": false,
|
41 |
+
"rstrip": false,
|
42 |
+
"single_word": false
|
43 |
+
}
|
44 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9e556afd44213b6bd1be2b850ebbbd98f5481437a8021afaf58ee7fb1818d347
|
3 |
+
size 499723
|
tokenizer_config.json
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": true,
|
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 |
+
"bos_token": "<s>",
|
32 |
+
"chat_template": "{% for message in messages %}{% if message['role'] == 'user' %}{{ '<|prompt|>' + message['content'] + eos_token }}{% elif message['role'] == 'system' %}{{ '<|system|>' + message['content'] + eos_token }}{% elif message['role'] == 'assistant' %}{{ '<|answer|>' + message['content'] + eos_token }}{% endif %}{% if loop.last and add_generation_prompt %}{{ '<|answer|>' }}{% endif %}{% endfor %}",
|
33 |
+
"clean_up_tokenization_spaces": false,
|
34 |
+
"cls_token": "</s>",
|
35 |
+
"eos_token": "</s>",
|
36 |
+
"legacy": false,
|
37 |
+
"model_max_length": 1000000000000000019884624838656,
|
38 |
+
"pad_token": "<unk>",
|
39 |
+
"padding_side": "left",
|
40 |
+
"sep_token": "</s>",
|
41 |
+
"sp_model_kwargs": {},
|
42 |
+
"tokenizer_class": "LlamaTokenizer",
|
43 |
+
"unk_token": "<unk>",
|
44 |
+
"use_default_system_prompt": false
|
45 |
+
}
|