Skip to content

Chatbot based on natural language processing (NLP) and deep learning for accurate intent classification in conversations. - Artificial Inteligence Tecniques

Notifications You must be signed in to change notification settings

KPlanisphere/chatbot-intent-classifier

Repository files navigation

🤖 Chatbot Intent Classifier

🚀 Chatbot Intent Classifier is a deep learning-based chatbot designed to understand user intent using Natural Language Processing (NLP). It leverages word embeddings, sentence similarity, and neural networks to classify user inputs into predefined categories and generate accurate responses.

📌 Features

Intent classification using deep learning
Word embeddings with SentenceTransformers for better context understanding
Customizable intents via intents.json
Pretrained model for quick deployment
Real-time interaction through a command-line interface

📂 Project Structure

📦 chatbot-intent-classifier
 ┣ 📜 chatbot.py                 # Main chatbot script
 ┣ 📜 chatbot_model_intents.py   # Model training script
 ┣ 📜 intents.json               # Intent dataset (customizable)
 ┣ 📜 chatbot_model.keras        # Trained deep learning model
 ┣ 📜 words.pkl / classes.pkl    # Preprocessed data
 ┗ 📜 README.md                  # This file

🛠️ Installation & Setup

1️⃣ Clone the Repository

git clone https://github.com/yourusername/chatbot-intent-classifier.git
cd chatbot-intent-classifier

2️⃣ Install Dependencies

Make sure you have Python 3.8+ installed. Then, run:

pip install -r requirements.txt

3️⃣ Train the Model (Optional)

If you want to retrain the model with new intents, run:

python chatbot_model_intents.py

4️⃣ Run the Chatbot

python chatbot.py

💬 The chatbot will start and you can begin chatting in the terminal!

🧠 How It Works

1️⃣ Text Processing: The input text is tokenized and lemmatized.
2️⃣ Intent Prediction: Using SentenceTransformers, the chatbot calculates the similarity of user input with predefined patterns.
3️⃣ Neural Network: A deep learning model trained with Keras predicts the most likely intent.
4️⃣ Response Generation: A random response is selected from the predefined responses in intents.json.

📊 Model Training

The chatbot model is built using a feedforward neural network with multiple layers:

  • Input Layer: Vectorized text input
  • Hidden Layers: Fully connected layers with ReLU activation and dropout
  • Output Layer: Softmax classifier for intent prediction

🔍 Model Hyperparameters

  • Optimizer: Adam (learning_rate=0.001)
  • Loss Function: Categorical Cross-Entropy
  • Epochs: 300
  • Batch Size: 16

📝 Customizing Intents

You can add or modify intents in the intents.json file. Example format:

{
    "intents": [
        {
            "tag": "greeting",
            "patterns": ["Hello", "Hi there", "Hey!"],
            "responses": ["Hello!", "Hi, how can I help?", "Hey there!"],
            "keywords": ["hello", "hi", "hey"]
        }
    ]
}

🚀 Future Improvements

✨ Implement Transformer-based models for better intent detection
✨ Add speech-to-text integration for voice input
✨ Deploy as a web service using Flask or FastAPI

🤝 Contributing

Contributions are welcome! Feel free to fork this repo and submit a pull request.


💡 Developed by Planisphere.
📌 Follow me on GitHub for more projects! 🚀

About

Chatbot based on natural language processing (NLP) and deep learning for accurate intent classification in conversations. - Artificial Inteligence Tecniques

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published