File size: 1,977 Bytes
2705a3e
 
 
 
 
 
 
 
 
 
 
 
19d436b
 
 
2705a3e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d81886a
11cdc54
d81886a
 
 
 
 
 
c64606c
2705a3e
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
37
38
39
40
41
from tamilatis.predict import TamilATISPredictor 
from tamilatis.model import JointATISModel
import numpy as np
from sklearn.preprocessing import LabelEncoder
import gradio as gr



model_name = "microsoft/xlm-align-base"
tokenizer_name = "microsoft/xlm-align-base"
num_labels = 78
num_intents = 23
checkpoint_path = "models/xlm_align_base.bin"
intent_encoder_path = "models/intent_classes.npy"
ner_encoder_path = "models/ner_classes.npy"

def predict_function(text):
  label_encoder = LabelEncoder()
  label_encoder.classes_ = np.load(ner_encoder_path)
  
  intent_encoder = LabelEncoder()
  intent_encoder.classes_ = np.load(intent_encoder_path)
  
  model  = JointATISModel(model_name,num_labels,num_intents)
  predictor = TamilATISPredictor(model,checkpoint_path,tokenizer_name,
                              label_encoder,intent_encoder,num_labels)
  slot_prediction, intent_preds = predictor.get_predictions(text)
  return slot_prediction, intent_preds


title = "MultiTask Learning in Intent Detection and Slot Prediction for Tamil Conversational Dialogues using Multilingual Pretrained Models"  
article="This is a demo for the MultiTask model trained on Tamil Translated conversations from ATIS dataset. The code can be found [here](https://github.com/seanbenhur/tamilatis). Made with ❤ by [Sean Benhur](https://www.linkedin.com/in/seanbenhur/)" 
examples = ["ஹைதராபாத்தில் இருந்து உதய்பூர் செல்லும் விமானங்களைக் காட்டு", "எனக்கு டெல்லியில் இருந்து சென்னைக்கு விமானம் வேண்டும்"]

intent_output = gr.outputs.Textbox(type="auto",label="Intent")
slots_output = gr.outputs.Textbox(type="auto",label="Slots")
iface = gr.Interface(fn=predict_function,article=article, inputs="text", title=title,outputs=[intent_output,slots_output],
examples=examples)
iface.launch()