Vish-AI / DEPLOY.md
Vishwas896's picture
train itself
b4fa832 verified
|
Raw
History Blame Contribute Delete
5.55 kB

A newer version of the Gradio SDK is available: 6.24.0

Upgrade

πŸš€ Vish AI - Deployment Guide

πŸ“¦ Essential Files for Hugging Face Spaces

Upload these 3 files only:

  1. app.py (18KB) - Main application with Phi-3 integration
  2. requirements.txt (515 bytes) - All dependencies
  3. README.md (7.1KB) - Space description and info

That's it! Everything else is optional.


🎯 Quick Deploy Steps

1. Create Hugging Face Space

Go to: https://huggingface.co/new-space

Settings:

  • Owner: Your username
  • Space name: vish-ai (or your choice)
  • License: MIT
  • SDK: Gradio
  • Python version: 3.10 or 3.11 ⚠️ (Required)
  • Hardware:
    • CPU Basic (FREE) - Works, but slower (3-6s responses)
    • T4 GPU ($0.60/hr) - Recommended (0.5-2s responses)

2. Upload Files

Option A - Web Upload:

  1. Click "Files" tab in your new Space
  2. Click "Add file" β†’ "Upload files"
  3. Upload: app.py, requirements.txt, README.md
  4. Click "Commit to main"

Option B - Git Clone:

git clone https://huggingface.co/spaces/YOUR_USERNAME/vish-ai
cd vish-ai
cp /path/to/app.py .
cp /path/to/requirements.txt .
cp /path/to/README.md .
git add .
git commit -m "Deploy Vish AI with Phi-3"
git push

3. Wait for Build

⏱️ First build takes 15-20 minutes:

  • Installing dependencies: ~3 min
  • Downloading Phi-3 model (7GB): ~10-15 min
  • Starting app: ~2 min

Watch the logs (click "Logs" tab) for:

πŸ“₯ Loading Phi-3 Mini unified model...
   Model: microsoft/Phi-3-mini-4k-instruct
   This may take 5-15 minutes on first run (downloading ~7GB)...
   Loading tokenizer...
   βœ… Tokenizer loaded
   Loading model (this is the slow part)...
βœ… Phi-3 Mini model loaded successfully!
πŸŽ‰ Unified model ready for all tasks!
   Model parameters: 3,821,079,552

βœ… All systems ready!

Running on local URL:  http://0.0.0.0:7860

4. Test Your Space

Once live, test all 3 features:

Chat:

  • Input: "What is artificial intelligence?"
  • Expected: Intelligent multi-paragraph response

Summarize:

  • Input: Paste 100+ word article
  • Expected: 2-3 sentence summary

Sentiment:

  • Input: "I absolutely love this product!"
  • Expected: "😊 POSITIVE"

πŸ” Optional: Add Supabase Authentication

If you want user authentication and logging:

  1. Go to Space Settings β†’ "Variables and secrets"
  2. Add these secrets:
    NEXT_PUBLIC_SUPABASE_URL = https://lyebtceryednzafhyunq.supabase.co
    NEXT_PUBLIC_SUPABASE_ANON_KEY = your_anon_key_here
    
  3. Restart Space

Without Supabase: App works perfectly, just no user logging.


πŸ“Š Performance Expectations

Hardware Chat Summarize Sentiment
CPU Basic (FREE) 3-6s 4-8s 2-4s
T4 GPU Small 0.5-1.5s 1-2s 0.3-0.8s
A10G GPU 0.2-0.6s 0.5-1s 0.2-0.5s

πŸ”§ Troubleshooting

❌ Build fails with "Out of Memory"

Fix: Model is optimized for CPU. If still failing:

  • Upgrade to T4 GPU (has more memory)
  • Check logs for specific error

❌ "AI models not available" in app

Fix:

  • Wait for build to complete (full 20 minutes)
  • Check logs for download progress
  • Ensure Python 3.10 or 3.11 (not 3.12+)

❌ Slow responses (>10 seconds)

Fix:

  • Normal on CPU Basic (AI is compute-intensive)
  • Upgrade to T4 GPU for 5-10x speedup
  • First response is slower (model warmup)

❌ Model not downloading

Fix:

  • Check build logs for errors
  • Ensure internet access (Spaces have it)
  • Wait full 20 minutes before retrying

πŸ“ Optional Files Explained

test_phi3_model.py (8.3KB)

Test the model locally before deploying:

pip install -r requirements.txt
python test_phi3_model.py

fine_tune_phi3.py (6.8KB)

Fine-tune Phi-3 on your custom data (advanced):

python fine_tune_phi3.py

supabase_setup.sql (6KB)

SQL schema for Supabase database tables (if using auth).


βœ… Success Checklist

  • Space created on Hugging Face
  • Python version is 3.10 or 3.11
  • Files uploaded: app.py, requirements.txt, README.md
  • Build completed without errors
  • Logs show: "βœ… Phi-3 Mini model loaded successfully!"
  • Chat responds intelligently
  • Summarizer condenses text
  • Sentiment analyzer detects emotions
  • Response times acceptable for your use case

🌐 Your Live Space

After deployment, share your app:

https://huggingface.co/spaces/YOUR_USERNAME/vish-ai

Example:

https://huggingface.co/spaces/vishwas896/vish-ai

πŸ’‘ Pro Tips

  1. Start with CPU Basic (free) for testing
  2. Monitor usage - upgrade to GPU only if needed
  3. First response is slower (model warmup) - this is normal
  4. Check logs regularly during first build
  5. Test all features before sharing publicly
  6. GPU pricing: Only charged when Space is running
  7. Pause Space when not in use to save costs (GPU only)

οΏ½ Need Help?


πŸŽ‰ What You've Built

✨ Powerful AI assistant with:

  • Microsoft Phi-3 Mini (3.8 billion parameters)
  • Chat, Summarization, and Sentiment Analysis
  • Clean, production-ready code
  • Deployed on Hugging Face's infrastructure
  • Optional user authentication with Supabase

Total setup: Just 3 files, ~25KB. That's it!


Built with ❀️ by Vishwas | Powered by Microsoft Phi-3 & Hugging Face