Back to Projects

Intent Classification Bot

NLP chatbot with bag-of-words and neural network classification.

PythonNLTKTensorFlowBoWNeural Network

Demo Conversation

Intent Detection

weather94% conf
"What's the weather like?"
"Tell me the forecast"
"Is it going to rain?"
goodbye97% conf
"Bye"
"See you later"
"Thanks, bye!"

NLP Pipeline

1
Tokenization
Split sentence into words
"What's the weather?" → ["what", "the", "weather"]
2
Stemming
Reduce to root forms (Porter Stemmer)
["running", "runs"] → ["run", "run"]
3
Bag-of-Words
Binary vector encoding
vocab=[hello,weather,bye] → [0,1,0]
4
Classification
Neural network predicts intent
[0,1,0] → weather (94% confidence)

Neural Network

Input
BoW Vector
Hidden 1
128 neurons
Hidden 2
64 neurons
Output
Softmax

Modular Intent Corpus

intents.json
{
  "intents": [
    {
      "tag": "greeting",
      "patterns": ["Hi", "Hello", "Hey"],
      "responses": ["Hello!", "Hi there!"]
    },
    {
      "tag": "weather",
      "patterns": ["Weather?", "Forecast"],
      "responses": ["Which city?"]
    }
  ]
}
Easy Updates

Add intents by editing JSON — no code changes needed

Fast Retraining

<1 minute training on small datasets

Confidence Threshold

Falls back to "I don't understand" when uncertain (<70%)

Design Decisions

BoW + NN over Transformers
Sub-50ms inference on CPU. Perfect for domain-specific intents where BERT/GPT would be overkill.
Stemming > Lemmatization
Faster, no POS tagging needed. Acceptable tradeoff for intent matching.
Dropout for Regularization
50% dropout prevents overfitting on small training datasets.
Softmax with Threshold
Better to say "I don't know" than confidently return wrong answers.
<50ms
Inference Time
0.7
Confidence Threshold
128×64
Hidden Layers
JSON
Intent Format
Lightweight NLP chatbot for FAQs and utilities