The implementation is straightforward with a Feed Forward Neural net with 2 hidden layers and 1 output layer.
$ git clone https://github.com/CaoHoangKiet222/Chatbot
$ cd Chatbot
$ python3 -m venv venv
Mac / Linux:
. venv/bin/activate
Windows:
venv\Scripts\activate
For Installation of PyTorch see official website.
You also need nltk
:
pip install nltk
python3 chat.py
Have a look at intents.json. You can customize it according to your own use case. Just define a new tag
, possible patterns
, and possible responses
for the chat bot. You have to re-run the training whenever this file is modified.
{
"intents": [
{
"tag": "greeting",
"patterns": [
"Hi",
"Hey",
"How are you",
"Is anyone there?",
"Hello",
"Good day"
],
"responses": [
"Hey :-)",
"Hello, thanks for visiting",
"Hi there, what can I do for you?",
"Hi there, how can I help?"
]
},
...
]
}
[1] Wikipedia, "FeedForward Neural Network," Wikipedia, [Online]. Available: https://en.wikipedia.org/wiki/Feedforward_neural_network.
[2] T. Wood, "Activation Function," DeepAI, [Online]. Available: https://deepai.org/machine-learning-glossary-and-terms/activation-function.
[3] PyTorch, "Neural Network" [Online]. Available: https://pytorch.org/tutorials/beginner/basics/buildmodel_tutorial.html
[4] PyTorch, "Optimizing Model Parameters" [Online]. Available: https://pytorch.org/tutorials/beginner/basics/buildmodel_tutorial.html