Whisper / intent.py
jaimin's picture
Upload 2 files
2f3b04f verified
raw
history blame contribute delete
591 Bytes
from transformers import pipeline
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification, TextClassificationPipeline
device = "cuda:0" if torch.cuda.is_available() else "cpu"
model_name = 'qanastek/XLMRoberta-Alexa-Intents-Classification'
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
intent_classifier = TextClassificationPipeline(model=model, tokenizer=tokenizer)
def perform_intent_classification(text):
result = intent_classifier(text)
return {"Intent": [result]}