简体   繁体   English

如何使用NLTK创建更高级的响应聊天机器人?

[英]How to make a more advanced responding chatbot with NLTK?

I have done a lot of research on how to create chat bots (the responding part) however I can't find a way to make it more advanced. 我已经对如何创建聊天机器人(响应部分)进行了大量研究,但是我找不到使它变得更高级的方法。 For example, I keep seeing NLTK reflections but I want to know if there are more advanced methods in NLTK (or other modules) that allow me to create a learning bot, smart bot or even an AI but I am struggling in finding modules, tutorials or documentation that help with getting started and proceeding that way. 例如,我一直看到NLTK反映,但是我想知道NLTK(或其他模块)中是否有更高级的方法可以让我创建学习机器人,智能机器人甚至是AI,但是我在努力寻找模块,教程或有助于入门和以这种方式进行操作的文档。 Reflections don't always work well like responding in context unless you have many lines of code pre-written for content which is inefficient and may not always be accurate. 反射并不总是像在上下文中响应那样总是工作得很好,除非您为效率低下且可能并不总是准确的内容预先编写了许多行代码。 Note: I don't want to be spoon fed, I just want to be pointed in the right direction of stuff that I can do and look at. 注意:我不想被喂饱,我只是想指出正确的方向,我可以做的和看的东西。

a solution would be eg user asks: "who is your favourite actor?" 例如,一个解决方案是用户问:“谁是您最喜欢的演员?”

bot replies with: "Brad Pitt" 机器人回复:“布拉德·皮特”

(only though of Brad because of the ad astra advertisements xD) (仅由于广告astra广告xD而属于Brad)

Below is the code that I am trying to stay away from. 下面是我想远离的代码。

pairs = [
    [
        r"my name is (.*)",
        ["Hello %1, How are you today ?",]
    ],
     [
        r"what is your name ?",
        ["My name is Chatty and I'm a chatbot ?",]
    ],
    [
        r"how are you ?",
        ["I'm doing good\nHow about You ?",]
    ],
    [
        r"sorry (.*)",
        ["Its alright","Its OK, never mind",]
    ],
    [
        r"i'm (.*) doing good",
        ["Nice to hear that","Alright :)",]
    ]```    

There are two main styles of conversational agents: retrieval and generative . 对话代理的主要样式有两种: 检索和生成 The regex code you show can be thought of as a very simple retrieval model. 您显示的正则表达式代码可以认为是一个非常简单的检索模型。 More complicated retrieval models classify user input with a classifier (at this point, almost always a neural network). 更为复杂的检索模型使用分类器对用户输入进行分类(此时,几乎始终是神经网络)。 Generative models treat the input to output mapping as a machine translation problem, and use techniques from NMT, neural machine translation. 生成模型将输入到输出的映射视为机器翻译问题,并使用NMT中的技术,即神经机器翻译。

Some resources: 一些资源:

  • The new verrsion of Speech and Language processing , by Dan Jurafsky and James H. Martin has three chapters on bots/question-answering Dan Jurafsky和James H. Martin撰写的《 语音和语言处理 》的新版本共分三章,涉及机器人/问题解答
  • If you are trying to build something practical, then you should use a mature library. 如果您尝试构建一些实用的东西,那么应该使用成熟的库。 IMO, Rasa has been leading the pack for a few years at this point IMO, Rasa在这一点上已经领先了几年

The code you want to stay away from used to be the very beginning of cahtbots (Eliza: https://blog.infermedica.com/introduction-to-chatbots-in-healthcare/ ). 您想要远离的代码曾经是cahtbots的开始(Eliza: https ://blog.infermedica.com/introduction-to-chatbots-in-healthcare/)。 A good starting point is a full dialogue system. 一个完整的对话系统是一个很好的起点。 You could use for example the trindikit for python, which is basically a dialogue manager. 您可以使用例如trindikit for python,它基本上是一个对话管理器。 Furthermore, you need to implement some sort of common sense reasoning database (eg compare Erik T Mueller: Commonsense Reasoning - An event Calculus based approach). 此外,您需要实现某种常识推理数据库(例如,比较Erik T Mueller:常识推理-基于事件演算的方法)。 Normally, most chatbots are focussed on a specific domain (product questions, recommender etc.), so you need to fix exactly what intentions may provoke which speech acts, classify and model them accordingly (LSTM for calssification, Bayes for production). 通常,大多数聊天机器人都专注于特定领域(产品问题,推荐者等),因此您需要准确确定可能引起哪种语音行为的意图,并对其进行分类和建模(LSTM用于校准,贝叶斯用于生产)。 Upon all this you either have to build a surface realisation system or use canned text as templates, which is growing work when your domain expands more and more. 基于这些,您要么必须构建一个表面实现系统,要么使用罐头文本作为模板,当您的域越来越多地扩展时,这项工作就越来越多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM