Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- HuggingFaceH4/no_robots
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
pipeline_tag: text-generation
|
8 |
+
thumbnail: https://huggingface.co/mrm8488/limstral-7B-v0.1/resolve/main/limstral_logo.png
|
9 |
+
---
|
10 |
+
|
11 |
+
## Mistral 7B fine-tuned on H4/No Robots instructions
|
12 |
+
This model is a fine-tuned version of [mistralai/Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1) on the [HuggingFaceH4/no_robots](https://huggingface.co/datasets/HuggingFaceH4/no_robots) dataset for instruction following downstream task.
|
13 |
+
|
14 |
+
## Training procedure
|
15 |
+
|
16 |
+
The model was loaded on **8 bits** and fine-tuned on the LIMA dataset using the **LoRA** PEFT technique with the `huggingface/peft` library and `trl/sft` for one epoch on 1 x A100 (40GB) GPU.
|
17 |
+
|
18 |
+
SFT Trainer params:
|
19 |
+
```
|
20 |
+
trainer = SFTTrainer(
|
21 |
+
model=model,
|
22 |
+
train_dataset=train_ds,
|
23 |
+
eval_dataset=test_ds,
|
24 |
+
peft_config=peft_config,
|
25 |
+
dataset_text_field="text",
|
26 |
+
max_seq_length=2048,
|
27 |
+
tokenizer=tokenizer,
|
28 |
+
args=training_arguments,
|
29 |
+
packing=False
|
30 |
+
)
|
31 |
+
```
|
32 |
+
|
33 |
+
LoRA config:
|
34 |
+
```
|
35 |
+
config = LoraConfig(
|
36 |
+
lora_alpha=16,
|
37 |
+
lora_dropout=0.1,
|
38 |
+
r=64,
|
39 |
+
bias="none",
|
40 |
+
task_type="CAUSAL_LM",
|
41 |
+
target_modules = ['q_proj', 'k_proj', 'down_proj', 'v_proj', 'o_proj', 'gate_proj', 'up_proj']
|
42 |
+
)
|
43 |
+
```
|
44 |
+
|
45 |
+
### Training hyperparameters
|
46 |
+
|
47 |
+
The following hyperparameters were used during training:
|
48 |
+
- learning_rate: 0.0002
|
49 |
+
- train_batch_size: 2
|
50 |
+
- eval_batch_size: 8
|
51 |
+
- seed: 66
|
52 |
+
- gradient_accumulation_steps: 64
|
53 |
+
- total_train_batch_size: 128
|
54 |
+
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
55 |
+
- lr_scheduler_type: cosine
|
56 |
+
- lr_scheduler_warmup_ratio: 0.03
|
57 |
+
- num_epochs: 2
|
58 |
+
- mixed_precision_training: Native AMP
|
59 |
+
|
60 |
+
### Training results
|
61 |
+
|
62 |
+
| Step | Training Loss | Validation Loss |
|
63 |
+
|------|---------------|-----------------|
|
64 |
+
| 10 | 1.796200 | 1.774305 |
|
65 |
+
| 20 | 1.769700 | 1.679720 |
|
66 |
+
| 30 | 1.626800 | 1.667754 |
|
67 |
+
| 40 | 1.663400 | 1.665188 |
|
68 |
+
| 50 | 1.565700 | 1.659000 |
|
69 |
+
| 60 | 1.660300 | 1.658270 |
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
+
|
74 |
+
### Usage
|
75 |
+
```py
|
76 |
+
import torch
|
77 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
78 |
+
|
79 |
+
repo_id = "mrm8488/mistral-7b-ft-h4-no_robots_instructions"
|
80 |
+
|
81 |
+
model = AutoModelForCausalLM.from_pretrained(repo_id, torch_dtype=torch.bfloat16)
|
82 |
+
tokenizer = AutoTokenizer.from_pretrained(repo_id)
|
83 |
+
|
84 |
+
gen = pipeline("text-generation", model=model, tokenizer=tokenizer, device=0)
|
85 |
+
|
86 |
+
instruction = "[INST] Write an email to say goodbye to me boss [\INST]"
|
87 |
+
res = gen(instruction, max_new_tokens=512, temperature=0.3, top_p=0.75, top_k=40, repetition_penalty=1.2, eos_token_id=2)
|
88 |
+
print(res[0]['generated_text'])
|
89 |
+
```
|
90 |
+
|
91 |
+
### Framework versions
|
92 |
+
|
93 |
+
- Transformers 4.35.0.dev0
|
94 |
+
- Pytorch 2.1.0+cu118
|
95 |
+
- Datasets 2.14.6
|
96 |
+
- Tokenizers 0.14.1
|