Spaces:
Sleeping
π Deployment Guide: Hugging Face Spaces
This guide will help you deploy your Multi-Personality Chatbot to Hugging Face Spaces for free public access.
π Prerequisites
Hugging Face Account (free)
- Sign up at: https://huggingface.co/join
- Verify your email
Git and Git LFS installed
- Git: https://git-scm.com/downloads
- Git LFS: https://git-lfs.github.com/
π― Step-by-Step Deployment
Step 1: Create a Hugging Face Space
- Go to https://huggingface.co/spaces
- Click "Create new Space"
- Fill in:
- Space name:
personality-chatbot(or your preferred name) - License: MIT or Apache 2.0
- Select SDK: Choose Gradio
- Hardware: Start with CPU basic (free), upgrade to GPU if needed
- Visibility: Public (so anyone can access)
- Space name:
- Click "Create Space"
Step 2: Set Up Local Repository
Open PowerShell in your project folder:
# Navigate to your project
cd C:\Users\dcast\LLM\Project3\llm-project
# Initialize git (if not already done)
git init
# Install Git LFS (for large model files)
git lfs install
# Track large files with Git LFS
git lfs track "*.safetensors"
git lfs track "*.bin"
git lfs track "*.json"
# Add all files
git add .gitattributes
git add .
# Commit
git commit -m "Initial commit: Multi-personality chatbot"
Step 3: Push to Hugging Face
Replace YOUR_USERNAME and YOUR_SPACE_NAME with your actual values:
# Add Hugging Face remote
git remote add space https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
# Push to Hugging Face
git push --set-upstream space main
Authentication: You'll be prompted for username and password
- Username: Your Hugging Face username
- Password: Use your Hugging Face Access Token (not your account password)
- Get token at: https://huggingface.co/settings/tokens
- Create a Write token
Step 4: Wait for Build
- Go to your Space URL:
https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME - The Space will automatically build (takes 5-15 minutes first time)
- You'll see build logs in the "Logs" tab
- Once done, your app will be live! π
Step 5: Share Your App
Your app will be accessible at:
https://YOUR_USERNAME-YOUR_SPACE_NAME.hf.space
Anyone can access this URL without authentication!
π Troubleshooting
"Repository too large" error
Problem: Adapter files are too big for free tier
Solution: Upload adapters to Hugging Face Model Hub separately
Create model repos for each adapter:
# Install huggingface-hub pip install huggingface-hub # Upload each adapter (run in Python) python -c "from huggingface_hub import HfApi; api = HfApi(); api.upload_folder(folder_path='pirate-lora-adapter', repo_id='YOUR_USERNAME/pirate-lora', repo_type='model')"Update
app.pyto load from Hub:ADAPTERS = { "π΄ββ οΈ Pirate": "YOUR_USERNAME/pirate-lora", "π§ Yoda": "YOUR_USERNAME/yoda-lora", "π€ Nerd": "YOUR_USERNAME/nerd-lora", "π§ Brainrot": "YOUR_USERNAME/brainrot-lora", }
"Out of memory" on CPU
Solution: Upgrade to GPU hardware
- Go to Space Settings
- Click "Change hardware"
- Select "GPU - T4 small" (free tier)
Build fails with "Module not found"
Solution: Check requirements.txt has all dependencies
gradio>=4.0.0
torch>=2.0.0
transformers>=4.35.0
peft>=0.7.0
accelerate>=0.24.0
safetensors>=0.4.0
π¨ Customization
Change app title/description
Edit app.py - modify the gr.Markdown() sections
Add more personalities
- Train a new adapter
- Add to
ADAPTERSdict inapp.py - Upload the new adapter folder
- Push changes:
git add . && git commit -m "Add new personality" && git push space main
Improve performance
- Use GPU hardware (Space settings)
- Reduce
max_tokensdefault - Add response caching
π Free Tier Limits
Hugging Face Spaces Free Tier:
- β CPU: Unlimited (but slow for LLMs)
- β GPU T4: Limited hours/month (check your account)
- β Storage: 50GB total
- β Persistence: 24/7 uptime
- β Public access: Unlimited users
Tips to stay within limits:
- Start with CPU, upgrade to GPU if too slow
- Keep model size small (Qwen2-0.5B is perfect)
- Monitor usage in Space Settings
π Useful Links
- Hugging Face Spaces Docs: https://huggingface.co/docs/hub/spaces
- Gradio Docs: https://www.gradio.app/docs
- Git LFS Guide: https://git-lfs.github.com/
π Need Help?
If you encounter issues:
- Check Space logs (Logs tab)
- Check build status
- Ask in Hugging Face Discord: https://discuss.huggingface.co/
That's it! Your chatbot is now publicly accessible to anyone with the URL. π