Views
No views yet
model_code in the Files and versions tab, where all the code used to get to the model (with the exception of actually uploading it here) is laid out nicely (I hope!)intent-detection-example.ipynb, if you're just looking to use the model:1with open("twiz-data/all_intents.json", 'r') as json_in: # all_intents.json can be found in the task-intent-detector/model_code directory
2 data = json.load(json_in)
3
4id_to_intent, intent_to_id = dict(), dict()
5for i, intent in enumerate(data):
6 id_to_intent[i] = intent
7 intent_to_id[intent] = i
8
9model = AutoModelForSequenceClassification.from_pretrained("NOVA-vision-language/task-intent-detector", num_labels=len(data), id2label=id_to_intent, label2id=intent_to_id)
10tokenizer = AutoTokenizer.from_pretrained("roberta-base") # you could try 'NOVA-vision-language/task-intent-detector', but I'm not sure I configured it correctly
11
12model_in = tokenizer("I really really wanna go to the next step", return_tensors='pt')
13with torch.no_grad():
14 logits = model(**model_in).logits # grab the predictions out of the model's classification head
15 predicted_class_id = logits.argmax().item() # grab the index of the highest scoring output
16 print(model.config.id2label[predicted_class_id]) # use the translation table we just created to translate between that id and the actual intent name