Skip to content
AI.info

Research

Counterfactual Modeling with Fine-Tuned LLMs for Health Intervention Design and Sensor Data Augmentation

Overview Research area: Explainable AI and machine learning for digital health, specifically counterfactual explanation (CFE) generation with large language models and its use for intervention design

Counterfactual Modeling with Fine-Tuned LLMs for Health Intervention Design and Sensor Data Augmentation
arXiv
2601.14590
Published
2026-01-21
Authors
Shovito Barua Soumma, Asiful Arefeen, Stephanie M. Carpenter, Melanie Hingle, Hassan Ghasemzadeh

AI summary

Overview

Research area: Explainable AI and machine learning for digital health, specifically counterfactual explanation (CFE) generation with large language models and its use for intervention design and data augmentation on sensor-derived clinical data.

Technical level: Advanced. The paper assumes familiarity with counterfactual explanations, LLM fine-tuning (LoRA, quantization), tabular classification metrics, and imbalanced-data evaluation.

Scope: A systematic evaluation of three LLM families in pretrained, prompted, and fine-tuned configurations for generating counterfactuals on the multimodal AI-READI dataset, benchmarked against three optimization-based counterfactual baselines across intervention quality, feature diversity, and augmentation effectiveness.

What This Paper Is About

Counterfactual explanations describe the minimal, actionable changes that would flip a model's prediction, but traditional optimization-based methods often need access to model internals and produce changes to features people cannot realistically alter. This paper asks whether fine-tuned large language models can generate counterfactuals for structured, sensor-derived health data that are both clinically plausible and realistically actionable, and whether those same counterfactuals can be reused as synthetic training data when labels are scarce. The authors compare GPT-4 (zero-shot and few-shot) against BioMistral-7B and LLaMA-3.1-8B (zero-shot and fine-tuned) on the AI-READI clinical dataset, evaluating them as interventions, as diverse feature modifiers, and as augmenters under three controlled label-scarcity scenarios.

Key Contributions

  1. A systematic comparison of GPT-4o with two open-source LLMs (BioMistral-7B and LLaMA-3.1-8B) in both pretrained and fine-tuned configurations, assessed along three dimensions: actionable intervention quality, feature diversity and realism, and data augmentation effectiveness under label scarcity.

  2. A benchmark of LLM-generated counterfactuals against state-of-the-art optimization-based baselines (DiCE, CFNOW, and NICE) on validity, distance, sparsity, and plausibility.

  3. What the authors describe as the first systematic evaluation of fine-tuned LLM-generated counterfactuals as structured augmentation samples for improving robustness under label scarcity in sensor-derived health datasets, while also assessing their utility for intervention-oriented explanation.

  4. Extension of the authors' earlier work, SenseCF, which focused primarily on GPT-4o prompting, by incorporating a broader suite of open-source LLMs and a more comprehensive counterfactual assessment.

