Hey DEV community π
I recently built and deployed a full-stack AI system that predicts medical specialties from clinical text using ClinicalBERT, and I wanted to share the full journey from training to deployment. This is part of my project under GradienNinja / Astrolabsoft.
Link https://astrolab-medical-ai.netlify.app/
π What I Built
I built an AI system that:
- Takes clinical notes as input
- Predicts the most likely medical specialty
- Returns top 3 predictions with confidence scores
- Runs as a fully deployed web application
Example Input
Patient is a 62-year-old male with chest pain radiating to the left arm, shortness of breath, sweating, and nausea. Symptoms worsen on exertion and improve with rest.
Example Output
Primary: Cardiovascular / Pulmonary
Confidence: 82%
Top 3 Predictions:
- Cardiovascular / Pulmonary
- General Medicine
- SOAP / Clinical Notes
Tech Stack
- Python
- PyTorch
- Hugging Face Transformers
- ClinicalBERT
- FastAPI (backend API)
- HTML / CSS / JavaScript (frontend)
- Netlify (frontend hosting)
- Hugging Face Spaces (model deployment)
System Architecture
Frontend (Netlify UI)
β
POST request (/predict)
β
FastAPI backend (Hugging Face Space)
β
ClinicalBERT model inference
β
JSON response
β
Frontend renders prediction
Why ClinicalBERT?
I used ClinicalBERT because it is pretrained on biomedical and clinical text, which gives it a strong understanding of:
- Medical terminology
- Symptoms and conditions
- Clinical documentation style
This significantly improves prediction quality compared to generic NLP models.
Deployment
- Backend: Hugging Face Spaces (FastAPI)
- Frontend: Netlify (HTML/CSS/JS)
- Fully API-based architecture
The system behaves like a lightweight AI SaaS product.
Challenges I Faced
- Handling class imbalance in medical dataset
- Long clinical notes exceeding token limits
- Low confidence in ambiguous symptom cases
- CORS issues between frontend and backend
- Deployment debugging in Hugging Face Spaces
π What I Learned
This project taught me that:
- Training a model is only 30% of the work
- Deployment is where real engineering begins
- Data quality matters more than model complexity
- API design is critical for real-world AI systems
- End-to-end thinking is required for production AI
π Future Improvements
I plan to upgrade this system into:
- Medical triage assistant (risk level detection)
- Explainable AI (why model made a prediction)
- Multi-label diagnosis support
- Better dataset balancing
- Hospital workflow integration
π¬ Final Thoughts
This project made me realize:
βBuilding AI models is easy. Building usable AI systems is hard.β
This is just the beginning of my journey in building real-world AI products.
If anyone is working on AI + healthcare systems, feel free to connect

Top comments (0)