> [!NOTE]
> **Disclaimer:** MedGemma is an open model subject to the [HAI-DEF Terms of Use](https://developers.google.com/health-ai-developer-foundations/terms). Nimblemind owns and controls the software development and manufacturing of nMAS.

![Nimblemind Pain Spike Prediction](https://developers.google.com/static/health-ai-developer-foundations/showcase/images/nimblemind/nimblemind-hero-upscaled.png)

In the United States, over
[two million individuals are diagnosed with opioid use disorder](https://www.nhlbi.nih.gov/news/2019/nih-heal-initiative-science-taking-pain-opioid-misuse-and-poor-sleep),
a condition that frequently co-occurs with chronic pain. Patients receiving
medication for opioid use disorder have a much higher chronic pain
prevalence (1.8-3 times higher than the general population) and often experience
significant pain spikes that can increase the risk of relapse, treatment
disengagement, and overdose. However, these changes are difficult to observe
during periodic clinical visits, leaving providers with limited visibility into
a patient's status between appointments. While wearable devices and assessments
now capture continuous signals related to sleep, activity, and stress, the core
challenge lies in interpreting this heterogeneous longitudinal data in a
clinically meaningful way relative to each patient's unique baseline.

To help bridge this gap, [Nimblemind](https://www.nimblemind.ai/about-us)
fine-tuned several LLMs, including
[**MedGemma**](https://developers.google.com/health-ai-developer-foundations/medgemma) and used
within the Nimblemind multi-agent system (nMAS) to support the longitudinal
monitoring of chronic pain dynamics. The nMAS coordinates multiple specialized
agents to ingest and structure multimodal data from three primary sources:

- **Electronic Medical Records (EMR):** Clinical history, medication changes, and prior diagnoses.
- **Patient Surveys:** Regular ecological momentary assessments (EMA) capturing subjective pain scores and cravings.
- **Wearable Devices:** Passive continuous data streams including heart rate variability (HRV), sleep staging, and physical activity metrics.

![nMAS Architecture Flowchart](https://developers.google.com/static/health-ai-developer-foundations/showcase/images/nimblemind/nimblemind-architecture-upscaled.jpg)

Compared with general-purpose LLMs that often produced descriptive summaries,
developing the system with healthcare-specific models like MedGemma, along with
speciality level fine-tuning, resulted in more consistent reasoning anchored to
patient-specific baselines and clinically defined thresholds. While these
behaviors of healthcare-specific models did not eliminate errors, they made
outputs more directly interpretable within a rule-based clinical workflow. For
example, when patients exhibited sustained high evening pain combined with poor
sleep and reduced activity, MedGemma generated explicit predictions of elevated
next-day spike risk and surfaced the underlying behavioral and physiological
drivers. In contrast, when pain levels were elevated but consistent with prior
baseline patterns, the model differentiated persistence from true spike events.
These results demonstrate that MedGemma's value lies not only in generating
fluent summaries, but in producing structured, baseline-aware reasoning that
integrates directly into reproducible, leakage-aware pipelines.

| **Model** | **Accuracy** | **Precision** | **Recall** | **F1 Score** |
|---|---|---|---|---|
| **Fine-tuned MedGemma 1.5** | 0.73 | 0.70 | 0.68 | 0.69 |
| **Qwen3-7B** | 0.64 | 0.61 | 0.60 | 0.60 |
| **Gemini 3-Pro** | 0.57 | 0.55 | 0.53 | 0.54 |
| **Claude-Opus 4.5** | 0.50 | 0.48 | 0.46 | 0.47 |

*Table 1. Comparative model performance on pain spike prediction.*

A [pilot study](https://arxiv.org/html/2511.19577v2) at the
[APT Foundation](https://aptfoundation.org/), a substance use treatment provider
in Connecticut, collected multimodal data from patients derived from wearable
sensors and clinical assessments. Nimblemind's proprietary AI system achieved
relatively high accuracy (\>0.7) in predicting future pain spikes, which are
fairly common in this demographic, up to five days in advance. By integrating
wearable monitoring with MedGemma-driven interpretation, raw multimodal data can
be converted into a reliable signal that can enable the care team to take action
sooner and personalize treatment adjustments to reduce relapse risk.

"By organizing and curating data from our EMR, patient surveys, and
wearable devices, they \[Nimblemind\] are helping us identify patient
interventions more effectively. This kind of AI-driven insight is the
future of personalized, proactive care."


--- **Lynn M. Madden, PhD** , CEO of
*APT Foundation*

Building on these results, Nimblemind plans to expand the role of generative AI
to support care teams with structured, patient-specific next-step
recommendations within nMAS. These outputs will serve as a clinically
grounded co-pilot, preparing actionable options for review by clinicians to
ensure proactive, personalized care pathways.