π§ 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