🧠 My Fine-Tuned Local Chatbot
A locally hosted AI chatbot powered by a fine-tuned DistilGPT2 model using Hugging Face Transformers. This chatbot is trained on the Stanford Alpaca Instruction Dataset, enabling it to follow instructions and provide helpful responses — all without relying on internet access.
🚀 Features
- 🔒 Fully local – no internet required after setup
- 🧠 Fine-tuned on Stanford Alpaca-style instructions
- ⚡ Fast inference with CUDA or CPU fallback
- 🌐 Flask API with simple HTML/CSS/JavaScript frontend
- 🎨 Customizable prompts and response formatting
- 🧾 Chat history saved using SQLite
- Dataset Used: Stanford Alpaca
📂 Project Structure
├── app.py # Flask API backend
├── train.py # Script for fine-tuning the model
├── chatbot_model/
│ └── trained_model_* # Your fine-tuned model directory
├── static/
│ ├── styles.css # Frontend styles
│ └── script.js
├── templates/
│ └── index.html # Web UI
├── requirements.txt
├── README.md # You are here!
├── download.py
├── preprocess.py
├── int_db.py
├── chat_history.db # Saves history of chats
└── processed_dataset.csv
Demo
💡 Sample Prompt
Human: What is the capital of France?
Assistant: The capital of France is Paris.
🏋️♀️ Training
python train.py
This will:
Download the Stanford Alpaca dataset
Fine-tune distilgpt2
Save it inside: chatbot_model/trained_model_YYYYMMDD_HHMMSS/
🖥️ Run the App
python app.py
Then visit: http://localhost:5005
❓ FAQ
Q: Does this work offline? ✅ Yes! Once the model is fine-tuned, no internet is needed.
Q: Can I run it on CPU? ✅ Yes, but it will be slower. A CUDA GPU is recommended for faster responses.
Q: Can I replace the model? ✅ Yes! You can fine-tune any Hugging Face-compatible model by modifying train.py.
🛠️ Tech Stack
- Flask – Web server backend
- Transformers – Hugging Face inference
- PyTorch – Deep learning engine
- HTML/CSS/JavaScript – Frontend
- Stanford Alpaca Dataset
- SQLite – For saving chat history
- Python
📜 License
MIT License – Free to use, modify, and share.
👩💻 Author
Jasleen Kaur Matharoo
📧 [email protected]
🌐 GitHub @Jasleen-05
Model tree for Jasleen05/my-local-chatbot
Base model
distilbert/distilgpt2