Update README.md
Browse files
README.md
CHANGED
|
@@ -9,4 +9,80 @@ license: other
|
|
| 9 |
license_name: llama3
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
license_name: llama3
|
| 10 |
---
|
| 11 |
|
| 12 |
+

|
| 13 |
+
|
| 14 |
+
# Mahou-1.0-llama3
|
| 15 |
+
|
| 16 |
+
Mahou is our attempt to build a production-ready conversational/roleplay LLM.
|
| 17 |
+
|
| 18 |
+
Future versions will be released iteratively and finetuned from flammen.ai conversational data.
|
| 19 |
+
|
| 20 |
+
NOTE: this model is experimental and currently significantly flawed.
|
| 21 |
+
|
| 22 |
+
### License
|
| 23 |
+
|
| 24 |
+
This model is based on Meta Llama-3-8B and is governed by the [META LLAMA 3 COMMUNITY LICENSE AGREEMENT](LICENSE).
|
| 25 |
+
|
| 26 |
+
### Method
|
| 27 |
+
|
| 28 |
+
Finetuned using an A100 on Google Colab.
|
| 29 |
+
|
| 30 |
+
[Fine-tune a Mistral-7b model with Direct Preference Optimization](https://towardsdatascience.com/fine-tune-a-mistral-7b-model-with-direct-preference-optimization-708042745aac) - [Maxime Labonne](https://huggingface.co/mlabonne)
|
| 31 |
+
|
| 32 |
+
### Configuration
|
| 33 |
+
|
| 34 |
+
LoRA, model, and training settings:
|
| 35 |
+
|
| 36 |
+
```python
|
| 37 |
+
# LoRA configuration
|
| 38 |
+
peft_config = LoraConfig(
|
| 39 |
+
r=16,
|
| 40 |
+
lora_alpha=16,
|
| 41 |
+
lora_dropout=0.05,
|
| 42 |
+
bias="none",
|
| 43 |
+
task_type="CAUSAL_LM",
|
| 44 |
+
target_modules=['k_proj', 'gate_proj', 'v_proj', 'up_proj', 'q_proj', 'o_proj', 'down_proj']
|
| 45 |
+
)
|
| 46 |
+
# Model to fine-tune
|
| 47 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 48 |
+
model_name,
|
| 49 |
+
torch_dtype=torch.bfloat16,
|
| 50 |
+
load_in_4bit=True
|
| 51 |
+
)
|
| 52 |
+
model.config.use_cache = False
|
| 53 |
+
# Reference model
|
| 54 |
+
ref_model = AutoModelForCausalLM.from_pretrained(
|
| 55 |
+
model_name,
|
| 56 |
+
torch_dtype=torch.bfloat16,
|
| 57 |
+
load_in_4bit=True
|
| 58 |
+
)
|
| 59 |
+
# Training arguments
|
| 60 |
+
training_args = TrainingArguments(
|
| 61 |
+
per_device_train_batch_size=4,
|
| 62 |
+
gradient_accumulation_steps=4,
|
| 63 |
+
gradient_checkpointing=True,
|
| 64 |
+
learning_rate=5e-5,
|
| 65 |
+
lr_scheduler_type="cosine",
|
| 66 |
+
max_steps=2000,
|
| 67 |
+
save_strategy="no",
|
| 68 |
+
logging_steps=1,
|
| 69 |
+
output_dir=new_model,
|
| 70 |
+
optim="paged_adamw_32bit",
|
| 71 |
+
warmup_steps=100,
|
| 72 |
+
bf16=True,
|
| 73 |
+
report_to="wandb",
|
| 74 |
+
)
|
| 75 |
+
# Create DPO trainer
|
| 76 |
+
dpo_trainer = DPOTrainer(
|
| 77 |
+
model,
|
| 78 |
+
ref_model,
|
| 79 |
+
args=training_args,
|
| 80 |
+
train_dataset=dataset,
|
| 81 |
+
tokenizer=tokenizer,
|
| 82 |
+
peft_config=peft_config,
|
| 83 |
+
beta=0.1,
|
| 84 |
+
max_prompt_length=2048,
|
| 85 |
+
max_length=8192,
|
| 86 |
+
force_use_ref_model=True
|
| 87 |
+
)
|
| 88 |
+
```
|