简体   繁体   English

Python Chatterbot效率问题

[英]Python Chatterbot efficiency issues

I have made a simple feedback loop program using Chatterbot. 我已经使用Chatterbot制作了一个简单的反馈循环程序。 The below code takes one to two minutes to respond to itself, and a similar amount of time to load. 以下代码需要一到两分钟的时间来响应自身,并且加载时间也差不多。 My question is regarding efficiency - is taking one to two minutes for getting a response normal for chatterbot? 我的问题是关于效率的问题-是否需要花费一到两分钟的时间才能使chatterbot正常响应? If it isn't, how could I improve my efficiency? 如果不是,我如何提高效率?

Other details - if I don't have the silence performance warning paramater set to true in my chatterbot creation, the following error appears. 其他详细信息-如果我在chatterbot创建过程中没有将静音性能警告参数设置为true,则会出现以下错误。

UnsuitableForProductionWarning: The JsonFileStorageAdapter is not recommended for production environments. UnsuitableForProduction警告:不建议在生产环境中使用JsonFileStorageAdapter。
self.UnsuitableForProductionWarning 自我。不适用于生产警告

This is my code. 这是我的代码。

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

I understand that due to the nature of the bot responding to itself, it shall eventually only output one message repeatedly. 我了解到,由于漫游器会自行响应,因此最终只会重复输出一条消息。 This I am not worried about. 这我不担心。

Update - the problem resides within visual studio 2015. I have discovered that running my code using the standard IDLE returns the output I expected instantaneously. 更新-问题存在于Visual Studio 2015中。我发现使用标准IDLE运行我的代码会立即返回我期望的输出。

It's nuts to train a model for every request you process. 为您处理的每个请求训练模型都是很疯狂的。 Use a separate script to train and pickle your trained model, then load the pickled model in your interactive script (the one you show us, minus the training) and use it to handle responses. 使用单独的脚本来训练和腌制您训练后的模型,然后将腌制的模型加载到您的交互式脚本中(您向我们展示的那个模型,减去训练)并使用它来处理响应。

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

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