高速对话引擎
flipgenic的Python项目详细描述
这是什么?在
Flipgenic是一个Python包,它可以帮助您创建聊天机器人 使用已知对话的数据库进行响应。它学习如何根据 它接收到的消息,或者来自数据集的消息,这些数据集是预先训练到其中的。在
如何使用它?在
下面是一个非常基本的例子:
# python -m pip install flipgenic# python -m spacy download en_core_web_mdfromflipgenicimportResponder# Create and connect to database# This can take a while to load the spaCy modelsresponder=Responder('/path/to/data/folder/')# Initialize the database with a single responseresponder.learn_response('Hello','Hi!')response=NonewhileTrue:text=input('> ')ifresponse:# Learn the input as a response to the previous outputresponder.learn_response(response,text)# Generate a responseresponse,distance=responder.get_response(text)print(response,f'({distance})')
有关更多信息,请参见ReadTheDocs。
它是如何工作的?在
输入信息(嗯,300维 vector representation其中)被存储 以及对那篇课文的任何反应。如果有人先输入 消息,则存储的响应将被找到并重新使用。在
使用 SpaCy。然后,这个向量用于 从NGT查询最接近的匹配项 包含先前所学信息向量的索引。每个对象ID 从索引对应一个或多个已知响应,存储在 基本SQLite数据库。选择最常见的回答,或随机选择一个 如果没有模式。在
- 项目
标签: