O'Reilly logo

Hands-On Natural Language Processing with Python by Rajalingappaa Shanmugamani, Rajesh Arumugam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Putting it all together

To run everything we have just coded, we will define our model hyperparameters and instantiate our chatbot model. We will then proceed to start training the model for 200 epochs, evaluating its performance on the validation set every 10 epochs. After training, we can test the model on the testing data as follows:

chatbot = ChatBotWrapper(train_data, test_data, val_data,                         candidates, candidates_to_idx,                         memory_size=50,                         batch_size=32,                         learning_rate=0.001,                         evaluation_interval=10,                         hops=3,                         epochs=100,                         embedding_size=50)chatbot.train()chatbot.test()

The following is the output:

Epoch: 10Total Cost: 17703.9733608Training Accuracy: 0.756870229008Validation Accuracy: 0.729912770223------------------------------------------------ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required