Created
August 11, 2018 14:15
-
-
Save imohitmayank/7eea297ecde9e9e1406a00012e4f713f to your computer and use it in GitHub Desktop.
rasa_starter/train_dialog.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Imports | |
#----------- | |
# rasa core | |
import logging | |
from rasa_core import training | |
from rasa_core.actions import Action | |
from rasa_core.agent import Agent | |
from rasa_core.domain import Domain | |
from rasa_core.policies.keras_policy import KerasPolicy | |
from rasa_core.policies.memoization import MemoizationPolicy | |
from rasa_core.featurizers import MaxHistoryTrackerFeaturizer, BinarySingleStateFeaturizer | |
from rasa_core.channels.console import ConsoleInputChannel | |
from rasa_core.interpreter import RegexInterpreter | |
from rasa_core.interpreter import RasaNLUInterpreter | |
# Function | |
#------------ | |
def train_dialog(dialog_training_data_file, domain_file, path_to_model = 'models/dialogue'): | |
logging.basicConfig(level='INFO') | |
agent = Agent(domain_file, | |
policies=[MemoizationPolicy(max_history=1)]) | |
training_data = agent.load_data(dialog_training_data_file) | |
agent.train( | |
training_data, | |
augmentation_factor=50, | |
epochs=200, | |
batch_size=10, | |
validation_split=0.2) | |
agent.persist(path_to_model) | |
# Train | |
#-------- | |
train_dialog('data/stories.md', 'domain.yml') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment