Spaces:
Running
Running
File size: 1,182 Bytes
6e70824 f997552 6e70824 75d1957 f997552 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import torch
import pandas as pd
from evo_model import EvoTransformer, train_evo_transformer
from datasets import load_dataset
import os
def manual_retrain():
try:
# Load feedback data from Firestore
from google.cloud import firestore
db = firestore.Client.from_service_account_json("firebase_key.json")
docs = db.collection("evo_feedback_logs").stream()
data = [doc.to_dict() for doc in docs if "goal" in doc.to_dict()]
if not data:
print("No feedback data available.")
return False
# Convert to training format
rows = []
for d in data:
question = d["goal"]
option1 = d["sol1"]
option2 = d["sol2"]
correct = d["correct"]
label = 0 if correct == "Solution 1" else 1
rows.append((question, option1, option2, label))
df = pd.DataFrame(rows, columns=["goal", "sol1", "sol2", "label"])
# Train the Evo model (minimal epochs to simulate update)
train_evo_transformer(df, epochs=1)
return True
except Exception as e:
print(f"[Retrain Error] {e}")
return False
|