This project is a contextual chatbot built using TensorFlow. The chatbot is designed to provide meaningful responses based on general input queries and those related to baking by leveraging natural language processing (NLP) techniques and machine learning.
- Tokenization and stemming of input text for preprocessing.
- Classification of user intents using bag-of-words.
- Training a neural network to classify intents.
- Generating appropriate responses based on user queries.
- Flexible and extensible design to add more intents and responses.
- Python 3.7 or higher
- Libraries:
- TensorFlow
- Numpy
- NLTK
Refer to requirements.txt for installing all the dependencies.
-
Clone the Repository:
git clone https://github.com/Subhoshri/Chatbot cd Chatbot -
Install required Libraries:
pip install Library-Name
-
Prepare the Environment:
- Download NLTK data (if not already installed):
import nltk nltk.download('punkt')
- Download NLTK data (if not already installed):
-
Update the intents file: Modify the
intents.jsonfile to add or update chatbot intents and patterns. -
Run the Application:
python app.py
-
Enter the URL provided after running the previous commands into your web browser.
Bakerly is now ready to chat!
- The
intents.jsonfile contains training data in patterns, and their associated tags (and contexts). - Words in patterns are tokenized and stemmed using NLTK's Stemmer.
- A bag-of-words representation is generated for each pattern.
- A feed-forward neural network (FFNN) is trained on the bag-of-words and output tags using TensorFlow.
- The output is a one-hot-encoded vector representing the possible intent classes.
- The trained model predicts the intent of user input.
- The bot selects an appropriate response from the
responseslist associated with the predicted intent.
- User Input: "Hello!"
- Preprocessing:
- Tokenize:
["hello"] - Stem:
["hello"] - Bag of Words:
[1, 0, 0, 0, ...]
- Tokenize:
- Model Prediction: Intent ->
greeting - Bot Response: "Hi there! How can I assist you today?"
-
Adding New Intents:
- Update the
intents.jsonfile with new intents, patterns, and responses. - Retrain the model.
- Update the
-
Improving Responses:
- Use additional NLP techniques, such as named entity recognition (NER) or sentiment analysis, to enhance contextual responses.
- The chatbot may not handle out-of-scope queries effectively.
- Responses are limited to predefined data in the
intents.jsonfile.
- TensorFlow Documentation: https://www.tensorflow.org
This project is licensed under the MIT License.