-
Notifications
You must be signed in to change notification settings - Fork 55
Added chatbot imlementation project #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
180 changes: 180 additions & 0 deletions
180
docs/projects/natural-language-processing/chatbot-project-implementation.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
|
|
||
| # Chatbot Implementation Project | ||
|
|
||
| ## AIM | ||
| To develop a chatbot using Natural Language Processing (NLP) and a Naive Bayes classifier for intent classification. The chatbot takes user input, predicts the intent, and generates an appropriate response based on predefined intents and responses stored in a CSV file. | ||
|
|
||
|
|
||
| ### DATASET LINK | ||
| [https://drive.google.com/file/d/1J7mGS16EkgCEtN7UJtBlJACeqoDbdS4F/view?usp=drive_link](https://drive.google.com/file/d/1J7mGS16EkgCEtN7UJtBlJACeqoDbdS4F/view?usp=drive_link) | ||
|
|
||
|
|
||
| ### NOTEBOOK LINK | ||
| [https://colab.research.google.com/drive/1L2LKfbVv4pb4yzczcRnnU4AkEW-kCZSZ?usp=sharing](https://colab.research.google.com/drive/1L2LKfbVv4pb4yzczcRnnU4AkEW-kCZSZ?usp=sharing) | ||
|
|
||
|
|
||
|
|
||
| ## LIBRARIES NEEDED | ||
|
|
||
| ??? quote "LIBRARIES USED" | ||
| - nltk | ||
| - scikit-learn | ||
| - numpy | ||
| - pickle | ||
|
|
||
|
|
||
| --- | ||
|
|
||
|
|
||
| ### DESCRIPTION | ||
|
|
||
| ??? info "What is the Requirement of the Project?" | ||
| -A chatbot is required to automate conversations and provide immediate responses to user queries. It can be used to answer FAQs, provide customer support, and improve user interaction. | ||
|
|
||
| ??? info "Why is it Necessary?" | ||
| - Chatbots are essential for improving user engagement and providing 24/7 service. | ||
| - They automate responses, saving time and providing immediate help. | ||
|
|
||
| ??? info "How is it Beneficial and Used?" | ||
| - Chatbots can be used for: | ||
| 1. Customer service automation. | ||
| 2. Answering user questions. | ||
| 3. Guiding users through processes on websites or apps. | ||
|
|
||
|
|
||
| #### "Initial Thoughts and Planning" | ||
| - **Intents and Responses**: Gathered and stored in CSV format. | ||
| - **Preprocessing**: Tokenized and lemmatized text to prepare for model training. | ||
| - **Model**: Built a Naive Bayes classifier to predict intents. | ||
| - **Deployment**: Deployed the model to predict user queries and return appropriate responses. | ||
|
|
||
| --- | ||
|
|
||
| #### Additional Resources Used | ||
| - [Scikit-learn Documentation](https://scikit-learn.org) | ||
| - **Tutorial**: Building Chatbots with NLP and Machine Learning | ||
|
|
||
| --- | ||
|
|
||
| ### FEATURES IN THE DATASET | ||
|
|
||
| | Feature | Description | | ||
| |-----------|---------------------------------------------------| | ||
| | `intents` | User query categories like greetings, farewells. | | ||
| | `responses` | Predefined chatbot responses for each intent. | | ||
|
|
||
| --- | ||
|
|
||
| #### STEPS AND IMPLEMENTATION | ||
|
|
||
| === "step 1" | ||
| Data Preprocessing | ||
| - Loaded the intents from CSV files. | ||
| - Cleaned data by removing duplicates and handling null values. | ||
|
|
||
|
|
||
|
|
||
| === "step 2" | ||
| Vectorization | ||
| - Used `TfidfVectorizer` to convert text into vectors. | ||
| - Split data into training and testing sets. | ||
|
|
||
|
|
||
| === "step 3" | ||
| Model Training | ||
| - Trained a Naive Bayes classifier on the preprocessed data. | ||
| - Saved the model for future use with `pickle`. | ||
| - Created an intent-response mapping. | ||
|
|
||
| === "step 4" | ||
| Prediction and Response Generation** | ||
| - The chatbot predicts the intent based on user input. | ||
| - Fetches and returns the appropriate response. | ||
|
|
||
| === "step 5" | ||
| Testing | ||
| - Conducted live interaction tests with the chatbot. | ||
|
|
||
|
|
||
| --- | ||
|
|
||
| ### Features Not Implemented Yet | ||
| - Integration of a deep learning model (e.g., RNN or LSTM) for better context handling. | ||
|
|
||
| --- | ||
|
|
||
|
|
||
| ### Flow Chart | ||
|
|
||
| ```mermaid | ||
| graph TD | ||
| A[Data Preprocessing] --> B[Vectorization] | ||
| B --> C[Model Training] | ||
| C --> D[Prediction and Response Generation] | ||
| D --> E[Testing the Chatbot] | ||
|
|
||
| A1[Load intents from CSV] --> A2[Clean data: remove duplicates and handle nulls] | ||
| A --> A1 | ||
| A --> A2 | ||
|
|
||
| B1[Use TfidfVectorizer to convert text into vectors] --> B2[Split data into training and testing sets] | ||
| B --> B1 | ||
| B --> B2 | ||
|
|
||
| C1[Train Naive Bayes classifier] --> C2[Save model with pickle] --> C3[Create intent-response mapping] | ||
| C --> C1 | ||
| C --> C2 | ||
| C --> C3 | ||
|
|
||
| D1[Chatbot predicts intent] --> D2[Fetch appropriate response based on intent] --> D3[Return response to user] | ||
| D --> D1 | ||
| D --> D2 | ||
| D --> D3 | ||
|
|
||
| E1[Live interaction with chatbot] --> E2[Test accuracy and responses] | ||
| E --> E1 | ||
| E --> E2 | ||
| ``` | ||
| ``` | ||
|
|
||
| #### Example Chatbot Interaction: | ||
|
|
||
| ```text | ||
| You: Hello | ||
| Bot: Hi, How can I assist you? | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## MODELS AND EVALUATION METRICS | ||
|
|
||
| | Model | Accuracy | Precision | Recall | | ||
| |------------------|----------|-----------|--------| | ||
| | Naive Bayes | 92% | 91% | 90% | | ||
|
|
||
| --- | ||
|
|
||
| ### CONCLUSION | ||
|
|
||
| ??? "What Have You Learned?" | ||
| - Building a chatbot using NLP techniques can automate interactions and provide user-friendly interfaces for businesses. | ||
| -The Naive Bayes classifier is an effective yet simple model for intent prediction. | ||
|
|
||
| --- | ||
|
|
||
| #### USE CASES | ||
|
|
||
| === "Application 1" | ||
|
|
||
| **Customer Support Automation** | ||
|
|
||
| -Provide 24/7 automated support for customers. | ||
|
|
||
|
|
||
| === "Application 2" | ||
|
|
||
| **FAQ Automation** | ||
|
|
||
| - Automatically respond to frequently asked questions on websites or apps. | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,16 @@ | ||
| # Natural Language Processing π£οΈ | ||
| # Chatbot Implementation π€ | ||
|
|
||
| <div style="display: flex; flex-direction: column; gap: 10px;"> | ||
|
|
||
| <!-- Chatbot Implementation --> | ||
| <a href="chatbot-project-implementation" style="padding: 0 2px 0 16px; background-color: rgba(39, 39, 43, 0.4); border: 1px solid rgba(76, 76, 82, 0.4); border-radius: 10px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); overflow: hidden; transition: transform 0.2s; display: flex; align-items: center;"> | ||
| <img src="https://media.istockphoto.com/id/1510476834/photo/ai-robot-icon-on-smartphone-chat-concept-with-ai-artificial-intelligence.jpg?s=1024x1024&w=is&k=20&c=cXTdI1ZrkVnzyvKJSglFaR354dgZbe4btsaDbTwyKV8=" alt="Chatbot Illustration" style="width: 300px; height: 150px; object-fit: cover; border-radius: 10px;" /> | ||
| <div style="padding: 15px;"> | ||
| <h2 style="margin: 0; font-size: 20px;">Chatbot Implementation Project</h2> | ||
| <p style="font-size: 16px;">Developing a modern chatbot system using NLP techniques and AI algorithms.</p> | ||
| <p style="font-size: 12px;">π 2025-01-21 | β±οΈ 15 mins</p> | ||
| </div> | ||
| </a> | ||
|
|
||
| </div> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't add this heading