Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
base_model: mistralai/Mistral-7B-v0.1
|
4 |
+
datasets:
|
5 |
+
- yahma/alpaca-cleaned
|
6 |
+
tags:
|
7 |
+
- sft
|
8 |
+
---
|
9 |
+
|
10 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/6XBMkYdr4qd_1GcBP4zu0.png)
|
11 |
+
|
12 |
+
# 🦙 Mistralpaca-7B
|
13 |
+
|
14 |
+
Mistral-7B model supervised fine-tuned on the [vicgalle/alpaca-gpt4](https://huggingface.co/datasets/vicgalle/alpaca-gpt4) dataset.
|
15 |
+
|
16 |
+
## 🧩 Configuration
|
17 |
+
|
18 |
+
```yaml
|
19 |
+
base_model: mistralai/Mistral-7B-v0.1
|
20 |
+
model_type: MistralForCausalLM
|
21 |
+
tokenizer_type: LlamaTokenizer
|
22 |
+
is_mistral_derived_model: true
|
23 |
+
|
24 |
+
load_in_8bit: false
|
25 |
+
load_in_4bit: true
|
26 |
+
strict: false
|
27 |
+
|
28 |
+
datasets:
|
29 |
+
- path: vicgalle/alpaca-gpt4
|
30 |
+
type: alpaca
|
31 |
+
|
32 |
+
dataset_prepared_path:
|
33 |
+
val_set_size: 0.01
|
34 |
+
output_dir: ./out
|
35 |
+
|
36 |
+
sequence_len: 2048
|
37 |
+
sample_packing: true
|
38 |
+
pad_to_sequence_len: true
|
39 |
+
|
40 |
+
adapter: qlora
|
41 |
+
lora_model_dir:
|
42 |
+
lora_r: 32
|
43 |
+
lora_alpha: 64
|
44 |
+
lora_dropout: 0.05
|
45 |
+
lora_target_linear: true
|
46 |
+
|
47 |
+
wandb_project: axolotl
|
48 |
+
wandb_entity:
|
49 |
+
wandb_watch:
|
50 |
+
wandb_name:
|
51 |
+
wandb_log_model:
|
52 |
+
|
53 |
+
gradient_accumulation_steps: 3
|
54 |
+
micro_batch_size: 4
|
55 |
+
num_epochs: 3
|
56 |
+
optimizer: adamw_bnb_8bit
|
57 |
+
lr_scheduler: cosine
|
58 |
+
learning_rate: 0.0002
|
59 |
+
|
60 |
+
train_on_inputs: false
|
61 |
+
group_by_length: false
|
62 |
+
bf16: auto
|
63 |
+
fp16:
|
64 |
+
tf32: false
|
65 |
+
|
66 |
+
gradient_checkpointing: true
|
67 |
+
early_stopping_patience:
|
68 |
+
resume_from_checkpoint:
|
69 |
+
local_rank:
|
70 |
+
logging_steps: 1
|
71 |
+
xformers_attention:
|
72 |
+
flash_attention: true
|
73 |
+
|
74 |
+
warmup_steps: 10
|
75 |
+
evals_per_epoch: 4
|
76 |
+
eval_table_size:
|
77 |
+
eval_table_max_new_tokens: 128
|
78 |
+
saves_per_epoch: 1
|
79 |
+
debug:
|
80 |
+
deepspeed:
|
81 |
+
weight_decay: 0.1
|
82 |
+
fsdp:
|
83 |
+
fsdp_config:
|
84 |
+
special_tokens:
|
85 |
+
bos_token: <s>
|
86 |
+
eos_token: </s>
|
87 |
+
unk_token: <unk>
|
88 |
+
```
|
89 |
+
|
90 |
+
## 💻 Usage
|
91 |
+
|
92 |
+
```python
|
93 |
+
!pip install -qU transformers accelerate
|
94 |
+
|
95 |
+
from transformers import AutoTokenizer
|
96 |
+
import transformers
|
97 |
+
import torch
|
98 |
+
|
99 |
+
model = "mlabonne/Mistralpaca-7B"
|
100 |
+
messages = [{"role": "user", "content": "What is a large language model?"}]
|
101 |
+
|
102 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
103 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
104 |
+
pipeline = transformers.pipeline(
|
105 |
+
"text-generation",
|
106 |
+
model=model,
|
107 |
+
torch_dtype=torch.float16,
|
108 |
+
device_map="auto",
|
109 |
+
)
|
110 |
+
|
111 |
+
outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
|
112 |
+
print(outputs[0]["generated_text"])
|
113 |
+
```
|