Spaces:
Runtime error
Runtime error
Commit ·
12ddec0
1
Parent(s): 9242c1b
api
Browse files
app.py
CHANGED
|
@@ -46,14 +46,15 @@ training_args = TrainingArguments(
|
|
| 46 |
)
|
| 47 |
|
| 48 |
# Inizializza il Trainer
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
trainer.train()
|
| 56 |
-
trainer.push_to_hub("
|
|
|
|
| 57 |
|
| 58 |
def answer_question(question):
|
| 59 |
inputs = tokenizer(question, return_tensors="pt", truncation=True, max_length=128).to(device)
|
|
@@ -62,4 +63,8 @@ def answer_question(question):
|
|
| 62 |
return answer
|
| 63 |
|
| 64 |
iface = gr.Interface(fn=answer_question, inputs="text", outputs="text")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
iface.launch()
|
|
|
|
| 46 |
)
|
| 47 |
|
| 48 |
# Inizializza il Trainer
|
| 49 |
+
def start_training():
|
| 50 |
+
trainer = Trainer(
|
| 51 |
+
model=model,
|
| 52 |
+
args=training_args,
|
| 53 |
+
train_dataset=tokenized_dataset["train"]
|
| 54 |
+
)
|
| 55 |
+
trainer.train()
|
| 56 |
+
trainer.push_to_hub("to_validate_model")
|
| 57 |
+
return "Training completato e caricato"
|
| 58 |
|
| 59 |
def answer_question(question):
|
| 60 |
inputs = tokenizer(question, return_tensors="pt", truncation=True, max_length=128).to(device)
|
|
|
|
| 63 |
return answer
|
| 64 |
|
| 65 |
iface = gr.Interface(fn=answer_question, inputs="text", outputs="text")
|
| 66 |
+
train_interface = gr.Interface(fn=start_training, inputs=[], outputs="text")
|
| 67 |
+
app = gr.TabbedInterface([iface, train_interface], ["Q&A", "Avvia Training"])
|
| 68 |
+
|
| 69 |
+
|
| 70 |
iface.launch()
|