关于虚拟助手或聊天机器人,通常称为意向分类。有很多方法可以做到这一点,但通常您会提供标记示例并训练一个模型来区分它们。这里从a blog post关于这个专题的一些示例数据:
# 3 classes of training data
training_data = []
training_data.append({"class":"greeting", "sentence":"how are you?"})
training_data.append({"class":"greeting", "sentence":"how is your day?"})
training_data.append({"class":"greeting", "sentence":"good day"})
training_data.append({"class":"greeting", "sentence":"how is it going today?"})
training_data.append({"class":"goodbye", "sentence":"have a nice day"})
training_data.append({"class":"goodbye", "sentence":"see you later"})
training_data.append({"class":"goodbye", "sentence":"have a nice day"})
training_data.append({"class":"goodbye", "sentence":"talk to you soon"})
training_data.append({"class":"sandwich", "sentence":"make me a sandwich"})
training_data.append({"class":"sandwich", "sentence":"can you make a sandwich?"})
training_data.append({"class":"sandwich", "sentence":"having a sandwich today?"})
training_data.append({"class":"sandwich", "sentence":"what's for lunch?"})
虽然你的训练数据是特定于应用程序,原则上它不是从自动分类电子邮件或新闻报道不同。
用于文本分类的易于使用的基线算法是朴素贝叶斯。更新的方法包括使用移动词的距离或神经网络。
您提取主题的部分也被称为槽检测,助理的“intent and slot”体系结构很常见。即使您想从头开始构建一些东西,查看诸如rasa等chatbot平台的配置屏幕可能对了解如何使用培训数据很有帮助。
谢谢你的一个很好的答案!如果我将POS标签应用于用户输入和训练数据,这是否会增加分类器的整体准确性? – Exo445
POS标签可能有用或不可用,它完全取决于您的方法。尝试在你的数据上使用它们,看看它是否有效! – polm23