File size: 6,206 Bytes
a035832
9c71d59
a035832
 
 
 
 
 
 
 
9c71d59
 
 
a035832
 
9c71d59
 
 
 
 
 
 
 
 
 
 
 
a035832
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9c71d59
a035832
 
9c71d59
a035832
 
 
 
9c71d59
a035832
9c71d59
 
 
431f2e6
 
 
 
 
9c71d59
 
 
 
0767860
9c71d59
 
 
0767860
9c71d59
 
 
0767860
9c71d59
 
 
0767860
9c71d59
 
 
 
0767860
0fb000c
9c71d59
 
 
 
 
 
 
a035832
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9c71d59
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
---
inference: false
license: mit
base_model: microsoft/phi-2
tags:
- axolotl
- generated_from_trainer
model-index:
- name: Phasmid-2_v2
  results: []
datasets:
- PygmalionAI/PIPPA
- HuggingFaceH4/no_robots
---


```
   _ (`-.  ('-. .-.   ('-.      .-')   _   .-')            _ .-') _  
  ( (OO  )( OO )  /  ( OO ).-. ( OO ).( '.( OO )_         ( (  OO) )  
 _.`     \,--. ,--.  / . --. /(_)---\_),--.   ,--.) ,-.-') \     .'_  
(__...--''|  | |  |  | \-.  \ /    _ | |   `.'   |  |  |OO),`'--..._)
 |  /  | ||   .|  |.-'-'  |  |\  :` `. |         |  |  |  \|  |  \  '  
 |  |_.' ||       | \| |_.'  | '..`''.)|  |'.'|  |  |  |(_/|  |   ' |  
 |  .___.'|  .-.  |  |  .-.  |.-._)   \|  |   |  | ,|  |_.'|  |   / :  
 |  |     |  | |  |  |  | |  |\       /|  |   |  |(_|  |   |  '--'  / 
 `--'     `--' `--'  `--' `--' `-----' `--'   `--'  `--'   `-------'  
```

[<img src="https://raw.githubusercontent.com/OpenAccess-AI-Collective/axolotl/main/image/axolotl-badge-web.png" alt="Built with Axolotl" width="200" height="32"/>](https://github.com/OpenAccess-AI-Collective/axolotl)
<details><summary>See axolotl config</summary>

axolotl version: `0.3.0`
```yaml
base_model: microsoft/phi-2
model_type: PhiForCausalLM
tokenizer_type: AutoTokenizer
is_llama_derived_model: false
trust_remote_code: true

load_in_8bit: false
load_in_4bit: false
strict: false

datasets:
  - path: SE6446/SE6446_phasmid_ds
    type: completion

hub_model_id: SE6446/Phasmid-2_v2
hub_strategy: every_save
use_auth_token: true
dataset_prepared_path: /phasmid-2-ds-path
val_set_size: 0.05
output_dir: ./phasmid-sft-out

sequence_len: 2048
sample_packing: true
pad_to_sequence_len:

adapter:
lora_model_dir:
lora_r:
lora_alpha:
lora_dropout:
lora_target_linear:
lora_fan_in_fan_out:

wandb_project: 
wandb_entity: 
wandb_watch:
wandb_name: 
wandb_log_model:

gradient_accumulation_steps: 1
micro_batch_size: 1
num_epochs: 4
optimizer: adamw_torch
adam_beta2: 0.95
adam_epsilon: 0.00001
max_grad_norm: 1.0
lr_scheduler: cosine
learning_rate: 0.0003

train_on_inputs: false
group_by_length: true
bf16: true
fp16: false
tf32: true

gradient_checkpointing:
early_stopping_patience:
resume_from_checkpoint:
local_rank:
logging_steps: 1
xformers_attention:
flash_attention:

warmup_steps: 100
evals_per_epoch: 4
saves_per_epoch: 1
debug:
deepspeed:
weight_decay: 0.1
fsdp:
fsdp_config:
resize_token_embeddings_to_32x: true
special_tokens:
  bos_token: "<|endoftext|>"
  eos_token: "<|endoftext|>"
  unk_token: "<|endoftext|>"
  pad_token: "<|endoftext|>"

```

</details><br>


# Phasmid-2_v2

This model is a fine-tuned version of [microsoft/phi-2](https://huggingface.co/microsoft/phi-2) on a mix of no_robots and the PIPPA dataset.
It achieves the following results on the evaluation set:
- Loss: 2.2924

## Model description
Phasmid-2 has been trained on intructional data and thus can perform far better at instruction following than phi-2. However I have not extensively tested the model.
## Intended uses & limitations
This model is little more than a side project and I shall treat it as such. 
Phasmid-2 (due to it's size), can still suffer from problematic hallucinations and poor information. No effort was made to reduce potentially toxic responses, as such you should train this model further if you require it to do so.
## Inference
Ensure that eniops is installed
```
pip install einops
```

Phi doesn't like device_map = auto, therefore you should specify as like the following:

1. FP16 / Flash-Attention / CUDA:
   ```python
   model = AutoModelForCausalLM.from_pretrained("SE6446/Phasmid-2_v2", torch_dtype="auto", flash_attn=True, flash_rotary=True, fused_dense=True, device_map="cuda", trust_remote_code=True)
   ```
2. FP16 / CUDA:
   ```python
   model = AutoModelForCausalLM.from_pretrained("SE6446/Phasmid-2_v2", torch_dtype="auto", device_map="cuda", trust_remote_code=True)
   ```
3. FP32 / CUDA:
   ```python
   model = AutoModelForCausalLM.from_pretrained("SE6446/Phasmid-2_v2", torch_dtype=torch.float32, device_map="cuda", trust_remote_code=True)
   ```
4. FP32 / CPU:
   ```python
   model = AutoModelForCausalLM.from_pretrained("SE6446/Phasmid-2_v2", torch_dtype=torch.float32, device_map="cpu", trust_remote_code=True)
   ```

And then use the following snippet
```python
tokenizer = AutoTokenizer.from_pretrained("SE6446/Phasmid-2_v2", trust_remote_code=True, torch_dtype="auto")
inputs = tokenizer('''SYSTEM: You are a helpful assistant. Please answer truthfully and politely. {custom_prompt}\n
                      USER: {{userinput}}\n
                      ASSISTANT: {{character name if applicable}}:''', return_tensors="pt", return_attention_mask=False)
outputs = model.generate(**inputs, max_length=200)
text = tokenizer.batch_decode(outputs)[0]
print(text)
```
it should generate after "ASSISTANT:".

## Training procedure

### Training hyperparameters

The following hyperparameters were used during training:
- learning_rate: 0.0003
- train_batch_size: 1
- eval_batch_size: 1
- seed: 42
- optimizer: Adam with betas=(0.9,0.95) and epsilon=1e-05
- lr_scheduler_type: cosine
- lr_scheduler_warmup_steps: 100
- num_epochs: 4

### Training results

| Training Loss | Epoch | Step  | Validation Loss |
|:-------------:|:-----:|:-----:|:---------------:|
| 2.3313        | 0.0   | 1     | 2.1374          |
| 2.5755        | 0.25  | 1319  | 2.5281          |
| 2.4864        | 0.5   | 2638  | 2.5314          |
| 2.0961        | 0.75  | 3957  | 2.4697          |
| 2.6547        | 1.0   | 5276  | 2.4213          |
| 2.1235        | 1.24  | 6595  | 2.3926          |
| 1.8875        | 1.49  | 7914  | 2.3233          |
| 0.9059        | 1.74  | 9233  | 2.2590          |
| 2.2046        | 1.99  | 10552 | 2.1985          |
| 1.1938        | 2.23  | 11871 | 2.2555          |
| 1.1425        | 2.48  | 13190 | 2.2393          |
| 0.6688        | 2.73  | 14509 | 2.2237          |
| 1.1111        | 2.98  | 15828 | 2.2126          |
| 0.651         | 3.21  | 17147 | 2.2859          |
| 0.8669        | 3.46  | 18466 | 2.2914          |
| 0.4149        | 3.71  | 19785 | 2.2924          |


### Framework versions

- Transformers 4.37.0.dev0
- Pytorch 2.0.1+cu118
- Datasets 2.16.1
- Tokenizers 0.15.0