Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: llama2
|
| 3 |
+
datasets:
|
| 4 |
+
- mlabonne/alpagasus
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
pipeline_tag: text-generation
|
| 8 |
+
tags:
|
| 9 |
+
- llama
|
| 10 |
+
- alpaca
|
| 11 |
+
- alpagasus
|
| 12 |
+
---
|
| 13 |
+
# 🦙🕊️ Alpagasus-2-7b
|
| 14 |
+
|
| 15 |
+
📝 [Paper](https://arxiv.org/abs/2307.08701) | 📄 [Blog](https://lichang-chen.github.io/AlpaGasus/) | 💻 [Code](https://github.com/gpt4life/alpagasus/tree/main) | 🤗 [Model](https://huggingface.co/gpt4life/alpagasus-7b) (unofficial)
|
| 16 |
+
|
| 17 |
+
This is a `Llama-2-7b-hf` model fine-tuned using QLoRA (4-bit precision) on the [`mlabonne/alpagasus`](https://huggingface.co/datasets/mlabonne/alpagasus) dataset, which is a high-quality subset (9k samples) of the Alpaca dataset (52k samples).
|
| 18 |
+
|
| 19 |
+
## 🔧 Training
|
| 20 |
+
|
| 21 |
+

|
| 22 |
+
|
| 23 |
+
It was trained on an RTX 3090 using the [🐜🔧TinyTuner](https://github.com/mlabonne/tinytuner). Parameters:
|
| 24 |
+
|
| 25 |
+
```yaml
|
| 26 |
+
# Dataset
|
| 27 |
+
dataset_name: mlabonne/alpagasus
|
| 28 |
+
prompt_template: alpaca
|
| 29 |
+
max_seq_length: 512
|
| 30 |
+
val_set_size: 0.01
|
| 31 |
+
|
| 32 |
+
# Loading
|
| 33 |
+
load_in_8bit: false
|
| 34 |
+
load_in_4bit: true
|
| 35 |
+
bf16: true
|
| 36 |
+
fp16: false
|
| 37 |
+
tf32: true
|
| 38 |
+
|
| 39 |
+
# Lora
|
| 40 |
+
adapter: qlora
|
| 41 |
+
lora_model_dir:
|
| 42 |
+
lora_r: 8
|
| 43 |
+
lora_alpha: 16
|
| 44 |
+
lora_dropout: 0.1
|
| 45 |
+
lora_target_modules:
|
| 46 |
+
- q_proj
|
| 47 |
+
- v_proj
|
| 48 |
+
lora_fan_in_fan_out:
|
| 49 |
+
|
| 50 |
+
# Training
|
| 51 |
+
learning_rate: 0.00002
|
| 52 |
+
micro_batch_size: 24
|
| 53 |
+
gradient_accumulation_steps: 1
|
| 54 |
+
num_epochs: 3
|
| 55 |
+
lr_scheduler_type: cosine
|
| 56 |
+
optim: paged_adamw_32bit
|
| 57 |
+
group_by_length: true
|
| 58 |
+
warmup_ratio: 0.03
|
| 59 |
+
eval_steps: 0.01
|
| 60 |
+
save_strategy: epoch
|
| 61 |
+
logging_steps: 1
|
| 62 |
+
weight_decay: 0
|
| 63 |
+
max_grad_norm:
|
| 64 |
+
max_steps: -1
|
| 65 |
+
gradient_checkpointing: true
|
| 66 |
+
|
| 67 |
+
# QLoRA
|
| 68 |
+
bnb_4bit_compute_dtype: float16
|
| 69 |
+
bnb_4bit_quant_type: nf4
|
| 70 |
+
bnb_4bit_use_double_quant: false
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
## 💻 Usage
|
| 74 |
+
|
| 75 |
+
``` python
|
| 76 |
+
# pip install transformers accelerate
|
| 77 |
+
|
| 78 |
+
from transformers import AutoTokenizer
|
| 79 |
+
import transformers
|
| 80 |
+
import torch
|
| 81 |
+
|
| 82 |
+
model = "mlabonne/alpagasus-2-7b"
|
| 83 |
+
prompt = "What is a large language model?"
|
| 84 |
+
|
| 85 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
| 86 |
+
pipeline = transformers.pipeline(
|
| 87 |
+
"text-generation",
|
| 88 |
+
model=model,
|
| 89 |
+
torch_dtype=torch.float16,
|
| 90 |
+
device_map="auto",
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
sequences = pipeline(
|
| 94 |
+
f'### Instruction: {prompt}',
|
| 95 |
+
do_sample=True,
|
| 96 |
+
top_k=10,
|
| 97 |
+
num_return_sequences=1,
|
| 98 |
+
eos_token_id=tokenizer.eos_token_id,
|
| 99 |
+
max_length=200,
|
| 100 |
+
)
|
| 101 |
+
for seq in sequences:
|
| 102 |
+
print(f"Result: {seq['generated_text']}")
|
| 103 |
+
```
|