WritingStudio / DEPLOY_TO_HF_SPACES.md
jmisak's picture
Upload 46 files
d7f7508 verified
# 🚀 Deploy to HuggingFace Spaces - Quick Guide
## ✅ Your App is Ready!
This application is **fully configured** for HuggingFace Spaces deployment. No additional setup needed!
## 📦 What You Need to Upload
### Required Files
```
✓ app.py (HF Spaces entry point)
✓ requirements.txt (Python dependencies)
✓ src/ (Complete source code)
└── writing_studio/
├── core/
├── services/
└── utils/
```
### Recommended Files
```
✓ .space_config.yml (HF configuration)
✓ README_HF_SPACES.md (Rename to README.md in your Space)
```
## 🎯 Deploy in 3 Steps
### 1️⃣ Create Space
Visit: https://huggingface.co/new-space
- Name your Space
- Choose SDK: **Gradio**
- Select: Public or Private
- Click "Create Space"
### 2️⃣ Upload Files
Drag and drop or use Git:
- `app.py`
- `requirements.txt`
- `src/` folder (keep structure!)
- `.space_config.yml`
- Rename `README_HF_SPACES.md``README.md`
### 3️⃣ Wait & Test
- Build takes ~5 minutes
- App will be live at: `https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE`
- Test with sample text!
## 🎨 Features Included
**Real Rubric Scoring** - Clarity, Conciseness, Organization, Evidence, Grammar
**5 Prompt Packs** - General, Literature, Tech Comm, Academic, Creative
**Visual Diff** - Highlighted changes between drafts
**Smart Caching** - Fast repeated analyses
**Error Handling** - User-friendly error messages
**Production Ready** - Validation, logging, metrics
## ⚙️ Configuration
### Default Settings (Perfect for Free Tier)
- Model: `distilgpt2` (fast & lightweight)
- Metrics: Disabled (not needed on HF Spaces)
- Logging: Text format (easy to read)
- Caching: Enabled (faster responses)
### Custom Settings (Optional)
Edit `.space_config.yml` or add in Space Settings:
```yaml
env:
DEFAULT_MODEL: gpt2 # Use larger model
MAX_TEXT_LENGTH: "5000" # Limit input size
LOG_LEVEL: INFO # Logging detail
```
## 💰 Hardware Tiers
### Free Tier (Recommended to Start)
- Works great with distilgpt2
- First analysis: ~30-60s
- Subsequent: ~5-10s
- Perfect for demos!
### CPU Upgrade ($0.10/hr)
- Better for gpt2
- Faster processing
### T4 GPU ($0.60/hr)
- Best performance
- Large models supported
## 📚 Documentation
- **[HF_SPACES_CHECKLIST.md](HF_SPACES_CHECKLIST.md)** - Deployment checklist
- **[docs/HUGGINGFACE_SPACES.md](docs/HUGGINGFACE_SPACES.md)** - Complete guide
- **[README_HF_SPACES.md](README_HF_SPACES.md)** - User documentation
- **[HF_SPACES_README.txt](HF_SPACES_README.txt)** - Quick reference
## 🧪 Test Locally First
```bash
pip install -r requirements.txt
python app.py
```
Visit http://localhost:7860 and test!
## 🆘 Troubleshooting
**Build fails?**
- Check all `src/` files uploaded
- Verify `requirements.txt` syntax
**Out of memory?**
- Use distilgpt2 (default)
- Upgrade hardware tier
**Slow?**
- First load always slow (model download)
- Use distilgpt2 for speed
- Upgrade hardware
**Full troubleshooting:** See [docs/HUGGINGFACE_SPACES.md](docs/HUGGINGFACE_SPACES.md)
## ⏱️ Timeline
- Setup: 5-10 minutes
- Build: 3-5 minutes
- **Total: ~15 minutes to live app!**
## 🎉 Success Checklist
After deployment, verify:
- [ ] Space builds successfully
- [ ] App loads in browser
- [ ] Text analysis works
- [ ] All 5 prompt packs available
- [ ] Rubric scores display
- [ ] Diff highlighting works
- [ ] Error handling tested
## 🔗 Resources
- [HuggingFace Spaces Docs](https://huggingface.co/docs/hub/spaces)
- [Gradio Documentation](https://gradio.app/docs/)
- [GitHub Repository](https://github.com/yourusername/writing-studio)
---
**Ready to deploy?** Follow the 3 steps above and you'll be live in minutes! 🚀