Main Findings

  • Fine-tuning drives counterfactual quality. Fine-tuned LLaMA-3.1-8B and BioMistral-7B substantially improve validity, sparsity, and distance relative to their pretrained versions, with gains of 20–40 percentage points in validity and reductions of more than 50% in feature distance.

  • Best reported counterfactual metrics. Fine-tuned LLaMA produced counterfactuals with high plausibility (up to 99%), strong validity (up to 0.99), and realistic, behaviorally modifiable feature adjustments. In Table III, fine-tuned LLaMA reaches validity 0.99 (Class 0) and 0.98 (Class 1), distance 0.41 and 0.2, sparsity 1.8 and 1.9, and plausibility 99 and 99.

  • Baselines trade plausibility for actionability. DiCE, CFNOW, and NICE achieve strong plausibility (DiCE 100 and 99; CFNOW 100 and 99; NICE 33 and 35) and sometimes lower distance, but often propose unrealistic or non-actionable feature shifts such as changes to sleep architecture.

  • Augmentation restores lost performance. Under controlled label scarcity, LLM-generated counterfactuals yielded an average 20% F1 recovery across three scarcity scenarios; the Discussion reports that fine-tuned LLaMA achieves an average 19.9% F1 recovery across the three scarcity conditions when 50% of labels are removed.

  • Scenario A (positive-class undersampling, Class 1 reduced by 50%). The reduced-data neural network lost 12.87% ACC, 11.76% PRE, 16.18% REC, 14.71% F1, and 14.10% AUC. Fine-tuned LLaMA recovered 21.00% ACC, 20.00% PRE, 24.56% REC, 22.41% F1, and 25.37% AUC.

  • Scenario B (negative-class undersampling, Class 0 reduced by 50%). The reduced-data model lost 10.72% ACC, 8.82% PRE, 10.29% REC, 10.29% F1, and 12.82% AUC. Fine-tuned LLaMA recovered 17.16% ACC, 16.13% PRE, 16.39% REC, 16.39% F1, and 23.53% AUC.

  • Scenario C (dual-class undersampling, both classes reduced by 50%). The reduced-data model lost 11.14% ACC, 10.29% PRE, 13.24% REC, 11.76% F1, and 14.10% AUC. Fine-tuned LLaMA recovered 21.47% ACC, 19.67% PRE, 22.03% REC, 20.00% F1, and 26.87% AUC.

  • Scenario difficulty varies. Positive-class scarcity (Scenario A) and dual-class scarcity (Scenario C) benefit more strongly from counterfactual augmentation than negative-class scarcity (Scenario B), consistent with greater model sensitivity to missing minority-class examples.

  • Zero-shot LLMs help but plateau earlier. Zero-shot LLMs still provide measurable improvement over the undersampled baseline, but their gains plateau earlier, suggesting limited ability to mimic the true class manifold without task-specific adaptation.

  • Feature diversity favors modifiable variables. Fine-tuned BioMistral and LLaMA concentrate counterfactuals on highly actionable variables—average steps, glucose levels (Average CGM, TIR%), and hyperglycemia frequency—whereas DiCE and CFNOW propose larger shifts in sleep-stage percentages and total sleep duration, and NICE alters features like REM or deep sleep that individuals cannot directly control in the short term.

  • Augmentation ratio effects. Performance improves steadily as more counterfactuals are injected, with clear monotonic gains for fine-tuned LLaMA-3.1-8B and BioMistral-7B, which reach the highest F1 scores at large augmentation ratios. Gains begin to plateau beyond approximately 60–80% augmentation.

  • Model-agnostic behavior. Counterfactual augmentation improved F1 consistently across Neural Network (NN), Random Forest (RF), Support Vector Machine (SVC), and XGBoost (XGB) in all three scarcity scenarios. Full-dataset F1 was 0.68 (NN), 0.69 (RF), 0.64 (SVC), and 0.69 (XGB); Scene A reached 0.83 (0.58 non-augmented), 0.80 (0.60), 0.79 (0.60), and 0.82 (0.62) respectively. The variation across classifiers remained minimal.

  • Prompt sensitivity is limited. Across two alternative prompt formulations (minimality-focused and actionability-focused) applied to fine-tuned LLaMA-3.1-8B in all three scarcity scenarios, F1 scores remained stable, with observed variance σ ≤ 0.08. The authors conclude effectiveness is driven primarily by LLM capability and fine-tuning rather than prompt design.

  • Latent-space alignment after fine-tuning. Using a randomly selected subset of 200 factual samples, the zero-shot model generated diffused and often misaligned counterfactuals, while the fine-tuned model produced counterfactuals that cluster tightly within the appropriate class region and maintain local structural coherence, with less class overlap in the augmented dataset.

  • Illustrative intervention. For an 81-year-old patient labeled "stressed" with low deep sleep (30.1%), moderate REM (15.4%), high blood glucose (210.8 mg/dL), limited activity (5.95 steps), stress level 85.25, and poor glucose control (TIR 12.5%, 1 hyper event), the LLM suggested increasing deep sleep to 35%, increasing REM sleep to 20%, and lowering blood glucose from 210.8 to 180 mg/dL.

Methodology in Plain English

