Spaces:
Sleeping
Sleeping
Update app_train.py
Browse files- app_train.py +0 -8
app_train.py
CHANGED
|
@@ -63,7 +63,6 @@ def log_message(output_log, msg):
|
|
| 63 |
def train_model(base_model, dataset_name, num_epochs, batch_size, learning_rate):
|
| 64 |
output_log = []
|
| 65 |
test_split = 0.2
|
| 66 |
-
mock_question = "Who is referred to as 'O best of Brahmanas' in the Bhagavad Gita?"
|
| 67 |
|
| 68 |
try:
|
| 69 |
log_message(output_log, "🔍 Initializing training sequence...")
|
|
@@ -146,13 +145,6 @@ You are a wise teacher interpreting Bhagavad Gita with deep insights.
|
|
| 146 |
tokenizer.save_pretrained(output_dir)
|
| 147 |
log_message(output_log, "\n✅ Training finished and model saved locally.")
|
| 148 |
|
| 149 |
-
# ===== Mock question response =====
|
| 150 |
-
inputs = tokenizer(f"<|system|>\nYou are a wise teacher interpreting Bhagavad Gita.\n<|user|>\n{mock_question}\n<|assistant|>\n", return_tensors="pt").to(device)
|
| 151 |
-
outputs = model.generate(**inputs, max_new_tokens=100)
|
| 152 |
-
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 153 |
-
log_message(output_log, f"\n🧪 Mock Question:\nQ: {mock_question}\nA: {answer}")
|
| 154 |
-
|
| 155 |
-
# Return model and tokenizer for interactive questions
|
| 156 |
return "\n".join(output_log), model, tokenizer, output_dir
|
| 157 |
|
| 158 |
except Exception as e:
|
|
|
|
| 63 |
def train_model(base_model, dataset_name, num_epochs, batch_size, learning_rate):
|
| 64 |
output_log = []
|
| 65 |
test_split = 0.2
|
|
|
|
| 66 |
|
| 67 |
try:
|
| 68 |
log_message(output_log, "🔍 Initializing training sequence...")
|
|
|
|
| 145 |
tokenizer.save_pretrained(output_dir)
|
| 146 |
log_message(output_log, "\n✅ Training finished and model saved locally.")
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
return "\n".join(output_log), model, tokenizer, output_dir
|
| 149 |
|
| 150 |
except Exception as e:
|