Inspiration

Most patients leave clinical appointments confused about their own lab results. Numbers like "eGFR 42 mL/min" or "HbA1c 8.2%" mean nothing without context. We wanted to bridge the gap between clinical data and patient understanding — not just explaining results, but triggering real actions automatically.

What it does

MedAgent takes any medical lab report PDF and runs it through a five-module NLP pipeline: extracts text via PyMuPDF, identifies drugs and diseases using BioBERT (F1=87%), classifies lab values as Normal/Borderline/Critical, simplifies findings into Grade 7-8 plain language using Groq Llama-3.3-70B, and dispatches real-world actions via an MCP agent including Google Calendar reminders, Gmail summaries, Slack nudges, and drug interaction checks.

How we built it

We fine-tuned BioBERT on BC5CDR for medical entity extraction, built a rule-based lab value parser with custom severity logic for one-sided and two-sided reference ranges, chained four LLM prompts for simplification, and connected Google Calendar, Gmail, and Slack via OAuth 2.0 and webhooks. The backend runs on FastAPI with a dark-themed web frontend deployable from Google Colab via ngrok.

Challenges we ran into

BioBERT subword label alignment required assigning -100 to continuation subwords so they are ignored in loss. One-sided reference ranges like eGFR and LDL needed separate classification logic. HbA1c parsing required a dedicated extractor. We also worked through multiple LLM provider rate limits and had to implement a manual OAuth redirect flow for Google authentication in Colab.

Accomplishments that we're proud of

BioBERT F1 = 87.01% on BC5CDR, beating our 82% target. Lab parser passing 11/11 health check assertions. Text simplification achieves +6.6 Flesch-Kincaid grade improvement on MedQuAD. MCP Agent executing all 4 real-world tools live with Google Calendar, Gmail, and Slack. A fully working web app deployed end-to-end from a Colab notebook.

What we learned

Fine-tuning domain-specific transformers requires careful tokenization and label alignment. Rule-based systems can outperform ML for structured extraction tasks like lab value parsing. Prompt chaining with fixed temperature produces more consistent LLM outputs. Integrating real OAuth and webhooks into an NLP pipeline bridges academic research and practical deployment.

What's next for MedAgent

Scanned PDF support with full OCR, longitudinal analysis across multiple reports to detect health trends, multilingual support for Spanish and Mandarin, clinical validation with healthcare professionals, FHIR EHR integration, and a fine-tuned simplification model trained on MedQuAD.

Built With

Share this project:

Updates