Instructions to use Jasleen05/my-local-chatbot with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Jasleen05/my-local-chatbot with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Jasleen05/my-local-chatbot")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Jasleen05/my-local-chatbot", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Jasleen05/my-local-chatbot with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Jasleen05/my-local-chatbot" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Jasleen05/my-local-chatbot", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Jasleen05/my-local-chatbot
- SGLang
How to use Jasleen05/my-local-chatbot with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Jasleen05/my-local-chatbot" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Jasleen05/my-local-chatbot", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Jasleen05/my-local-chatbot" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Jasleen05/my-local-chatbot", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Jasleen05/my-local-chatbot with Docker Model Runner:
docker model run hf.co/Jasleen05/my-local-chatbot
π§ 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
π§ jasleen.matharoo@s.amity.edu
π GitHub @Jasleen-05
Model tree for Jasleen05/my-local-chatbot
Base model
distilbert/distilgpt2