Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -26,6 +26,7 @@ def tokenize_function(examples):
|
|
26 |
|
27 |
tokenized_datasets = dataset.map(tokenize_function, batched=True)
|
28 |
|
|
|
29 |
# === 4️⃣ EĞİTİM AYARLARI ===
|
30 |
training_args = TrainingArguments(
|
31 |
output_dir="./mistral_lora",
|
@@ -38,15 +39,33 @@ training_args = TrainingArguments(
|
|
38 |
logging_dir="./logs",
|
39 |
logging_steps=10,
|
40 |
optim="adamw_torch",
|
|
|
41 |
)
|
42 |
|
|
|
43 |
# === 5️⃣ GPU BAŞLATMA VE EĞİTİM ===
|
44 |
@spaces.GPU
|
45 |
def train_model():
|
46 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
|
47 |
model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, torch_dtype=torch.float32).to(device)
|
48 |
model = get_peft_model(model, lora_config)
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
trainer = Trainer(
|
51 |
model=model,
|
52 |
args=training_args,
|
@@ -55,6 +74,7 @@ def train_model():
|
|
55 |
trainer.train()
|
56 |
return "✅ Model Eğitimi Tamamlandı!"
|
57 |
|
|
|
58 |
# === 6️⃣ BAŞLATMA ===
|
59 |
if __name__ == "__main__":
|
60 |
train_model() # Eğitimi başlat
|
|
|
26 |
|
27 |
tokenized_datasets = dataset.map(tokenize_function, batched=True)
|
28 |
|
29 |
+
# === 4️⃣ EĞİTİM AYARLARI ===
|
30 |
# === 4️⃣ EĞİTİM AYARLARI ===
|
31 |
training_args = TrainingArguments(
|
32 |
output_dir="./mistral_lora",
|
|
|
39 |
logging_dir="./logs",
|
40 |
logging_steps=10,
|
41 |
optim="adamw_torch",
|
42 |
+
no_cuda=True, # 🔥 ÇÖZÜM: Ana süreçte GPU'yu başlatmayı engelle
|
43 |
)
|
44 |
|
45 |
+
|
46 |
# === 5️⃣ GPU BAŞLATMA VE EĞİTİM ===
|
47 |
@spaces.GPU
|
48 |
def train_model():
|
49 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
50 |
+
|
51 |
+
# Modeli burada yükle
|
52 |
model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, torch_dtype=torch.float32).to(device)
|
53 |
model = get_peft_model(model, lora_config)
|
54 |
|
55 |
+
# TrainingArguments burada tanımlandı!
|
56 |
+
training_args = TrainingArguments(
|
57 |
+
output_dir="./mistral_lora",
|
58 |
+
per_device_train_batch_size=1,
|
59 |
+
gradient_accumulation_steps=16,
|
60 |
+
learning_rate=5e-4,
|
61 |
+
num_train_epochs=1,
|
62 |
+
save_steps=500,
|
63 |
+
save_total_limit=2,
|
64 |
+
logging_dir="./logs",
|
65 |
+
logging_steps=10,
|
66 |
+
optim="adamw_torch",
|
67 |
+
)
|
68 |
+
|
69 |
trainer = Trainer(
|
70 |
model=model,
|
71 |
args=training_args,
|
|
|
74 |
trainer.train()
|
75 |
return "✅ Model Eğitimi Tamamlandı!"
|
76 |
|
77 |
+
|
78 |
# === 6️⃣ BAŞLATMA ===
|
79 |
if __name__ == "__main__":
|
80 |
train_model() # Eğitimi başlat
|