Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Here's an adapted TWIZ intent detection model, trained on the TWIZ dataset, with an extra focus on simplicity!
|
| 2 |
+
It achieves ~85% accuracy on the TWIZ test set, and should be especially useful for the WSDM students @ NOVA.
|
| 3 |
+
|
| 4 |
+
I STRONGLY suggest interested students to check `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!)
|
| 5 |
+
|
| 6 |
+
Here's the contents of `intent-detection-example.ipynb`, if you're just looking to use the model:
|
| 7 |
+
|
| 8 |
+
```python
|
| 9 |
+
with open("twiz-data/all_intents.json", 'r') as json_in: # all_intents.json can be found in the task-intent-detector/model_code directory
|
| 10 |
+
data = json.load(json_in)
|
| 11 |
+
|
| 12 |
+
id_to_intent, intent_to_id = dict(), dict()
|
| 13 |
+
for i, intent in enumerate(data):
|
| 14 |
+
id_to_intent[i] = intent
|
| 15 |
+
intent_to_id[intent] = i
|
| 16 |
+
|
| 17 |
+
model = AutoModelForSequenceClassification.from_pretrained("NOVA-vision-language/task-intent-detector", num_labels=len(data), id2label=id_to_intent, label2id=intent_to_id)
|
| 18 |
+
tokenizer = AutoTokenizer.from_pretrained("roberta-base") # you could try 'NOVA-vision-language/task-intent-detector', but I'm not sure I configured it correctly
|
| 19 |
+
|
| 20 |
+
model_in = tokenizer("I really really wanna go to the next step", return_tensors='pt')
|
| 21 |
+
with torch.no_grad():
|
| 22 |
+
logits = model(**model_in).logits # grab the predictions out of the model's classification head
|
| 23 |
+
predicted_class_id = logits.argmax().item() # grab the index of the highest scoring output
|
| 24 |
+
print(model.config.id2label[predicted_class_id]) # use the translation table we just created to translate between that id and the actual intent name
|
| 25 |
+
```
|