The authors built a pipeline that turns raw sensor and clinical records into structured tabular rows, asks an LLM to rewrite a row so that a trained classifier flips its prediction, and then validates and reuses those rewritten rows.

  • Data: The publicly available AI-READI Flagship Dataset covers 1,067 participants recruited across three U.S. locations (University of Alabama at Birmingham, University of California San Diego, University of Washington), supporting research in Type 2 Diabetes Mellitus. Participants fall into four categories: healthy controls, individuals with prediabetes, individuals with T2DM treated with oral agents, and individuals with T2DM using insulin. Monitoring lasted a ten-day period using a Dexcom G6 continuous glucose monitor, a Garmin Vivosmart 5 for activity and heart-rate-variability-derived stress indices, and an Anura environmental sensor, plus surveys, clinical examinations, and retinal images. Daily step counts came from an accelerometer, with occasional missing values due to device charging.

  • Preprocessing: The train–test split was done at the patient level (80% of patients to training, 20% to test) to avoid data leakage. A two-hour sliding window with 50% overlap was applied to continuous signals. Per night, Awake, Light Sleep, Deep Sleep, and REM Sleep percentages were computed; from windows, mean step counts, mean glucose level, number of hyperglycemic events, and percentage of time-in-range (%TIR) were extracted. The target label was set using high (mean daily stress > 75) and moderate stress (mean daily stress ≤ 75) thresholds. In total 12 features were used, including 4 immutable features: Age, Gender, Medication, and Patient Subgroup.

  • Counterfactual generation: Given feature vector x_i and prediction y-hat_i, each LLM generated a modified vector x'_i such that f(x'_i) ≠ f(x_i). Prompts explicitly constrained the LLM to minimally alter feature values and forbade changes to immutable or clinically fixed features (such as age, sex, or medication type). A predefined output format using <new> tags and a rule-based parser extracted modified feature–value pairs and mapped them back onto the original vector. Values were validated to lie within the empirical data distribution. Three LLM families were used in four generative modes: GPT-4o with zero-shot and few-shot prompting; BioMistral-7B with zero-shot and fine-tuning; and LLaMA-3.1-8B with zero-shot and fine-tuning.

  • Fine-tuning setup: Experiments ran on a single NVIDIA A100 GPU (40 GB). Llama-3.1-8B-Instruct and BioMistral-7B were fine-tuned with parameter-efficient LoRA rather than full-model training to reduce cost and prevent catastrophic forgetting of medical knowledge. Configuration: LoRA rank 16, LoRA alpha 32, LoRA dropout 0.03, 2 epochs, batch size 4 (effective 16 with gradient accumulation of 4), learning rate 2e-4, max sequence length 512 tokens, FP16 precision, evaluation every 50 steps, checkpointing every 100 steps. 4-bit NF4 quantization (BitsAndBytes) was applied only to Llama-3.1-8B to reduce memory footprint, enable larger effective batch sizes, and avoid out-of-memory errors while preserving quality and stable optimization under LoRA.

  • Baselines: DiCE (diverse counterfactuals optimizing proximity and feasibility), CFNOW (model-agnostic two-step search for valid, minimal counterfactuals), and NICE (iteratively replacing feature values with those from the nearest instance having a different prediction).

  • Metrics: Validity (whether counterfactuals genuinely belong to the desired class), distance (L2 normalized distance of continuous features plus Hamming distance of categorical features), sparsity (average number of feature changes per counterfactual), and plausibility (fraction of explanations falling within feature ranges derived from the data).

  • Augmentation protocol: Counterfactuals that successfully altered the model prediction were added to the training set. Three undersampling scenarios each removed 50% of samples from the targeted class: Positive-Class Scarcity, Negative-Class Scarcity, and Dual-Class Scarcity. Only counterfactuals corresponding to the undersampled class were added. Augmentation ratio was varied from 20% to 100%.

Why This Matters

Impact on research. The paper positions LLM-generated counterfactuals as a model-agnostic alternative to optimization-based methods that require model gradients or internal structure. It also extends counterfactual explanations beyond interpretability into a data-efficiency role, showing that label-flipping synthetic samples can recover classifier performance lost to undersampling. The authors note that, because the framework does not depend on model internals, new LLMs can be incorporated in a plug-and-play manner.

