Download DEPLOYMENT.md from PranilB/Question_Answering_Classification: direct link, hf CLI and curl.
- Browser
- Download file 4.09 kB
-
https://huggingface.co/spaces/PranilB/Question_Answering_Classification/resolve/main/DEPLOYMENT.md
- Command line
-
hf download hf://spaces/PranilB/Question_Answering_Classification/DEPLOYMENT.md
-
curl -L -o DEPLOYMENT.md https://huggingface.co/spaces/PranilB/Question_Answering_Classification/resolve/main/DEPLOYMENT.md
π Deployment Guide β Railway (Backend) + Vercel (Frontend)
β οΈ Key Constraint: BERT Model Size
The trained BERT model is 418 MB (model.safetensors).
GitHub blocks files >100MB. We use Git LFS to handle this.
PART 1: Setup Git LFS + Push to GitHub
Step 1 β Install Git LFS
Download and install: https://git-lfs.com
Then in your terminal:
git lfs install
Step 2 β Track large model file
cd "d:\Users\Pranil\Github Repos\Question_AndAnswerGeneration"
git lfs track "Classification/checkpoints/best_model/model.safetensors"
git add .gitattributes
Step 3 β Stage and commit everything
git add .
git commit -m "Add deployment files + BERT model via LFS"
git push origin main
β³ This will take a few minutes β the 418MB file uploads via LFS.
PART 2: Deploy Backend to Railway
Step 4 β Create Railway account
Go to: https://railway.app
Sign up with GitHub account (easiest β auto-imports repos)
Step 5 β Create new project
- Click "New Project"
- Choose "Deploy from GitHub repo"
- Select your
Question_AndAnswerGenerationrepo - Railway auto-detects Python β click "Deploy"
Step 6 β Set environment variables
In your Railway project β Variables tab β add these:
| Variable | Value |
|---|---|
SUPABASE_URL |
https://your-project.supabase.co |
SUPABASE_KEY |
your-supabase-anon-key |
GROQ_API_KEY |
your-groq-api-key |
GROQ_MODEL |
llama-3.3-70b-versatile |
EMBEDDING_MODEL |
BAAI/bge-small-en-v1.5 |
Step 7 β Get your backend URL
After deployment completes (3β8 mins):
Go to Settings β Domains β Copy your URL
It looks like: https://question-andanswer-production.up.railway.app
Step 8 β Verify backend is live
Open in browser:
https://YOUR-RAILWAY-URL.up.railway.app/health
https://YOUR-RAILWAY-URL.up.railway.app/docs
PART 3: Update Frontend with Backend URL
Step 9 β Update API_BASE in app.js
Open Frontend/app.js and change line 14:
// Before (local):
const API_BASE = "http://localhost:8000";
// After (production):
const API_BASE = "https://YOUR-RAILWAY-URL.up.railway.app";
Step 10 β Commit the frontend update
git add Frontend/app.js
git commit -m "Update API_BASE to Railway URL"
git push origin main
PART 4: Deploy Frontend to Vercel
Step 11 β Create Vercel account
Go to: https://vercel.com
Sign up with GitHub account
Step 12 β Import project
- Click "New Project"
- Import your
Question_AndAnswerGenerationrepo - In "Configure Project":
- Root Directory:
Frontend - Framework Preset:
Other(it's vanilla HTML) - Leave everything else default
- Root Directory:
- Click "Deploy"
Step 13 β Get your frontend URL
Vercel gives you: https://question-andanswer.vercel.app
β Final Test
- Open your Vercel URL
- Type a question: "What is the role of cofactors in enzyme activity?"
- Click π¬ Full Analysis
- Should classify β retrieve β answer in ~10 seconds
π§ Troubleshooting
| Problem | Fix |
|---|---|
| Railway deploy fails | Check Deploy Logs in Railway dashboard |
| BERT model not found | Confirm model.safetensors was pushed via Git LFS |
| CORS error in browser | Verify Railway URL in API_BASE has no trailing slash |
| Supabase timeout | Check your Supabase project is not paused (free tier pauses after inactivity) |
| Railway out of memory | Upgrade to Hobby plan ($5/mo) β BERT needs ~1.5GB RAM |
π° Cost Summary
| Service | Free Tier | Paid |
|---|---|---|
| Railway | 500MB RAM, limited hours | $5/mo Hobby |
| Vercel | Unlimited static hosting | Free |
| Supabase | 500MB DB, 2GB bandwidth | $25/mo Pro |
| Groq | Free tier (limited RPM) | Pay-per-use |
| Git LFS | 1GB free | $5/mo per 50GB |
π‘ For a student project / demo: everything fits in free tiers.
Railway free tier may sleep after inactivity (cold start ~30s on first request).