A professional, rule-based Intelligent FAQ Chatbot built using Python, Natural Language Processing (NLP), and basic Machine Learning techniques. The application utilizes TF-IDF (Term Frequency-Inverse Document Frequency) and Cosine Similarity to mathematically evaluate user queries and fetch highly accurate responses from a predefined computer science knowledge base.
Optimized to run seamlessly across both standard Desktop IDEs and Android-based terminal environments like Pydroid 3.
- Advanced Text Preprocessing: Automates tokenization, case-normalization, punctuation stripping, and English stopword elimination.
- Vector Space Modeling: Implements Scikit-Learn's
TfidfVectorizerto convert unstructured raw string queries into weighted mathematical vectors. - Cosine Similarity Matching: Uses spatial geometry formulas to determine the closest conceptual match between user intent and the database.
- Strict Confidence Filtering: Enforces a
0.25similarity threshold score. If user input is too ambiguous, the bot gracefully triggers a polite fallback prompt. - Cross-Platform CLI: Interactive, memory-efficient command-line loop handling real-time runtime execution.
┌──────────────┐ ┌──────────────────────┐ ┌────────────────────────┐
│ User Input │ ───> │ Text Preprocessing │ ───> │ TF-IDF Vectorization │
└──────────────┘ │ (NLTK Stopwords) │ └────────────────────────┘
└──────────────────────┘ │
▼
┌──────────────┐ ┌──────────────────────┐ ┌────────────────────────┐
│ Final Answer │ <─── │ Threshold Validation │ <─── │ Cosine Similarity │
└──────────────┘ │ (> 0.25) │ │ (vs Dataset Keys) │
└──────────────────────┘ └────────────────────────┘
- Core Language: Python 3.x
- Primary Frameworks:
nltk(Natural Language Toolkit) - String tokenization and semantic filtering.scikit-learn- Vector mapping matrix operations.string- Standard structural operations.
Ensure you have your environment configured with the required dependencies before bootstrapping the script.
Execute the following native pip command in your terminal console:
pip install nltk scikit-learn- Launch the Pydroid 3 application interface.
- Select the Pip management terminal from the left sidebar navigation menu.
- Search for
nltkandscikit-learnindependently, then click Install.
- Clone the project locally or pull it directly into your active workspace.
- Fire up the core script via your terminal command structure:
python faq_chatbot.py
- Note on First Run: The backend pipeline will automatically parse and sync missing remote packages (
punkt,punkt_tab,stopwords) onto your local machine storage. - Interact directly within the continuous interface (e.g., "What is python?", "What is machine learning?").
- Type
exitsmoothly to shut down and de-allocate memory safely.
- Harshita Jain
This repository is distributed under the open-source MIT License. Feel free to fork, modify, and utilize this project framework for your academic or custom implementations.