Developing an intelligent chatbot using deep learning with Keras.
- see
requirements.txt
file - install the dependencies
- run
pip install -r requirements.txt
- run
- these intents are created to to establish context during a conversation
- create
intents.json
file
- these succeeding steps will be completed in the
train.ipynb
file -> everything is successfully ran in thetrain-kg.ipynb
file- import all the required packages
- load the json file and extract necessary data
- the
training_sentences
variable is what holds the training data -> the sample messages is the intent categories -thetraining_labels
variable holds the target labels that correspond with the training data
- the
- create the "LabelEncoder()" function to convert the target labels into an understandable model form
- create
tokenizer
class to vectorize the data corpus- using this class for the pre-processing tasks removes the punctuations and splits the words into lists of tokens
- the tokens are then indexed or vectorized
- the
oov_token
attribute is used to deal with out of vocabulary tokens
- the
padded_sequences
method is to make the training text sequences the same size
- used
Sequential
class from Keras to define the Neural Network architecture for the proposed model - used the
fit
method to train the model - saved the required files to use at inference time
- implementing a chat function to communicate with users
- How This Works?
- upon receiving a new message, the chat bot calculates the similarity between the new text sequence and the training data
- with the confidence scores from each category, the model categorizes the user's message to an intent with the correlating highest confidence score
- this is all laid out in the
chat.py
file