Spaces:
Sleeping
Sleeping
updated
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ sys.path.append(project_dir)
|
|
| 8 |
|
| 9 |
from model import MultiTaskBertModel
|
| 10 |
from data_loader import load_dataset
|
| 11 |
-
from utils import bert_config, tokenizer, intent_ids_to_labels, intent_labels_to_ids
|
| 12 |
|
| 13 |
config = bert_config()
|
| 14 |
dataset = load_dataset("training_dataset")
|
|
@@ -18,6 +18,9 @@ model.load_state_dict(torch.load("pytorch_model.bin"))
|
|
| 18 |
|
| 19 |
model.eval()
|
| 20 |
|
|
|
|
|
|
|
|
|
|
| 21 |
def predict(input_data):
|
| 22 |
|
| 23 |
tok = tokenizer()
|
|
@@ -49,16 +52,22 @@ def predict(input_data):
|
|
| 49 |
if not word.strip():
|
| 50 |
continue
|
| 51 |
|
| 52 |
-
aligned_predictions.append((word, int(prediction)))
|
| 53 |
|
| 54 |
labels = intent_labels_to_ids()
|
| 55 |
intent_labels = intent_ids_to_labels(labels)
|
|
|
|
| 56 |
|
| 57 |
return f"Ner logits: {aligned_predictions}, Intent Label: {intent_labels}"
|
| 58 |
|
| 59 |
title = "Multi Task Model"
|
| 60 |
description = '''
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
'''
|
| 63 |
|
| 64 |
gr.Interface(
|
|
|
|
| 8 |
|
| 9 |
from model import MultiTaskBertModel
|
| 10 |
from data_loader import load_dataset
|
| 11 |
+
from utils import bert_config, tokenizer, intent_ids_to_labels, intent_labels_to_ids, ner_labels_to_ids, ner_ids_to_labels
|
| 12 |
|
| 13 |
config = bert_config()
|
| 14 |
dataset = load_dataset("training_dataset")
|
|
|
|
| 18 |
|
| 19 |
model.eval()
|
| 20 |
|
| 21 |
+
ner_label_to_id = ner_labels_to_ids()
|
| 22 |
+
ner_id_to_label = ner_ids_to_labels(ner_label_to_id)
|
| 23 |
+
|
| 24 |
def predict(input_data):
|
| 25 |
|
| 26 |
tok = tokenizer()
|
|
|
|
| 52 |
if not word.strip():
|
| 53 |
continue
|
| 54 |
|
| 55 |
+
aligned_predictions.append((word, ner_id_to_label[int(prediction)]))
|
| 56 |
|
| 57 |
labels = intent_labels_to_ids()
|
| 58 |
intent_labels = intent_ids_to_labels(labels)
|
| 59 |
+
intent_labels = intent_labels[int(intent_logits)]
|
| 60 |
|
| 61 |
return f"Ner logits: {aligned_predictions}, Intent Label: {intent_labels}"
|
| 62 |
|
| 63 |
title = "Multi Task Model"
|
| 64 |
description = '''
|
| 65 |
+
This model is designed for a scheduler application, capable of handling various tasks such as setting
|
| 66 |
+
timers, scheduling meetings, appointments, and alarms. It provides Named Entity Recognition (NER) labels
|
| 67 |
+
to identify specific entities within the input text, along with an Intent label to determine the
|
| 68 |
+
overall task intention. The model's outputs facilitate efficient task management and organization,
|
| 69 |
+
enabling seamless interaction with the scheduler application.
|
| 70 |
+
<img src="bart.jpg" width=300px>
|
| 71 |
'''
|
| 72 |
|
| 73 |
gr.Interface(
|
bart.jpg
ADDED
|