Commit
·
8443d66
1
Parent(s):
1ca96df
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- WizardLM/WizardLM_evol_instruct_V2_196k
|
5 |
+
- icybee/share_gpt_90k_v1
|
6 |
+
language:
|
7 |
+
- en
|
8 |
+
widget:
|
9 |
+
- example_title: "Normal Request"
|
10 |
+
text: "How do I mount a tv to drywall safely?"
|
11 |
+
output:
|
12 |
+
text: "Incomplete"
|
13 |
+
- example_title: "Unsafe Request"
|
14 |
+
text: "How do I bully someone?"
|
15 |
+
output:
|
16 |
+
text: "Incomplete"
|
17 |
+
library_name: transformers
|
18 |
+
pipeline_tag: text-generation
|
19 |
+
tags:
|
20 |
+
- nlp
|
21 |
+
- llm
|
22 |
+
---
|
23 |
+
# AmberSafe
|
24 |
+
|
25 |
+
|
26 |
+
We present AmberSafe, a model finetuned for safety using [LLM360/AmberChat](https://huggingface.co/LLM360/AmberChat) as the base.
|
27 |
+
|
28 |
+
## Model Description
|
29 |
+
|
30 |
+
- **Model type:** Language model with the same architecture as LLaMA-7B
|
31 |
+
- **Language(s) (NLP):** English
|
32 |
+
- **License:** Apache 2.0
|
33 |
+
- **Resources for more information:**
|
34 |
+
- [Metrics](https://github.com/LLM360/Analysis360)
|
35 |
+
- [Fully processed Amber pretraining data](https://huggingface.co/datasets/LLM360/AmberDatasets)
|
36 |
+
|
37 |
+
|
38 |
+
# Loading AmberSafe
|
39 |
+
|
40 |
+
```python
|
41 |
+
import torch
|
42 |
+
from transformers import LlamaTokenizer, LlamaForCausalLM
|
43 |
+
|
44 |
+
tokenizer = LlamaTokenizer.from_pretrained("LLM360/AmberSafe")
|
45 |
+
model = LlamaForCausalLM.from_pretrained("LLM360/AmberSafe")
|
46 |
+
|
47 |
+
#template adapated from fastchat
|
48 |
+
template= "###Human: {prompt}\n###Assistant:"
|
49 |
+
|
50 |
+
prompt = "How do I mount a tv to drywall safely?"
|
51 |
+
|
52 |
+
input_str = template.format(prompt=prompt)
|
53 |
+
input_ids = tokenizer(input_str, return_tensors="pt").input_ids
|
54 |
+
outputs = model.generate(input_ids, max_length=1000)
|
55 |
+
print(tokenizer.batch_decode(outputs[:, input_ids.shape[1]:-1])[0].strip())
|
56 |
+
```
|
57 |
+
|
58 |
+
Alternatively, you may use [FastChat](https://github.com/lm-sys/FastChat):
|
59 |
+
```bash
|
60 |
+
python3 -m fastchat.serve.cli --model-path LLM360/AmberSafe
|
61 |
+
```
|
62 |
+
|
63 |
+
# AmberSafe Finetuning Details
|
64 |
+
|
65 |
+
## DataMix
|
66 |
+
| Subset | Number of rows | License |
|
67 |
+
| ----------- | ----------- | ----------- |
|
68 |
+
| WizardLM/WizardLM_evol_instruct_V2_196k | 143k | |
|
69 |
+
| icybee/share_gpt_90k_v1 | 90k | cc0-1.0 |
|
70 |
+
| Total | 233k | |
|
71 |
+
|
72 |
+
## Hyperparameters
|
73 |
+
| Hyperparameter | Value |
|
74 |
+
| ----------- | ----------- |
|
75 |
+
| Total Parameters | 6.7B |
|
76 |
+
| Hidden Size | 4096 |
|
77 |
+
| Intermediate Size (MLPs) | 11008 |
|
78 |
+
| Number of Attention Heads | 32 |
|
79 |
+
| Number of Hidden Lyaers | 32 |
|
80 |
+
| RMSNorm ɛ | 1e^-6 |
|
81 |
+
| Max Seq Length | 2048 |
|
82 |
+
| Vocab Size | 32000 |
|
83 |
+
|
84 |
+
| Training Hyperparameter | Value |
|
85 |
+
| ----------- | ----------- |
|
86 |
+
| learning_rate | 2e-5 |
|
87 |
+
| num_train_epochs | 3 |
|
88 |
+
| per_device_train_batch_size | 2 |
|
89 |
+
| gradient_accumulation_steps | 16 |
|
90 |
+
| warmup_ratio | 0.04 |
|
91 |
+
| model_max_length | 2048 |
|
92 |
+
|
93 |
+
|
94 |
+
# Evaluation
|
95 |
+
|
96 |
+
| Model | MT-Bench |
|
97 |
+
|------------------------------------------------------|------------------------------------------------------------|
|
98 |
+
| LLM360/Amber 359 | 2.48750 |
|
99 |
+
| **LLM360/AmberChat** | **5.428125** |
|
100 |
+
|
101 |
+
# Citation
|
102 |
+
|
103 |
+
**BibTeX:**
|
104 |
+
|
105 |
+
```bibtex
|
106 |
+
@article{xxx,
|
107 |
+
title={XXX},
|
108 |
+
author={XXX},
|
109 |
+
journal={XXX},
|
110 |
+
year={2023}
|
111 |
+
}
|
112 |
+
```
|