首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python Chatterbot效率问题

Python Chatterbot效率问题
EN

Stack Overflow用户
提问于 2017-03-26 13:47:26
回答 1查看 727关注 0票数 0

我做了一个简单的反馈循环程序使用聊天机器人。下面的代码需要一到两分钟才能对自己做出响应,加载的时间也差不多。我的问题是关于效率如果不是,我怎样才能提高效率呢?

其他细节--如果在我的聊天机器人创建中没有将沉默性能警告参数设置为true,则会出现以下错误。

UnsuitableForProductionWarning:生产环境不推荐使用JsonFileStorageAdapter。 self.UnsuitableForProductionWarning

这是我的密码。

代码语言:javascript
复制
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

chatterbot = ChatBot("Training Example",silence_performance_warning=True,storage_adapter='chatterbot.storage.JsonFileStorageAdapter')
chatterbot.set_trainer(ChatterBotCorpusTrainer)

chatterbot.train(
    "chatterbot.corpus.english.greetings",
    "chatterbot.corpus.english.conversations"
)

print("Ready")
print("1 : How are you?")
response = "How are you?"
first = False

while True:
    response = chatterbot.get_response(str(response))
    if first:
        print("1 : "+str(response))
        first = False
    else:
        print("2 : "+str(response))
        first = True

我明白,由于bot本身的性质,它最终只能重复输出一条信息。这一点我并不担心。

更新-问题存在于visual studio 2015中。我已经发现,使用标准的空闲运行代码会立即返回我期望的输出。

EN

回答 1

Stack Overflow用户

发布于 2017-03-26 16:27:20

为你处理的每一个请求训练一个模型是很疯狂的。使用一个单独的脚本来训练和挑选您经过训练的模型,然后在您的交互脚本中加载被腌制的模型(您向我们展示的那个,减去培训),并使用它来处理响应。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43029533

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档