hackergeek commited on
Commit
71e1bba
·
verified ·
1 Parent(s): 006af89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -64,9 +64,12 @@ def train_model(dataset_url, model_url, epochs):
64
  tokenized_datasets = dataset.map(tokenize_function, batched=True)
65
  train_dataset = tokenized_datasets["train"]
66
 
 
 
 
67
  training_args = TrainingArguments(
68
  output_dir="./deepseek_lora_cpu",
69
- evaluation_strategy="epoch",
70
  learning_rate=5e-4,
71
  per_device_train_batch_size=1,
72
  per_device_eval_batch_size=1,
@@ -84,7 +87,8 @@ def train_model(dataset_url, model_url, epochs):
84
  trainer = Trainer(
85
  model=model,
86
  args=training_args,
87
- train_dataset=train_dataset
 
88
  )
89
 
90
  log_status("🚀 ترینینگ شروع شد...")
 
64
  tokenized_datasets = dataset.map(tokenize_function, batched=True)
65
  train_dataset = tokenized_datasets["train"]
66
 
67
+ # Automatically check for validation dataset
68
+ eval_dataset = tokenized_datasets["validation"] if "validation" in tokenized_datasets else None
69
+
70
  training_args = TrainingArguments(
71
  output_dir="./deepseek_lora_cpu",
72
+ evaluation_strategy="epoch" if eval_dataset else "no", # Enable evaluation if validation data exists
73
  learning_rate=5e-4,
74
  per_device_train_batch_size=1,
75
  per_device_eval_batch_size=1,
 
87
  trainer = Trainer(
88
  model=model,
89
  args=training_args,
90
+ train_dataset=train_dataset,
91
+ eval_dataset=eval_dataset # Add eval dataset if available
92
  )
93
 
94
  log_status("🚀 ترینینگ شروع شد...")