Real-world applications:

  • Personalized health guidance: suggesting small, clinically plausible adjustments grounded in sensor-derived physiology (for example, increasing deep sleep, lowering blood glucose, increasing step counts) to identify early behavioral or metabolic interventions for at-risk individuals.
  • Scalable data augmentation in clinical machine learning where labeled sensor data are expensive or scarce, as an alternative to collecting more data.
  • Decision support for stress and metabolic monitoring programs built on wearables such as continuous glucose monitors and activity trackers.
  • Interpretability reporting for deployed health prediction models, giving instance-level explanations linking predictions to modifiable features.

Industry relevance. Digital health and wearable-sensor companies, clinical decision-support developers, and payers or providers running remote-monitoring programs could use the approach to make predictive models more robust and their outputs more actionable without requiring access to proprietary model internals. The demonstrated model-agnostic generalization across NN, RF, SVC, and XGBoost supports deployment across heterogeneous modeling stacks.

Future Directions

  • Integrating LLMs directly into the machine learning training loop for iterative, counterfactual-guided model updates ("LLM-in-the-loop learning").
  • Incorporating clinical knowledge graphs or causal structures into the fine-tuning pipeline to reduce unrealistic or physiologically implausible feature changes.
  • Adding physician-in-the-loop evaluation and expert validation to assess clinical utility, safety, and interpretability of generated counterfactual interventions, and to address personalized feasibility constraints.
  • Extending beyond structured tabular features to multimodal LLMs that generate counterfactuals from raw sensor traces, free-text clinical notes, or imaging.
  • Evaluating the longer-term impact of counterfactual-based guidance on early intervention and patient outcomes in real-world digital health ecosystems, and pursuing fairness-aware classifier training with bias-sensitive counterfactual evaluation.

Target Audience

Researchers and practitioners in explainable AI, digital health, and wearable-sensor analytics; machine learning engineers working on imbalanced clinical datasets; LLM fine-tuning practitioners interested in structured tabular domains; and clinical informatics teams evaluating whether model explanations translate into actionable patient-level interventions. Readers with a background in counterfactual explanation metrics and parameter-efficient fine-tuning will get the most from the quantitative comparisons, though the paper states its clinical implications in accessible terms.

Reported limitations: Fine-tuned LLMs do not outperform all state-of-the-art counterfactual baselines across every metric, particularly in distance or sparsity for certain classes; some counterfactuals may still exceed clinically achievable ranges; fine-tuning requires labeled data that may be scarce for some conditions; bias or error in the underlying classifier may propagate to the generated counterfactuals; and the work is limited to structured tabular features without multimodal raw sensor streams or clinical text.

Funding reported: NSF Grant IIS-2402650, and A. Arefeen was supported in part by the NIDDK of the NIH under Award T32DK137525.

Authors’ abstract

Counterfactual explanations (CFEs) provide human-centric interpretability by identifying the minimal, actionable changes required to alter a machine learning model's prediction. Therefore, CFs can be used as (i) interventions for abnormality prevention and (ii) augmented data for training robust models. We conduct a comprehensive evaluation of CF generation using large language models (LLMs), including GPT-4 (zero-shot and few-shot) and two open-source models-BioMistral-7B and LLaMA-3.1-8B, in both pretrained and fine-tuned configurations. Using the multimodal AI-READI clinical dataset, we assess CFs across three dimensions: intervention quality, feature diversity, and augmentation effectiveness. Fine-tuned LLMs, particularly LLaMA-3.1-8B, produce CFs with high plausibility (up to 99%), strong validity (up to 0.99), and realistic, behaviorally modifiable feature adjustments. When used for data augmentation under controlled label-scarcity settings, LLM-generated CFs substantially restore classifier performance, yielding an average 20% F1 recovery across three scarcity scenarios. Compared with optimization-based baselines such as DiCE, CFNOW, and NICE, LLMs offer a flexible, model-agnostic approach that generates more clinically actionable and semantically coherent counterfactuals. Overall, this work demonstrates the promise of LLM-driven counterfactuals for both interpretable intervention design and data-efficient model training in sensor-based digital health. Impact: SenseCF fine-tunes an LLM to generate valid, representative counterfactual explanations and supplement minority class in an imbalanced dataset for improving model training and boosting model robustness and predictive performance

Read the original paper