我做了一个简单的反馈循环程序使用聊天机器人。下面的代码需要一到两分钟才能对自己做出响应,加载的时间也差不多。我的问题是关于效率如果不是,我怎样才能提高效率呢?
其他细节--如果在我的聊天机器人创建中没有将沉默性能警告参数设置为true,则会出现以下错误。
UnsuitableForProductionWarning:生产环境不推荐使用JsonFileStorageAdapter。 self.UnsuitableForProductionWarning
这是我的密码。
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中。我已经发现,使用标准的空闲运行代码会立即返回我期望的输出。
发布于 2017-03-26 16:27:20
为你处理的每一个请求训练一个模型是很疯狂的。使用一个单独的脚本来训练和挑选您经过训练的模型,然后在您的交互脚本中加载被腌制的模型(您向我们展示的那个,减去培训),并使用它来处理响应。
https://stackoverflow.com/questions/43029533
复制相似问题