使用Huggingface BERT模型识别意图
from transformers import AutoTokenizer, AutoModelForSequenceClassification, TextClassificationPipeline
model_name = 'qanastek/XLMRoberta-Alexa-Intents-Classification'
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
classifier = TextClassificationPipeline(model=model, tokenizer=tokenizer)
res = classifier("What's the weather like today?")
print(res)
# [{'label': 'weather_query', 'score': 0.9999779462814331}]
论文 同时预测意图和槽位
BERT for Joint Intent Classification and Slot Filling:https://arxiv.org/abs/1902.10909