Skip to content

Instantly share code, notes, and snippets.

@nahidalam
Created September 30, 2018 05:19
Show Gist options
  • Save nahidalam/9a8c1c2d6ed784d83673c313d607aa34 to your computer and use it in GitHub Desktop.
Save nahidalam/9a8c1c2d6ed784d83673c313d607aa34 to your computer and use it in GitHub Desktop.
Training and running dialogue model
def train_dialogue(domain_file = 'customer_domain.yml',
model_path = './models/dialogue',
training_data_file = './data/stories.md'):
agent = Agent(domain_file, policies = [MemoizationPolicy(), KerasPolicy()])
agent.train(
training_data_file,
epochs = 300,
batch_size = 50,
validation_split = 0.2)
agent.persist(model_path)
return agent
def run_customer_bot(serve_forever=True):
interpreter = RasaNLUInterpreter('./models/nlu/default/customernlu')
agent = Agent.load('./models/dialogue', interpreter = interpreter)
if serve_forever:
agent.handle_channel(ConsoleInputChannel())
return agent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment