PolyBot is an offline, NLP-powered college/university FAQ chatbot built using Flask, NLTK, and Scikit-Learn. It parses and maps user questions to a pre-defined database of over 40+ FAQ entries using TF-IDF vectorization and cosine similarity matching, requiring zero external paid APIs.
- User Query Input: The user asks a question in the chat interface.
- Text Preprocessing: The backend uses NLTK to tokenize, lowercase, strip stopwords/punctuation, and lemmatize the input string (e.g. converting "admissions" and "admitted" to their root word "admit").
- TF-IDF & Vectorization: Both the user question and the FAQ database questions are vectorized into a bag-of-words model using Scikit-Learn's
TfidfVectorizer. - Cosine Similarity Matching: Cosine similarity is computed between the query vector and all FAQ question vectors.
- Threshold Filter: If the highest similarity score is above
0.2, the chatbot returns the corresponding answer. Otherwise, it falls back to a friendly message prompting the user to rephrase.
- Backend: Python (Flask)
- Natural Language Processing (NLP):
- NLTK: Tokenization, Stopwords filtering, and WordNet Lemmatization
- Scikit-Learn: TF-IDF Vectorization and Cosine Similarity
- NumPy: Matrix index math
- Frontend: Semantic HTML5, CSS3 (Glassmorphism & Flexbox), and Vanilla JS
CodeAlpha_FAQChatbot/
βββ app.py
βββ faqs.py
βββ chatbot.py
βββ templates/
β βββ index.html
βββ static/
β βββ style.css
β βββ script.js
βββ requirements.txt
βββ README.md
- High-Quality Custom Dataset: Built-in repository of 41+ Q&A pairs covering admissions, fees, hostel rooms, exams, library access, placements, and campus activities.
- WhatsApp/ChatGPT-Style UI: Modern dark navy theme featuring a glowing send button, animated typing indicator, and responsive bubble layouts.
- Auto NLTK Downloader: Automatically downloads NLTK packages (
punkt,stopwords,wordnet, andomw-1.4) on the first run. - Enter-to-Send: Supports standard keyboard triggers for quick sending.
- Scroll Memory: Auto-scrolls to the newest message bubbles.
- No API Costs: Executes entirely offline with no usage caps.
Open your terminal and enter the project folder:
cd CodeAlpha_FAQChatbotInstall the required packages listed in requirements.txt:
pip install -r requirements.txtStart the local server:
python app.pyOn first run, the terminal will log the NLTK downloads. Once completed, the server will launch.
Open your browser and visit:
http://127.0.0.1:5000/
Jenicadeva Christa S (CodeAlpha AI Intern)