Upload folder using huggingface_hub
Browse files- integrate.py +2 -2
- run.zsh +43 -0
- train.py +4 -4
- train_simple.py +25 -9
integrate.py
CHANGED
|
@@ -10,8 +10,8 @@ from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
| 10 |
from peft import PeftModel
|
| 11 |
|
| 12 |
def load_zenith_model(
|
| 13 |
-
base_model_path="
|
| 14 |
-
lora_path="outputs
|
| 15 |
device_map="auto"
|
| 16 |
):
|
| 17 |
"""Load Zenith LoRA adapter for Aspetos platform integration"""
|
|
|
|
| 10 |
from peft import PeftModel
|
| 11 |
|
| 12 |
def load_zenith_model(
|
| 13 |
+
base_model_path="DeepSeek-Coder-V2-Lite-Instruct",
|
| 14 |
+
lora_path="outputs/zenith-lora",
|
| 15 |
device_map="auto"
|
| 16 |
):
|
| 17 |
"""Load Zenith LoRA adapter for Aspetos platform integration"""
|
run.zsh
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/zsh
|
| 2 |
+
|
| 3 |
+
# Fast fine-tune for Zenith - World's First Autonomous AI Development Partner
|
| 4 |
+
|
| 5 |
+
PythonExe="python"
|
| 6 |
+
|
| 7 |
+
echo "🚀 Setting up ZENITH fine-tune for Aspetos (<2h training)..."
|
| 8 |
+
echo "Building the most advanced AI development partner in existence!"
|
| 9 |
+
|
| 10 |
+
# Env vars for stable training (adjust if needed)
|
| 11 |
+
export BASE_MODEL="/cloud/models/DeepSeek-Coder-V2-Lite-Instruct" # Please change this to the actual path of the model on your cloud GPU
|
| 12 |
+
export OUTPUT_DIR="outputs/zenith-lora"
|
| 13 |
+
export DATA_PATH="data/zenith_combined.jsonl"
|
| 14 |
+
export EPOCHS="1"
|
| 15 |
+
export BATCH="4" # Balanced for A100
|
| 16 |
+
export GRAD_ACC="4" # Effective batch size = 16
|
| 17 |
+
export LR="1e-4" # Stable learning rate for proper convergence
|
| 18 |
+
export STEPS="200" # Increased steps for more training examples
|
| 19 |
+
export MAX_SEQ_LEN="2048"
|
| 20 |
+
export USE_4BIT="1"
|
| 21 |
+
export SEED="42"
|
| 22 |
+
export MAX_GRAD_NORM="1.0" # Gradient clipping
|
| 23 |
+
export WEIGHT_DECAY="0.01"
|
| 24 |
+
export WARMUP_RATIO="0.05"
|
| 25 |
+
export EARLY_STOP_PATIENCE="5" # Allow more patience for learning
|
| 26 |
+
export EVAL_STEPS="40" # Balanced evaluation frequency
|
| 27 |
+
export SAVE_STEPS="40" # Balanced save frequency
|
| 28 |
+
|
| 29 |
+
echo "Installing dependencies..."
|
| 30 |
+
$PythonExe -m pip install -r requirements.txt
|
| 31 |
+
if [ $? -ne 0 ]; then
|
| 32 |
+
echo "pip install failed"
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
|
| 36 |
+
echo "🎯 Starting ZENITH fine-tune (target: 1800 steps, ~1-2 hours on GPU)..."
|
| 37 |
+
echo "Training the world's most advanced autonomous development partner!"
|
| 38 |
+
$PythonExe train.py
|
| 39 |
+
if [ $? -ne 0 ]; then
|
| 40 |
+
echo "Training failed"
|
| 41 |
+
exit 1
|
| 42 |
+
fi
|
| 43 |
+
echo "✅ ZENITH training complete - Ready for deployment!"
|
train.py
CHANGED
|
@@ -9,9 +9,9 @@ from peft import LoraConfig
|
|
| 9 |
from transformers import BitsAndBytesConfig
|
| 10 |
|
| 11 |
# Config from env vars
|
| 12 |
-
BASE_MODEL = os.environ.get("BASE_MODEL", "
|
| 13 |
-
OUTPUT_DIR = os.environ.get("OUTPUT_DIR", "outputs
|
| 14 |
-
DATA_PATH = os.environ.get("DATA_PATH", "data
|
| 15 |
VAL_PATH = os.environ.get("VAL_PATH")
|
| 16 |
MAX_STEPS = int(os.environ.get("STEPS", 200))
|
| 17 |
USE_4BIT = os.environ.get("USE_4BIT", "1") == "1"
|
|
@@ -59,7 +59,7 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
| 59 |
# Memory-saving configurations
|
| 60 |
model.config.use_cache = False
|
| 61 |
|
| 62 |
-
data_files = [DATA_PATH, "data
|
| 63 |
print(f"Loading datasets: {data_files}")
|
| 64 |
raw_train = load_dataset("json", data_files=data_files, split="train")
|
| 65 |
|
|
|
|
| 9 |
from transformers import BitsAndBytesConfig
|
| 10 |
|
| 11 |
# Config from env vars
|
| 12 |
+
BASE_MODEL = os.environ.get("BASE_MODEL", "DeepSeek-Coder-V2-Lite-Instruct")
|
| 13 |
+
OUTPUT_DIR = os.environ.get("OUTPUT_DIR", "outputs/zenith-lora")
|
| 14 |
+
DATA_PATH = os.environ.get("DATA_PATH", "data/zenith.jsonl")
|
| 15 |
VAL_PATH = os.environ.get("VAL_PATH")
|
| 16 |
MAX_STEPS = int(os.environ.get("STEPS", 200))
|
| 17 |
USE_4BIT = os.environ.get("USE_4BIT", "1") == "1"
|
|
|
|
| 59 |
# Memory-saving configurations
|
| 60 |
model.config.use_cache = False
|
| 61 |
|
| 62 |
+
data_files = [DATA_PATH, "data/training_data_v2.jsonl"]
|
| 63 |
print(f"Loading datasets: {data_files}")
|
| 64 |
raw_train = load_dataset("json", data_files=data_files, split="train")
|
| 65 |
|
train_simple.py
CHANGED
|
@@ -11,8 +11,8 @@ from trl import SFTTrainer
|
|
| 11 |
from peft import LoraConfig
|
| 12 |
|
| 13 |
# 1. Configuration
|
| 14 |
-
BASE_MODEL = "
|
| 15 |
-
OUTPUT_DIR = "outputs
|
| 16 |
DATA_FILES = [
|
| 17 |
"data/zenith.jsonl",
|
| 18 |
"data/training_data_v2.jsonl",
|
|
@@ -55,13 +55,29 @@ model.config.use_cache = False
|
|
| 55 |
print(f"Loading datasets: {DATA_FILES}")
|
| 56 |
dataset = load_dataset("json", data_files=DATA_FILES, split="train")
|
| 57 |
|
| 58 |
-
def
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
# 5. Create fixed train/validation split
|
| 67 |
print("Creating train/validation split...")
|
|
@@ -88,7 +104,7 @@ training_args = TrainingArguments(
|
|
| 88 |
lr_scheduler_type="cosine", # Cosine decay scheduler
|
| 89 |
warmup_steps=50, # Warmup steps
|
| 90 |
logging_steps=10,
|
| 91 |
-
max_steps=
|
| 92 |
save_steps=50,
|
| 93 |
save_total_limit=2, # Save only the best and the last checkpoints
|
| 94 |
evaluation_strategy="steps",
|
|
|
|
| 11 |
from peft import LoraConfig
|
| 12 |
|
| 13 |
# 1. Configuration
|
| 14 |
+
BASE_MODEL = "DeepSeek-Coder-V2-Lite-Instruct"
|
| 15 |
+
OUTPUT_DIR = "outputs/zenith-lora-simple"
|
| 16 |
DATA_FILES = [
|
| 17 |
"data/zenith.jsonl",
|
| 18 |
"data/training_data_v2.jsonl",
|
|
|
|
| 55 |
print(f"Loading datasets: {DATA_FILES}")
|
| 56 |
dataset = load_dataset("json", data_files=DATA_FILES, split="train")
|
| 57 |
|
| 58 |
+
def _valid(example):
|
| 59 |
+
msgs = example.get("messages")
|
| 60 |
+
if not isinstance(msgs, list) or not msgs:
|
| 61 |
+
return False
|
| 62 |
+
for m in msgs:
|
| 63 |
+
if not isinstance(m, dict) or "role" not in m or "content" not in m:
|
| 64 |
+
return False
|
| 65 |
+
return True
|
| 66 |
|
| 67 |
+
def _to_text(example):
|
| 68 |
+
try:
|
| 69 |
+
text = tokenizer.apply_chat_template(
|
| 70 |
+
example["messages"], tokenize=False, add_generation_prompt=False
|
| 71 |
+
)
|
| 72 |
+
return {"text": text}
|
| 73 |
+
except Exception:
|
| 74 |
+
return {"text": ""}
|
| 75 |
+
|
| 76 |
+
dataset = dataset.filter(_valid)
|
| 77 |
+
dataset = dataset.map(_to_text, remove_columns=dataset.column_names)
|
| 78 |
+
|
| 79 |
+
# Drop empty or pathological items
|
| 80 |
+
dataset = dataset.filter(lambda x: isinstance(x.get("text"), str) and len(x["text"]) > 0)
|
| 81 |
|
| 82 |
# 5. Create fixed train/validation split
|
| 83 |
print("Creating train/validation split...")
|
|
|
|
| 104 |
lr_scheduler_type="cosine", # Cosine decay scheduler
|
| 105 |
warmup_steps=50, # Warmup steps
|
| 106 |
logging_steps=10,
|
| 107 |
+
max_steps=200,
|
| 108 |
save_steps=50,
|
| 109 |
save_total_limit=2, # Save only the best and the last checkpoints
|
| 110 |
evaluation_strategy="steps",
|