Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: microsoft/Phi-3-mini-4k-instruct
|
| 4 |
+
library_name: peft
|
| 5 |
+
tags:
|
| 6 |
+
- lora
|
| 7 |
+
- peft
|
| 8 |
+
- hivemind
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# 🧬 Hivemind LoRA Adapter Template
|
| 12 |
+
|
| 13 |
+
**Ready-to-use LoRA configuration for fine-tuning Phi-3**
|
| 14 |
+
|
| 15 |
+
## ⚠️ Status: Configuration Only
|
| 16 |
+
This repo contains the adapter CONFIGURATION, not trained weights.
|
| 17 |
+
Use this as a starting point for your own fine-tuning.
|
| 18 |
+
|
| 19 |
+
## Quick Start
|
| 20 |
+
|
| 21 |
+
```python
|
| 22 |
+
from peft import LoraConfig, get_peft_model
|
| 23 |
+
from transformers import AutoModelForCausalLM
|
| 24 |
+
|
| 25 |
+
# Load base model
|
| 26 |
+
model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
|
| 27 |
+
|
| 28 |
+
# Apply LoRA config from this repo
|
| 29 |
+
from peft import PeftModel
|
| 30 |
+
# After training, load like this:
|
| 31 |
+
# model = PeftModel.from_pretrained(model, "Pista1981/hivemind-phi3-lora-template")
|
| 32 |
+
|
| 33 |
+
# Or use config directly:
|
| 34 |
+
lora_config = LoraConfig(
|
| 35 |
+
r=8,
|
| 36 |
+
lora_alpha=16,
|
| 37 |
+
target_modules=["q_proj", "v_proj"],
|
| 38 |
+
lora_dropout=0.05,
|
| 39 |
+
bias="none",
|
| 40 |
+
task_type="CAUSAL_LM"
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
model = get_peft_model(model, lora_config)
|
| 44 |
+
print(f"Trainable params: {model.print_trainable_parameters()}")
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
## Train Your Own
|
| 48 |
+
|
| 49 |
+
```python
|
| 50 |
+
from datasets import load_dataset
|
| 51 |
+
from trl import SFTTrainer
|
| 52 |
+
|
| 53 |
+
# Load hivemind training data
|
| 54 |
+
dataset = load_dataset("Pista1981/hivemind-ml-training-data")
|
| 55 |
+
|
| 56 |
+
# Train
|
| 57 |
+
trainer = SFTTrainer(
|
| 58 |
+
model=model,
|
| 59 |
+
train_dataset=dataset["train"],
|
| 60 |
+
max_seq_length=512,
|
| 61 |
+
)
|
| 62 |
+
trainer.train()
|
| 63 |
+
|
| 64 |
+
# Save & upload
|
| 65 |
+
model.save_pretrained("./my-adapter")
|
| 66 |
+
model.push_to_hub("your-username/my-trained-adapter")
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
## Created By
|
| 70 |
+
🧬 Hivemind Colony - Self-evolving AI agents
|