Updated Home (markdown)

Daniel Han 2024-02-24 17:35:29 +11:00
commit d8ce12fe5d

45
Home.md

@ -55,23 +55,20 @@ model.save_pretrained_merged("model", tokenizer, save_method = "lora",)
model.push_to_hub_merged("hf/model", tokenizer, save_method = "lora", token = "")
```
### Evaluation Loop - also OOM or crashing.
Set the trainer settings for evaluation to:
```python
SFTTrainer(
args = TrainingArguments(
fp16_full_eval = True,
per_device_eval_batch_size = 2,
eval_accumulation_steps = 4,
evaluation_strategy = "steps",
eval_steps = 1,
),
train_dataset = train_dataset,
eval_dataset = eval_dataset,
```
This will cause no OOMs and make it somewhat faster with no upcasting to float32.
### Saving to GGUF
### GGUF quantization options
To save to GGUF, use the below to save locally:
```python
model.save_pretrained_gguf("dir", tokenizer, quantization_method = "q4_k_m")
model.save_pretrained_gguf("dir", tokenizer, quantization_method = "q8_0")
model.save_pretrained_gguf("dir", tokenizer, quantization_method = "f16")
```
For to push to hub:
```python
model.push_to_hub_gguf("hf_username/dir", tokenizer, quantization_method = "q4_k_m")
model.push_to_hub_gguf("hf_username/dir", tokenizer, quantization_method = "q8_0")
```
All supported quantization options for `quantization_method` are listed below:
```python
# https://github.com/ggerganov/llama.cpp/blob/master/examples/quantize/quantize.cpp#L19
# From https://mlabonne.github.io/blog/posts/Quantize_Llama_2_models_using_ggml.html
@ -105,6 +102,22 @@ ALLOWED_QUANTS = \
}
```
### Evaluation Loop - also OOM or crashing.
Set the trainer settings for evaluation to:
```python
SFTTrainer(
args = TrainingArguments(
fp16_full_eval = True,
per_device_eval_batch_size = 2,
eval_accumulation_steps = 4,
evaluation_strategy = "steps",
eval_steps = 1,
),
train_dataset = train_dataset,
eval_dataset = eval_dataset,
```
This will cause no OOMs and make it somewhat faster with no upcasting to float32.
### Chat Templates
Assuming your dataset is a list of list of dictionaries like the below:
```python