Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,11 +1,8 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
import torch
|
| 4 |
-
from threading import Thread
|
| 5 |
-
import time
|
| 6 |
|
| 7 |
-
|
| 8 |
-
training_status = {"running": False, "log": "", "progress": 0}
|
| 9 |
|
| 10 |
def run_training(
|
| 11 |
base_model: str,
|
|
@@ -41,7 +38,7 @@ def run_training(
|
|
| 41 |
from datasets import load_dataset
|
| 42 |
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, TrainingArguments
|
| 43 |
from peft import LoraConfig, get_peft_model, prepare_model_for_kbit_training
|
| 44 |
-
from trl import SFTTrainer
|
| 45 |
|
| 46 |
progress(0.15, desc="Loading tokenizer...")
|
| 47 |
log(f"[3/6] Loading tokenizer: {base_model}")
|
|
@@ -96,7 +93,8 @@ def run_training(
|
|
| 96 |
progress(0.4, desc="Setting up trainer...")
|
| 97 |
log(f"[6/6] Starting training: {epochs} epochs, batch={batch_size}, lr={learning_rate}")
|
| 98 |
|
| 99 |
-
|
|
|
|
| 100 |
output_dir="./outputs",
|
| 101 |
num_train_epochs=epochs,
|
| 102 |
per_device_train_batch_size=batch_size,
|
|
@@ -111,15 +109,15 @@ def run_training(
|
|
| 111 |
push_to_hub=True,
|
| 112 |
hub_model_id=output_repo,
|
| 113 |
hub_token=os.environ.get("HF_TOKEN"),
|
|
|
|
|
|
|
| 114 |
)
|
| 115 |
|
| 116 |
trainer = SFTTrainer(
|
| 117 |
model=model,
|
| 118 |
-
args=
|
| 119 |
train_dataset=dataset,
|
| 120 |
-
|
| 121 |
-
max_seq_length=4096,
|
| 122 |
-
dataset_text_field="text",
|
| 123 |
)
|
| 124 |
|
| 125 |
log("\n" + "=" * 50)
|
|
@@ -154,6 +152,7 @@ with gr.Blocks(title="Agent Zero Trainer") as demo:
|
|
| 154 |
**Intuition Labs** • terminals.tech
|
| 155 |
|
| 156 |
Fine-tune models for coherent multi-context orchestration.
|
|
|
|
| 157 |
""")
|
| 158 |
|
| 159 |
with gr.Row():
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
import torch
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
training_status = {"running": False, "log": ""}
|
|
|
|
| 6 |
|
| 7 |
def run_training(
|
| 8 |
base_model: str,
|
|
|
|
| 38 |
from datasets import load_dataset
|
| 39 |
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, TrainingArguments
|
| 40 |
from peft import LoraConfig, get_peft_model, prepare_model_for_kbit_training
|
| 41 |
+
from trl import SFTTrainer, SFTConfig
|
| 42 |
|
| 43 |
progress(0.15, desc="Loading tokenizer...")
|
| 44 |
log(f"[3/6] Loading tokenizer: {base_model}")
|
|
|
|
| 93 |
progress(0.4, desc="Setting up trainer...")
|
| 94 |
log(f"[6/6] Starting training: {epochs} epochs, batch={batch_size}, lr={learning_rate}")
|
| 95 |
|
| 96 |
+
# Use SFTConfig instead of TrainingArguments for newer TRL
|
| 97 |
+
sft_config = SFTConfig(
|
| 98 |
output_dir="./outputs",
|
| 99 |
num_train_epochs=epochs,
|
| 100 |
per_device_train_batch_size=batch_size,
|
|
|
|
| 109 |
push_to_hub=True,
|
| 110 |
hub_model_id=output_repo,
|
| 111 |
hub_token=os.environ.get("HF_TOKEN"),
|
| 112 |
+
max_seq_length=4096,
|
| 113 |
+
dataset_text_field="text",
|
| 114 |
)
|
| 115 |
|
| 116 |
trainer = SFTTrainer(
|
| 117 |
model=model,
|
| 118 |
+
args=sft_config,
|
| 119 |
train_dataset=dataset,
|
| 120 |
+
processing_class=tokenizer,
|
|
|
|
|
|
|
| 121 |
)
|
| 122 |
|
| 123 |
log("\n" + "=" * 50)
|
|
|
|
| 152 |
**Intuition Labs** • terminals.tech
|
| 153 |
|
| 154 |
Fine-tune models for coherent multi-context orchestration.
|
| 155 |
+
Running on L40S GPU (48GB VRAM) - $1.80/hr
|
| 156 |
""")
|
| 157 |
|
| 158 |
with gr.Row():
|