/Chatbot

Primary LanguagePython

Chatbot

Python Django HTML5 CSS3 JavaScript PyTorch NumPy

Overview

What I learned:

  • How a chatbot works generally using tokenization, stemming, and a bag of words
  • How to use a neural network to make a deep learning chatbot

How a chatbot works

Tokenize

• Split a sentence into a word

'how are you' -> ['how', 'are', 'you']

Stemming

• reduce words into its root

['delivery', 'delivered', 'delivering'] -> ['deliv', 'deliv', 'deliv]

Bag of words

• counts occurence of words

input: how are you ['how', 'is', 'it', 'I', 'am', 'are', 'sell, 'you'] -> [1, 0, 0, 0, 0, 1, 0, 1]

Result

Then, it trains our model with a nural network.

After all, the bot chooses one of the corresponding responses even though the exact input is not there.

{
  "tag": "greeting",
  "patterns": [
      "Hi",
      "Hello",
      "What is up",
      "How are you doing",
      "Hey",
      "yo",
      "sup"
  ],
  "responses":[
      "Hey!",
      "Hello",
      "Hi there, how can I help?",
      "Hi, what can I do for you today?",
      "Hi, there"
  ]
}

You: How are you?

Bot: Hi, there

Setup

Download Python. Run these commands:

# Install Django
python -m pip install Django

# Move to the file directory
cd movie_recommendation

# Run the local server
python manage.py runserver

Demo

Video Link: Video

References

Followed this tutorial: Training our model, Speech to Text