updated train_abuse_model to save the traind model after training process
Browse files- train_abuse_model.py +14 -2
train_abuse_model.py
CHANGED
@@ -225,5 +225,17 @@ trainer = Trainer(
|
|
225 |
# Start training!
|
226 |
trainer.train()
|
227 |
|
228 |
-
|
229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
# Start training!
|
226 |
trainer.train()
|
227 |
|
228 |
+
# Save the model and tokenizer
|
229 |
+
if not os.path.exists("saved_model/"):
|
230 |
+
os.makedirs("saved_model/")
|
231 |
+
model.save_pretrained("saved_model/")
|
232 |
+
tokenizer.save_pretrained("saved_model/")
|
233 |
+
|
234 |
+
# Evaluation
|
235 |
+
try:
|
236 |
+
label_map = {0.0: "no", 0.5: "plausibly", 1.0: "yes"}
|
237 |
+
evaluate_model_with_thresholds(trainer, test_dataset)
|
238 |
+
except Exception as e:
|
239 |
+
print(f"Evaluation failed: {e}")
|
240 |
+
|
241 |
+
|