Title, really. I was wondering if it's possible to save an existing model so that I don't have to train it every time I re-run my script.
I've looked at the docs, and the closest I found was the method export_for_training; but that only exports training data, not the chatbot itself.
Is there a mechanism that saves a chatbot?
ChatterBot instances are designed to be stateless. Everything that they learn is stored in a chat bot's connected database.
You shouldn't need to re-train your chat bot each time the script is run because the training data is persisted.
So, to answer the question, there is no method that allows a chat bot to be "saved", but if yo want to create a database backup then you can easily restore it to another chat bot's database.
Thanks!
As master @gunthercox said, the trained data is persist, so we can re-use whenever you required.
some workaround or an actual answer i am not sure, you could split your bot program into two phase one for train, one for bot.
For example
train.py
# -*- coding: utf-8 -*-
from chatterbot import ChatBot
# Create a new chat bot named Charlie
chatbot = ChatBot(
'Charlie',
trainer='chatterbot.trainers.ListTrainer'
)
chatbot.train([
"Hi, can I help you?",
"Sure, I'd like to book a flight to Iceland.",
"Your flight has been booked."
])
bot.py
```Python
# -*- coding: utf-8 -*-
from chatterbot import ChatBot
# Create a new chat bot named Charlie
chatbot = ChatBot(
'Charlie',
trainer='chatterbot.trainers.ListTrainer'
)
# Get a response to the input text 'How are you?'
response = chatbot.get_response('I would like to book a flight.')
print(response)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
ChatterBot instances are designed to be stateless. Everything that they learn is stored in a chat bot's connected database.
You shouldn't need to re-train your chat bot each time the script is run because the training data is persisted.
So, to answer the question, there is no method that allows a chat bot to be "saved", but if yo want to create a database backup then you can easily restore it to another chat bot's database.