Digital phenotyping with large language models to detect depressive state changes in patients Authors: Yunhao Yuan, Ya Gao, Hans Moen, Erkki Isometsä, Pekka Marttinen, Talayeh Aledavood Published: 2026 ABSTRACT Digital phenotyping leverages continuous data from smartphones and wearable devices for real-time mental health monitoring, offering opportunities for early detection and personalized care in mood disorders by enabling clinicians to proactively respond to significant changes before symptoms worsen. However, the heterogeneity of such data presents modeling challenges. This study evaluates the potential of large language models (LLMs) to detect changes in depression severity from digital phenotyping data among individuals experiencing major depressive episodes. We compare in-context learning and fine-tuning strategies and find that both few-shot prompted and fine-tuned LLMs outperform traditional baselines. Furthermore, embedding-only and QLoRA fine-tuning yield comparable results, with the former excelling on individual features and the latter performing better on combined inputs. These findings demonstrate the promise of LLMs in integrating heterogeneous behavioral data for mental health analysis, while underscoring the importance of clinical validation and ethical safeguards in real-world applications. Introduction Recent years have seen increasingly rapid advances in large language models (LLMs), including notable examples such as ChatGPT-41, LLaMA-3.12, and Gemma-33. These models are capable of encoding vast amounts of information and demonstrate robust performance across diverse tasks involving complex natural language understanding, reasoning, and generation, such as question answering, summarization, and problem-solving4–7. In the health domain, there is also a growing interest in utilizing LLMs to enhance clinical decision-making, electronic health records analysis, patient communication, medical education, and medical images interpretation and assessments8–14. One promising area where LLMs could extend current health applications is digital phenotyping. Digital phenotyping refers to the quantification of human behaviors, physiological states, and clinical characteristics using data collected passively and continuously from smartphones, wearables, and other connected devices 15–19. By constructing detailed digital trajectories of patients’ behavioral, social, and physiological patterns, this approach offers a dynamic and personalized window into mental and physical health 20. In digital phenotyping, machine learning (ML) approaches are widely used to link behavioral markers from passively collected data with mental health outcomes. Conventional ML models, such as logistic regression, random forests, and gradient boosting, typically rely on engineered features (e.g., mobility patterns, sleep duration, or screen interaction time) to classify whether an individual is at risk of worsening symptoms or to forecast future questionnaire scores21–23. Deep learning has extended these approaches by automatically learning hierarchical and temporal representations from collected data24. For instance, convolutional and recurrent neural networks (CNNs, LSTMs) have been applied to accelerometer traces, GPS trajectories, and multimodal smartphone logs to detect depressive episodes25,26, predict anxiety symptom fluctuations27, or identify schizophrenia-related behavioral markers28,29. Parallel work in audiovisual modalities, such as facial expression and speech analysis30,31, demonstrates effectiveness in controlled settings but requires active participation and specialized equipment. In contrast, digital phenotyping enables passive, low-burden, and continuous monitoring in real-world contexts, making it particularly suitable for longitudinal and large-scale applications. Despite these advances, prior ML and deep learning approaches for digital phenotyping face two persistent limitations. First, most models rely on fixed feature engineering pipelines and task-specific architectures, which restrict their ability to generalize across heterogeneous behavioral signals. Second, multimodal integration is typically handled through handcrafted aggregation or late fusion strategies, requiring substantial labeled data and extensive retraining when features, populations, or sensing configurations change. These constraints are particularly problematic in mental health contexts, where datasets are small, behavioral signals are noisy, and symptom manifestations vary widely across individuals and over time 32,33. LLMs offer a potential alternative to task-specific digital phenotyping models. Pre-trained on large-scale corpora, LLMs can perform new tasks with limited task-specific data through zero- and few-shot in-context learning, where behavior is guided by structured prompts and a small number of examples34. Yet, in specialized domains, in-context learning may underperform, as LLMs may lack exposure to domain-specific concepts35. This can be solved by fine-tuning LLMs to the unique data and decision-making requirements of clinical tasks. While full fine-tuning is computationally costly for billion-parameter models, parameter-efficient fine-tuning (PEFT) methods such as Low-Rank Adaptation (LoRA) or QLoRA enable the adaptation of large models without updating all parameters, significantly reducing computation and memory requirements35–38. Alternatively, embedding-layer fine-tuning focuses only on retraining the feature representation layers, which has shown promise in domains39. Pre-trained embeddings, optimized on broad general-purpose corpora, often fail to capture subtle domain-specific relationships. Adapting the embedding layer can better align representations with specialized terminology and context while remaining computationally efficient40,41. Although LLMs are primarily designed for text, they can be applied to non-text domains when structured data are reformulated as ordered symbolic representations expressed in natural language42. Unlike conventional machine learning/deep learning models, LLMs operate over symbolic sequences using pretrained contextual and relational priors, enabling flexible comparison, abstraction, and example-based reasoning over behavioral trajectories without requiring explicit retraining for each sensing configuration 43. In this work, we reformulate digital phenotyping time-series as structured symbolic sequences expressed in natural language, where sensor traces are represented as ordered values augmented with temporal context and statistical summaries. This transformation enables LLMs to operate on behavioral trajectories in a manner analogous to how they reason over token sequences, allowing sequence comparison and contextual abstraction rather than direct numerical prediction. We address the following research question: Can large language models accurately detect changes in depression severity using digital phenotyping data? Importantly, our goal is to examine whether LLMs can meaningfully integrate heterogeneous behavioral signals and identify patterns when modeling complex behavioral trajectories derived from passive sensing data. From a translational perspective, passive sensing models are not used as standalone diagnostic systems in current clinical practice. Instead, they are typically investigated as screening or monitoring components that may help highlight behavioral changes warranting further clinical attention. Any potential clinical use would require substantially higher predictive reliability, validation in larger and more diverse populations, and integration within clinician-supervised workflows. Our experiments, therefore, focus on evaluating the methodological feasibility of applying LLMs to digital phenotyping data and comparing their performance with conventional machine learning baselines under realistic data constraints. We evaluate the ability of open-source LLMs, including Llama 3.1-Instruct-8B44, Mistral-7B-Instruct-v0.345, Qwen3-8B46, Gemma-3-4B-IT3, to automatically detect changes in depressive states from digital phenotyping data. We use a digital phenotyping dataset20,47,48 collected via smartphone applications from patients with major depressive episodes and healthy controls recruited from multiple clinics across Finland. The initial depression severity of a participant is determined based on the Patient Health Questionnaire (PHQ-9)49, which asks about their state over the past two weeks. The task of the LLMs is then to detect whether a participant’s depressive state changes from one two-week period to the subsequent two-week period using passively collected digital phenotyping data. We explore and systematically evaluate multiple open-source LLMs under various prompting settings and fine-tuning techniques to analyze the LLMs’ capabilities in digital phenotyping research. We also compare with conventional classification models, including XGBoost, Random Forest, LSTM, CNN-LSTM, and XGBoost, which have demonstrated strong performance in prior digital phenotyping studies20,28–31. Results Study cohort and study design We analyze data from the Mobile Monitoring of Mood (MoMo-Mood) study20, a 1-year digital phenotyping study of 133 participants who have a diagnosis of either major depressive disorder (MDD) (mean age: 39.0, SD: 14.2), major depressive episodes (MDE) with bipolar disorder (BD) (mean age: 37.1, SD: 10.3), or MDD with borderline personality disorder (BPD) (mean age: 28.3, SD: 6.0) and 31 healthy controls (mean age: 41.8, SD: 13.9). The depressive symptoms may differ across these diagnoses, as in MDD symptoms are often intrinsic and linked to biological factors, whereas in BPD depressive episodes are more often reactive to interpersonal conflicts50,51. Importantly, these are matters of degree rather than kind, and the etiology of depressive symptoms is multifactorial across all subgroups. The focus of our analysis, however, is not on disorder-specific mechanisms but on symptom-level changes in depression severity as measured by PHQ-9. Pooling across diagnostic groups allows us to maximize statistical power in our relatively small dataset, while also mirroring real-world digital phenotyping deployments where mixed clinical populations are the norm. We note, however, that different diagnostic groups may exhibit distinct baseline behavioral patterns (e.g., activity levels or phone usage habits), which could act as a potential confound. To mitigate this risk, our analysis focuses on within-individual changes across consecutive time windows rather than absolute behavioral levels, thereby reducing sensitivity to stable between-group differences. We therefore interpret our findings as reflecting generalizable patterns of behavioral signals associated with depressive symptom fluctuations, rather than mechanisms specific to MDD, BP, or BPD. The specific task requires the LLMs to detect future depressive state changes (increase, decrease, or stable) based on smartphone-derived digital phenotyping data basic with health context, and/or statistical summary. Participants’ mobile sensor data (including battery level, screen usage, acceleration magnitude, and screen-off durations) are collected continuously and paired with biweekly PHQ-9 assessments49, a 9-item clinical questionnaire that evaluates the severity of depressive symptoms, with higher scores indicating more severe depression (Fig. 1). These passively collected behavioral signals can be used as proxies for mental health indicators, such as social withdrawal, disrupted sleep, or reduced mobility, which are associated with depressive episodes20,23,32. We reformulate the detection of depressive state changes as a natural language task, enabling the application of LLMs to this digital phenotyping dataset.Fig. 1The overview of the complete study pipeline, including longitudinal data collection, label construction, and the learning and adaptation strategies used for large language models.a The upper panel illustrates data collection from subjects from the active phase to the passive phase, where daily phenotypic data (D1, D2, etc.) and bi-weekly depression levels (PHQ-9 scores) are recorded during passive phase. b The lower panel depicts the data labeling process: ground truth labels are assigned based on the difference in PHQ-9 scores between two consecutive two-week periods. These labels indicate whether an individual’s depression severity remains stable, increases, or decreases across the compared periods. c Overview of learning and adaptation strategies for LLMs evaluated in this study. From left to right: in-context learning (all weights frozen), embedding fine-tuning (only embeddings optimized with FP16 precision), and QLoRA fine-tuning, where the base model is quantized to NF4 (4-bit NormalFloat) and kept frozen while small adapter layers are trained. Black nodes indicate frozen weights; dotted nodes indicate optimized weights. The overview of the complete study pipeline, including longitudinal data collection, label construction, and the learning and adaptation strategies used for large language models. a The upper panel illustrates data collection from subjects from the active phase to the passive phase, where daily phenotypic data (D1, D2, etc.) and bi-weekly depression levels (PHQ-9 scores) are recorded during passive phase. b The lower panel depicts the data labeling process: ground truth labels are assigned based on the difference in PHQ-9 scores between two consecutive two-week periods. These labels indicate whether an individual’s depression severity remains stable, increases, or decreases across the compared periods. c Overview of learning and adaptation strategies for LLMs evaluated in this study. From left to right: in-context learning (all weights frozen), embedding fine-tuning (only embeddings optimized with FP16 precision), and QLoRA fine-tuning, where the base model is quantized to NF4 (4-bit NormalFloat) and kept frozen while small adapter layers are trained. Black nodes indicate frozen weights; dotted nodes indicate optimized weights. We use four pre-trained LLMs (Gemma-3-4B, Llama-3.1-8B, Mistral-7B, and Qwen-3-8B) with two strategies: few-shot in-context learning and supervised fine-tuning. To evaluate model performance under diverse conditions, we explore various configurations resulting from combinations of modeling strategy, input features, prompt formats, and training setup. Specifically, we test 15 digital phenotyping feature combinations (battery usage, screen-off duration, screen-use duration, and acceleration magnitude) under four redesigned prompt formats: Basic, Health Context, Statistics, and All formats. The Basic format presents only past and current 2-week sensor sequences; Health Context adds background information about PHQ-9; Statistics provides statistical summaries of the historical sequences; and All combines all contextual elements. We restrict our analysis to four behavioral features because these have been consistently identified as reliable and interpretable digital biomarkers in prior digital phenotyping research20,52–54. While richer feature sets (such as app usages or communication frequency) could provide additional predictive power, our study aims to isolate the contribution of a minimal feature set in testing whether LLMs can effectively analyze digital phenotyping data. For in-context learning, we evaluate seven few-shot settings (0, 1, 3, 5, 10, 15, and 25 examples). For fine-tuning, we compare two strategies: parameter-efficient fine-tuning using QLoRA55 and embedding-layer-only fine-tuning39, across the same 15 feature sets and four different prompt formats. We compare the LLM-based models against multiple baseline models (XGBoost, Random Forest, LSTM, and CNN-LSTM) trained on the same input features as LLMs. All experiments are repeated across five random seeds to ensure the robustness of the results. Performance variability across seeds is explicitly reported as mean ± standard deviation for all Macro-F1 scores. We adopt Macro-F1 because our dataset is highly imbalanced, with “Remain Stable” comprising the majority class; this metric equally weights each class, providing a more faithful assessment of model performance on the minority classes ("More Depressed” and “Less Depressed”), which are clinically important. To better reflect clinical priorities, we additionally report class-specific recall, with particular emphasis on minority classes (worsening and improvement). This provides a more direct assessment of the model’s sensitivity to clinically meaningful changes, especially missed worsening events, which carry greater clinical consequences. In addition, detailed per-class metrics (precision, recall, and confusion matrices) are provided in the Supplementary Information to highlight model performance on minority classes. We note that no consensus clinical performance thresholds for passive sensing models currently exist in the literature. Clinical utility in this domain is typically evaluated in terms of sensitivity to deterioration and the ability to identify at-risk individuals earlier than routine self-report or scheduled visits, rather than absolute Macro-F1 cutoffs. We therefore benchmark against prior comparable work, including 20, who report a Macro-F1 of 0.67 when jointly leveraging smartphone-sensed behavioral data and contemporaneous PHQ-9 scores, and interpret our results relative to this landscape. In this study, labels are defined as discrete biweekly transitions based on changes in PHQ-9 scores between consecutive assessments. These transitions represent interval-level summaries rather than continuous symptom trajectories, and they do not provide information about the exact timing, onset, or persistence of changes within each interval. Moreover, transitions are not guaranteed to be temporally contiguous across intervals, limiting the ability to define coherent episodes of change. In-context learning performance Since prompt design strongly influences in-context learning, we test four systematic formats (Basic, Health Context, Statistics, and All) at 25-shot settings across the different types of LLMs (Fig. 2), the All prompt achieves the highest mean Macro F1 score, significantly outperforming the Basic and Health Context settings (p < 0.001). The Statistics format also provides an advantage over Basic and Health Context, though it does not differ significantly from All. Under this setting, a small subset of feature-set combinations with the highest mean Macro-F1 scores using 25-shots in-context learning is selected for focused reporting, with complete results for other prompt formats and feature sets provided in the Supplementary Information (Figs. S1–S4). The six highest-performing configurations are All Features (0.354), Battery + Screen-Off + Screen-Use (0.344), Battery + Screen-Off + Magnitude (0.341), Screen-Off + Magnitude (0.338), Battery + Magnitude + Screen-Use (0.338), and Screen-Use (0.335).Fig. 2Comparison of four prompt formats(Basic, Health Context, Statistics, and All) aggregated across LLMs and feature sets.Bars indicate the mean Macro F1 score across five random seeds, with error bars showing the standard deviation. Square brackets denote the results of paired t-tests between prompt formats, with significance levels annotated as *p < 0.05, **p < 0.01, and ***p < 0.001. a Comparison of different prompt formats across multiple LLMs trained on different feature sets at the 25-shot setting. b Comparison of different LLMs at the 25-shot setting using prompt format All cross multiple feature sets. Comparison of four prompt formats(Basic, Health Context, Statistics, and All) aggregated across LLMs and feature sets. Bars indicate the mean Macro F1 score across five random seeds, with error bars showing the standard deviation. Square brackets denote the results of paired t-tests between prompt formats, with significance levels annotated as *p < 0.05, **p < 0.01, and ***p < 0.001. a Comparison of different prompt formats across multiple LLMs trained on different feature sets at the 25-shot setting. b Comparison of different LLMs at the 25-shot setting using prompt format All cross multiple feature sets. Figure 3 represents the top six performances of in-context learning using Llama 3.1 under the All prompt format (Full results in Fig. S1). Our results show that few-shot in-context learning outperforms zero-shot in most cases. This demonstrates the strong adaptability of LLMs when supplied with structured demonstrations. In the zero-shot setting, models perform poorly, with average Macro F1 scores often below 0.20. However, with only a handful of examples, scores rise substantially. By the 25-shot condition, all four LLMs achieve values in the 0.34–0.40 range, representing improvements of 0.15–0.25 points over zero-shot. This demonstrates the strong adaptability of LLMs when supplied with structured demonstrations.Fig. 3Effect of in-context examples (shots) on LLaMA-3.1-8B performance across different digital phenotyping feature sets.a–f show Macro-F1 scores as a function of the number of in-context examples (shots) for a single feature-set configuration, evaluated using LLaMA-3.1-8B under All prompt. Points indicate mean performance aggregated over five random seeds. Light shaded bands represent ± 1 standard deviation (SD), while darker shaded bands represent ± 1 standard error of the mean (SEM). Results illustrate how performance scales with increasing contextual supervision and how different behavioral feature combinations affect learning dynamics. Effect of in-context examples (shots) on LLaMA-3.1-8B performance across different digital phenotyping feature sets. a–f show Macro-F1 scores as a function of the number of in-context examples (shots) for a single feature-set configuration, evaluated using LLaMA-3.1-8B under All prompt. Points indicate mean performance aggregated over five random seeds. Light shaded bands represent ± 1 standard deviation (SD), while darker shaded bands represent ± 1 standard error of the mean (SEM). Results illustrate how performance scales with increasing contextual supervision and how different behavioral feature combinations affect learning dynamics. A non-monotonic pattern is also evident. In several cases, while the 1-shot example generally outperforms the zero-shot scenario, the 3-shot and 5-shot examples often show slightly lower performance than the 1-shot setting. For example, when using Battery + Magnitude + Screen-Use features as inputs, Llama-3.1-8B improves from 0.25 in the zero-shot setting to 0.28 with one-shot, and drops to 0.26 with three-shot. Several feature configurations (e.g., Screen-Use + Magnitude) exhibit a slight performance dip at the 1-shot setting relative to the zero-shot baseline. This trend, observed across multiple feature combinations and different LLMs, suggests that the model may initially struggle to adapt and generalize as additional, limited examples are introduced, but benefits significantly from larger sets of training examples. By comparing the performance of different LLMs at the 25-shot under prompt format All cross multiple feature sets (Fig. 2), we find that Llama-3.1-8B achieves the highest scores. Mistral-7B and Qwen-3-8B perform comparably, whereas the smaller Gemma-3-4B model is behind with averages closer to 0.30. Notably, even the smaller models demonstrate measurable gains over zero-shot performance, suggesting that the benefits of in-context learning are not limited to high-parameter LLMs. To investigate the causes of the non-monotonic performance pattern observed in few-shot in-context learning, we conduct an error analysis on test cases with all feature combinations under the All prompt with the Llama-3.1-8B model, where 1-shot outperformed 3- or 5-shot. In many cases, the class imbalance in the dataset leads to containing only majority-class examples (e.g., Remains Stable), which encourages the model to overfit to the dominant label and limits generalization. Also, when examples drawn from different individuals may vary in demographic or historical characteristics, the models tend to misclassify. For instance, when inferring the depressive state of a 21-year-old man, the 3-shot context included only older adults (ages 55–64) labeled as Remains Stable, whose baseline phone use and mobility were comparatively low. This skewed reference frame led the model to interpret the younger subject’s reduction in activity as normal variation (Remains Stable) rather than a signal of worsening depression. Performance in the few-shot regime is highly sensitive to which specific examples are chosen. With only 3 or 5 samples, unlucky draws (e.g., atypical cases, borderline examples, or mislabeled data) can have an outsized negative effect. In one instance, a test subject exhibits increased PHQ-9 scores, but the context includes a case with similar behavior patterns that is tagged as Less Depressed. This inconsistent cue biases the model toward Less Depressed rather than More Depressed. As the number of demonstrations increases, the law of large numbers helps stabilize performance. Fine-tuning performance Figure 4 presents the performance of LLMs in detecting depressive state changes using digital phenotyping data in the All prompt format, which integrates PHQ-9 information, statistical summaries, and raw behavioral sequences. We summarize the highest-performing experimental setting for each behavioral feature set in Table S1. Detailed results for other prompt formats are reported in Fig. S5–S7. Baseline results correspond to conventional machine learning and deep learning approaches (Table S2 shows the results of each baseline model). Two distinct fine-tuning strategies (parameter-efficient fine-tuning using QLoRA and embedding layer fine-tuning) are compared across diverse feature sets to determine their effectiveness in capturing behavioral patterns associated with depressive state transitions (Detailed results for comparing different fine-tuning methods across models are in Figs. S8 and S9). By analyzing fine-tuning performance, we aim to assess how well LLMs can learn from digital phenotyping data when given access to labeled training samples and optimized through targeted parameter adjustments. Detailed per-class recall and confusion matrices for different feature sets using All prompt are summarized in Figs. S10–S13.Fig. 4Performance comparison across different feature sets for detecting depressive state changes using prompt format All.The table reports Macro F1 scores with standard deviations (averaged over five independent runs with different random seeds) for multiple large language models (Gemma-3-4B, Llama-3.1-8B, Mistral-7B, Qwen-3-8B). Results are shown for different combinations of digital phenotyping features: battery usage (B), screen-off duration (SO), screen-use duration (SU), and movement acceleration magnitude (M). Performance comparison across different feature sets for detecting depressive state changes using prompt format All. The table reports Macro F1 scores with standard deviations (averaged over five independent runs with different random seeds) for multiple large language models (Gemma-3-4B, Llama-3.1-8B, Mistral-7B, Qwen-3-8B). Results are shown for different combinations of digital phenotyping features: battery usage (B), screen-off duration (SO), screen-use duration (SU), and movement acceleration magnitude (M). Across feature sets, absolute performance levels are modest, with the highest scores clustering in the mid-0.36 range. This outcome is expected given the severe class imbalance in the dataset, where over 80% of labels indicate stable states, and the subtlety of behavioral signals derived from smartphone sensors, which are often only weakly correlated with acute clinical changes in depressive symptoms. Embedding-only fine-tuning and QLoRA achieve similar performance across feature sets, with embedding-only slightly higher on some individual features (e.g., SO and SU for Llama-3.1-8B), while QLoRA matches or surpasses embedding in combined feature settings. This pattern recurs across multiple feature sets and models, indicating that embedding-only fine-tuning tends to deliver slightly stronger performance on isolated features, whereas QLoRA often performs comparably or better when multiple behavioral signals are combined. Although LLMs demonstrate an advantage over conventional baselines, comparisons remain instructive. Random Forest and XGBoost achieve relatively stable Macro F1 scores in the range of 0.29–0.34 (Table S2), while deep learning baselines such as CNN-LSTM closely approach LLM performance, particularly on screen-use data and battery data. Nevertheless, neither class of baseline model surpasses the best in-context or embedding-tuned LLMs. The fact that LLMs could outperform baselines even in the presence of limited labeled data highlights the value of leveraging pretrained linguistic and reasoning capacities for behavioral health prediction. This suggests that few-shot in-context learning is not only highly data-efficient but also highly competitive, demonstrating that large language models can generalize well from limited, well-structured examples without the need for parameter updates. Overall performance Overall, Macro-F1 scores ranged from 0.29 to 0.40, with modest variation across feature combinations and model types (Fig. 4). Fine-tuning approaches generally achieved slightly higher Macro-F1 compared to few-shot prompting and baseline models, although differences were relatively small. As shown in Fig. 4, few-shot in-context learning sometimes matches or exceeds fine-tuned models despite requiring no parameter updates and relying on as few as 25 carefully structured examples embedded within the prompt. Notably, LLMs reach the highest Macro-F1 on the full feature set (All) using 25-shot in-context learning, outperforming their embedding-tuned and fine-tuned via QLoRA counterparts, illustrating that pretrained representations, when leveraged with well-designed prompts, generalize effectively from limited data. These results underscore the data efficiency of prompt-based adaptation strategies in digital phenotyping tasks, which is particularly important in mental health domains where labeled data is scarce and expensive to obtain. For the Remains class, recall is consistently high across models, with fine-tuned models achieving median recall values exceeding 0.6-0.8 depending on feature sets (Fig. S13). In contrast, recall for clinically actionable states is markedly lower. For the More Depressed class (Fig. S11), LLMs using 25 shots in-context learning achieve better recall, with median values typically below 0.35. This implies that a substantial proportion of worsening episodes are not detected, limiting the model’s utility as an early-warning system. For the Less Depressed class (Fig. S12), recall is modest (generally less than 0.4 for most configurations), indicating limited sensitivity to recovery signals. Error analysis and sensitivity analyses To better characterize model limitations and address concerns regarding subgroup performance and potential bias, we conducted a stratified error analysis examining recall for the More Depressed, Less Depressed class and Macro-F1 across key variables (Fig. S14): label distribution, age difference, and gender alignment. Specifically, gender alignment is defined as the proportion of in-context examples with the same gender as the query subject; age difference denotes the mean absolute age difference between demonstrations and the query subject; and label distribution represents the proportion of demonstrations whose labels match the query label. The results show that including in-context examples with more similar label distributions to the target participant is beneficial: recall for the worsening state increases from 0.28 to 0.49, and recall for the less depressed class increases from 0.22 to 0.59 as label alignment improves, suggesting that LLMs are better able to recognize symptom transitions when provided with demonstrations that reflect the target class distribution. Recall for the more depressed class also improves with age similarity (from 0.28 to 0.50), indicating that demographically closer examples may provide more relevant behavioral reference points, though this pattern does not hold for the less depressed class. However, recall decreases for both classes slightly as gender alignment increases, suggesting that gender alignment between demonstrations and the query subject does not confer the same benefit and that the model may rely on features that are not strongly gender-differentiated in this dataset. Macro F1 initially increases with label alignment (from 0.27 to 0.34) but decreases at the highest alignment bin, suggesting that while some degree of label similarity in demonstrations is beneficial, overly homogeneous label distributions may reduce the model’s ability to discriminate between classes. Macro F1 increases more consistently with age difference. However, Macro F1 shows a gradual decline across gender alignment levels (from 0.35 to 0.32), further suggesting that gender-matched demonstrations do not meaningfully improve overall performance. To examine whether model performance varies systematically across diagnostic subgroups, we compare pooled performance across all users with performance within each diagnostic subgroup (Control, MDD, BPD, BD) for in-context learning (Table S3) and fine-tuned LLMs (Table S4). Macro-F1 scores are computed per random seed, and subgroup differences are assessed using Wilcoxon signed-rank tests across seeds with Bonferroni correction (α/m = 0.05/16). Across all evaluated models, no statistically significant differences are observed between pooled and subgroup-specific performance after correction. These results suggest that LLMs exhibit stable performance across the diagnostic subgroups. We assess the robustness of our findings to the choice of outcome definition. We conduct a sensitivity analysis by re-labeling depressive state transitions using a stricter threshold (±4-point change in PHQ-9) and repeating all experiments under identical model settings, feature sets, and tuning methods. Across models, learning paradigms, and feature sets, the relative performance patterns remain highly consistent with those obtained using the ± 3-point cutoff. Paired t-tests comparing Macro-F1 scores between the two thresholds indicate that statistically significant differences are primarily concentrated in low-shot or zero-shot configurations (Table S5) after Bonferroni correction (α/m = 0.05/540). Importantly, this analysis should be interpreted as demonstrating relative stability of Macro-F1 under an alternative labeling rule, rather than robustness in the clinical sense. Changing the PHQ-9 threshold alters what is operationalized as meaningful change and therefore modifies the outcome definition itself. While the consistency of results across thresholds provides supportive evidence that the model’s performance is not overly sensitive to this specific operationalization, it does not imply equivalence across all clinically valid criteria for defining change, nor does it exhaust the range of possible clinically meaningful transition definitions. We further examine the robustness of our results to the use of oversampling strategies. Specifically, we repeat all in-context learning and fine-tuning experiments under identical settings but without applying the oversampling strategy, focusing on LLaMA-3.1-8B under All prompt format. Paired t-tests comparing Macro-F1 scores between runs with and without oversampling indicate no statistically significant differences across feature sets after Bonferroni correction (α/m = 0.05/135). These results suggest that the observed performance patterns are not driven by oversampling and remain stable under the original class distribution. Feature contributions and model-specific effects on LLM performance The linear mixed-effects analysis demonstrates a strong overall contribution of digital phenotyping features to LLM performance. The omnibus likelihood-ratio (LR) test comparing the full model with a reduced model excluding feature terms is highly significant (LR = 306.20, p < 0.001), indicating that the inclusion of feature main effects and feature × model interaction terms substantially improves model fit. Shown as the Table 1, across model architectures, several features show significant average associations with Macro-F1 scores. Battery usage is negatively associated with performance (β = − 0.013, p < 0.001), as is screen-use duration (β = − 0.011, p < 0.001), whereas screen-off duration (β = 0.006, p < 0.001) and acceleration magnitude (β = 0.005, p < 0.001) exhibit positive average associations.Table 1Significant main and interaction effects from a logistic regression modelPredictorβp-valueIntercept0.294<0.001Main effectsBattery usage (B)−0.013<0.001Screen-off duration (SO)0.006<0.001Screen-use duration (SU)−0.011<0.001Acceleration magnitude (M)0.005<0.001Feature × model interactionsB × Gemma-3-4B−0.016<0.001B × Llama-3.1-8B0.015<0.001B × Mistral-7B0.016<0.001B × Qwen3-8B−0.0090.028SO × Llama-3.1-8B0.0080.043SU × Gemma-3-4B−0.0090.035SU × Llama-3.1-8B0.0130.002β denotes standardized regression coefficients. All experimental conditions using the All prompt format are included, pooling across in-context learning and fine-tuning settings. Main effects capture average associations across conditions, while interaction terms indicate moderation effects. Table 1Significant main and interaction effects from a logistic regression modelPredictorβp-valueIntercept0.294<0.001Main effectsBattery usage (B)−0.013<0.001Screen-off duration (SO)0.006<0.001Screen-use duration (SU)−0.011<0.001Acceleration magnitude (M)0.005<0.001Feature × model interactionsB × Gemma-3-4B−0.016<0.001B × Llama-3.1-8B0.015<0.001B × Mistral-7B0.016<0.001B × Qwen3-8B−0.0090.028SO × Llama-3.1-8B0.0080.043SU × Gemma-3-4B−0.0090.035SU × Llama-3.1-8B0.0130.002β denotes standardized regression coefficients. All experimental conditions using the All prompt format are included, pooling across in-context learning and fine-tuning settings. Main effects capture average associations across conditions, while interaction terms indicate moderation effects. Significant main and interaction effects from a logistic regression model β denotes standardized regression coefficients. All experimental conditions using the All prompt format are included, pooling across in-context learning and fine-tuning settings. Main effects capture average associations across conditions, while interaction terms indicate moderation effects. In addition to these main effects, multiple significant feature × model interactions indicate architecture-specific deviations from the average feature effects. Battery usage shows both negative and positive interaction effects depending on the model, including a negative deviation for Gemma-3-4B (β = − 0.016, p < 0.001) and Qwen3-8B (β = − 0.009, p = 0.028), and positive deviations for Llama-3.1-8B (β = 0.015, p < 0.001) and Mistral-7B (β = 0.016, p < 0.001). Screen-off duration exhibits a positive interaction with Llama-3.1-8B (β = 0.008, p = 0.043), while screen-use duration shows a negative interaction with Gemma-3-4B (β = − 0.009, p = 0.035) and a positive interaction with Llama-3.1-8B (β = 0.013, p = 0.002). Discussion In this study, we evaluate whether LLMs can detect changes in depressive symptom severity from digital phenotyping data derived from passively collected smartphone signals. By leveraging in-context learning and fine-tuning strategies, we show that LLMs can integrate complex behavioral features to detect mental health outcomes with comparable performance to the conventional baselines, highlighting the potential of LLMs to capture temporal dynamics in passive sensing signals. We find that LLMs have competitive predictive performance compared to alternative models. However, the performance is still not sufficient for clinical deployment. Rather, the present work should be understood as a methodological investigation of the ability of LLMs to meaningfully analyse digital phenotyping data under realistic data constraints. While our results indicate only modest macro-F1 scores, we emphasize that LLMs are able to leverage pre-trained representations to analyze raw digital phenotyping signals without requiring extensive feature engineering or large annotated datasets. This capability is particularly relevant in digital phenotyping research, where labeled clinical outcomes are often limited and expensive to obtain. Our in-context and embedding-level fine-tuning strategies further indicate that small-scale LLMs can achieve a degree of generalization with limited supervision, highlighting their potential as a lightweight tool for digital phenotyping in healthcare contexts. Thus, while their present performance is limited, LLMs illustrate the potential of general-purpose language models to adopt digital phenotyping data, serving as a lightweight exploratory tool under data-scarce conditions. From this perspective, the contribution of LLMs in this study lies less in large gains in predictive performance and more in their flexibility and data efficiency when modeling complex behavioral trajectories derived from passive sensing data. Nevertheless, further methodological advances and larger datasets will be necessary before such approaches can support clinically meaningful decision-making. Our experiments with in-context learning reveal that LLMs can analyze digital phenotyping data using their pre-trained knowledge. Few-shot in-context learning can achieve comparable performance to both fine-tuned models and conventional baselines, despite relying on as few as 25 labeled examples embedded in the prompt. In mental health research, where labeled data are both costly and sensitive to obtain, the ability of LLMs to generalize from small curated examples is particularly advantageous. However, performance is sensitive to both the number and composition of in-context examples. In zero-shot settings, where models rely solely on pre-existing capabilities, performance is relatively low. Introducing a single example leads to a marked improvement, indicating that even minimal task grounding can substantially aid model interpretation. However, we observed a non-monotonic pattern when increasing examples to 3- or 5-shot settings, where performance sometimes decreased. Error analysis revealed that this decline stems from dataset imbalance. While 3–5 shot scenarios are rarely used in real applications, they serve as diagnostic tools that expose how skewed or inconsistent demonstrations can destabilize model performance, highlighting critical limitations of in-context learning on imbalanced clinical data and emphasizing the importance of careful prompt engineering. We see the task of further optimizing what in-context examples and information to present to the LLM as a natural direction for future work. This includes exploring retrieval-augmented generation (RAG) approaches56,57, where the objective would be to provide contextually dependent input examples optimized for each classification instance. Our findings reveal that embedding-layer fine-tuning produces broadly comparable performance compared to QLoRA fine-tuning across multiple feature sets and prompt formulations. Embedding-layer fine-tuning is a lightweight strategy that only updates the input embeddings during training. This approach preserves the foundation knowledge embedded in the deeper layers of the pre-trained model while adapting its representation space to task-specific data. Prior work has shown that updating embeddings can be effective for domain adaptation under data scarcity, balancing efficiency and performance39,58,59. In contrast, QLoRA model fine-tuning, which adjusts all parameters55,60, can lead to overfitting and a loss of generalizability. These findings imply that fine-tuning strategies should be selected with task design in mind. For exploratory analyses or when data scarcity limits the use of many features, embedding-only fine-tuning offers an efficient and stable option that avoids overfitting. When richer multimodal or multi-feature inputs are available, QLoRA may provide advantages in integrating diverse signals. Another key distinction between the two methods lies in computational requirements. Embedding-layer fine-tuning is more resource-efficient, as it restricts training to a small subset of parameters, lowering memory use and training cost. QLoRA remains more efficient than full fine-tuning but requires greater resources than embedding-only adaptation. In the context of digital phenotyping and mental health monitoring, where labeled data is scarce and computational constraints are common, such efficiency considerations are highly relevant. Llama-3.1-8B achieves higher Macro-F1 scores than Mistral-7B and Qwen-3-8B across many feature sets and prompting strategies. The significant feature × model interactions in our mixed-effects analysis (Table 1) suggest differential feature processing capabilities across models, which may arise from differences in both training corpora and architectural choices. Another likely contributing factor is Llama-3.1’s stronger capacity for long-context processing: prompts in the 25-shot condition span roughly 18-20k tokens, which may be more reliably handled by Llama-3.1’s extended context window (up to 128k tokens) compared to the shorter context limits of Mistral-7B and Qwen-3-8B (32k tokens). As shown in Table S4, Llama-3.1-8B achieves the best performance across most multi-feature configurations, especially in high-shot settings. This difference may be particularly consequential for tasks requiring coherent reasoning across multiple structured demonstrations and heterogeneous behavioral signals. Our findings have implications for the development of LLM-based mental health monitoring tools, but they should be interpreted as an exploratory step rather than a clinically deployable solution. Given the black-box nature of these algorithms and their potential to replicate existing biases in training data, these tools are best used as aids requiring clinicians’ judgment and confirmation, rather than for fully automated decision-making. In practice, this implies a human-in-the-loop deployment, where model outputs are presented as risk flags or trend summaries that require clinician interpretation and confirmation, rather than actionable clinical decisions. Second, interpretability remains a central challenge for LLM-based approaches. To mitigate this, future deployments could expose intermediate representations, such as feature-level summaries, temporal trend descriptions, or example-based rationales, to help clinicians understand why a particular depressive state change may happen. Third, safeguarding patient privacy is paramount in mental health applications. Our study relies exclusively on passively collected behavioral signals and avoids raw content data (e.g., message text or call audio), reducing privacy risks at the data level. For deployment, additional safeguards would be required, including on-device preprocessing, strict data minimization, encrypted storage, and adherence to regional data protection regulations (e.g., GDPR). Importantly, we intentionally focus on open-source models that can be locally deployed within secure clinical infrastructures, avoiding the need to transmit sensitive patient data to external commercial APIs. While commercial LLMs may provide superior performance61, the concerns around user data privacy in mental health applications are paramount. In the field of digital phenotyping, several prior studies use machine learning and deep learning-based methods to detect changes in depressive state23,24. Higher predictive performance is reported in more constrained digital phenotyping settings. For example, prior work62 using smart wristband sensor data collected from 138 undergraduates reports a Macro-F1 of 0.47 for five-class stress level prediction, while another study reports a Macro-F1 of approximately 0.80 for binary detection of depression worsening versus non-worsening using deep learning models63. Similarly, Ikäheimonen et al. report a Macro-F1 of 0.67 when predicting depression state transitions by jointly leveraging smartphone-sensed behavioral data and contemporaneous self-reported PHQ-9 scores20. In current practice, passive sensing models are not used as standalone diagnostic tools, but rather as screening or early-warning systems that flag individuals for further clinical assessment. For such applications, there is no universally accepted Macro-F1 threshold; instead, clinical utility is typically evaluated in terms of sensitivity to deterioration and the ability to identify at-risk individuals earlier than routine self-report or scheduled visits. Beyond predictive performance, the feasibility of deploying LLM-based approaches in clinical settings depends critically on computational footprint, inference latency, and compatibility with institutional data governance requirements. In our experiments, all evaluated approaches (e.g., 25-shot in-context learning, embedding-only fine-tuning, and QLoRA fine-tuning) are feasible on a single modern GPU (NVIDIA Tesla A100 80G GPU), with inference times below one second per instance. The use of open-source models enables hosting entirely within hospital or university infrastructure, ensuring that raw sensor data and derived behavioral features remain under institutional control. However, successful clinical translation requires sustained cross-disciplinary collaboration among clinicians, data scientists, and IT and governance teams to address infrastructure maintenance, model monitoring and validation across clinical populations, and integration into clinician-facing decision support systems. While our study extends our understanding of the application of LLMs in mental health tasks, several limitations need to be addressed for a more comprehensive understanding of the models’ capabilities and their broader implications. Due to constrained computational resources and time, our study relies only on the small open source LLMs (Llama 3.1-8B, Gemma-3-7B, Mistral-7B, Qwen-3-8B), which have fewer than 10 billion parameters. While this model demonstrates promising results, larger LLMs with more sophisticated architectures and higher parameter counts, such as the Llama 3.1 405B model, have demonstrated improved performance across a range of tasks and may yield even better outcomes in detecting changes in depressive state. The dataset used in this study is collected within Finland, representing a relatively homogenous cultural and geographical population. This may limit the generalizability of our findings to other regions or populations with diverse socioeconomic, cultural, or technological contexts. For example, phone activity levels, screen-use habits, and nighttime phone interactions may systematically differ between populations with varying work schedules, urbanization levels, or access to digital infrastructure, potentially biasing models trained in one context when applied elsewhere. In addition, cultural norms surrounding mental health awareness, symptom reporting, and help-seeking behaviors may influence both PHQ-9 responses and their behavioral correlates, further complicating cross-cultural transferability. Technical heterogeneity also poses challenges: differences in smartphone operating systems, sensor availability, background process management, and data logging fidelity across devices and platforms can introduce systematic measurement biases that are independent of mental health status. However, the dataset consists of clinical patients diagnosed and followed in specialized psychiatric care, which makes it a rare and valuable resource, but also means that its characteristics may not be representative of broader community or primary care populations. Future studies should consider cross-cultural datasets to validate the robustness of LLMs across diverse populations and to identify potential biases in model classifications. Our dataset uses self-reported PHQ-9 scores to capture changes in depressive symptoms. While PHQ-9 scores are widely used in clinical and research settings as a screening instrument, self-reported measures can be susceptible to social desirability bias, recall inaccuracies, or underreporting symptoms64. Compared with clinician-administered instruments such as the BDI (Beck Depression Inventory) or MADRS (Montgomery–Åsberg Depression Rating Scale)65,66, which are more reliable but rarely employed in routine clinical care due to their length and interview requirements, the PHQ-9 provides a pragmatic but less nuanced proxy of symptom change. Our use of a 3-point PHQ-9 threshold should be interpreted as a proxy for symptom fluctuation in population-level screening contexts rather than a direct measure of treatment response. This may limit the clinical alignment of our findings, particularly in secondary or tertiary care. Our sample includes participants with heterogeneous clinical profiles (MDD, MDE, BP, BPD). While pooling these groups maximized statistical power and allowed us to focus on symptom-level trajectories rather than disorder-specific classifications, it may mask disorder-specific patterns and limit the precision of clinical interpretation. In particular, depressive episodes in different disorders may exhibit distinct symptom profiles and temporal dynamics, which may also be reflected in their associated behavioral signals. Although our subgroup analyses did not reveal statistically significant performance differences across diagnostic groups, these results should not be interpreted as evidence of equivalence between groups. Given the relatively small sample sizes within each diagnostic subgroup, the statistical power to detect meaningful differences is limited. At the same time, the comparable performance across diagnostically diverse subgroups suggests that our approach may generalize across different types of depressive presentations. Future studies with larger datasets should perform diagnosis-stratified analyses to investigate whether behavioral signatures of depressive change and model performance differ systematically across clinical populations. Methods Study cohort construction In this study, we use a digital phenotyping dataset from a year-long longitudinal study (the Momo-Mood study)47. Participants are recruited in Finland from psychiatric facilities at Helsinki University Hospital, Turku University Central Hospital, and the City of Espoo Mental Health Services. The healthy controls are recruited via university email lists and voluntary healthcare staff. Diagnoses are confirmed using the Mini-International Neuropsychiatric Interview (MINI) 67 and Structured Clinical Interview-II (SCID-II)68. Each group has a higher proportion of female participants: the healthy control group includes 24 women and 7 men; the MDD group, 46 women and 31 men; the MDE ∣ BD group, 18 women and 3 men; and the MDD ∣ BPD group, 23 women and 1 man. Further details regarding participant characteristics and exclusion criteria can be found in ref. 48. Participants may engage in the study for up to one year, with the flexibility to withdraw anytime. The data collection process is divided into two phases: an “active phase” lasting the first two weeks, during which participants respond to 5 rounds of daily questions, and a “passive phase,” which includes biweekly PHQ-9 surveys and continuous passive sensing via smartphones. If a participant does not respond on the date when the questionnaire prompt is issued, the corresponding PHQ-9 assessment is treated as missing rather than being shifted or filled by responses from adjacent days. The passive sensing data comprises timestamps for communication activities (calls and texts), anonymized contact identifiers, smartphone screen events (on, off, lock, unlock), GPS location data, application usage, and battery status20,47. All sensor data is collected passively from smartphone sensors. Each record includes the user’s ID, the device’s ID, and a timestamp. The study presented in this article analyzes the data collected during passive phrase using LLMs to predict PHQ-9 score changes between consecutive two-week periods. The data are gathered using the Niima data collection platform69. The raw data is pre-processed using Niimpy behavioral data analysis toolbox70. For acceleration magnitude, values exceeding 2 × g (19.6 m/s2) are removed as physiologically implausible, and missing values are imputed using the participant-specific median. Battery level does not require outlier filtering and is treated as missing not at random, as missingness may result from phone shutdown, battery depletion, or participant withdrawal; battery status signals are used to identify such cases, and no imputation is applied. For screen usage, continuous usage periods longer than 10 hours are discarded as artifacts. Missing screen status is resolved using battery information: if the phone is shut down, screen status is set to “off”; otherwise, incomplete records are excluded. The raw data is segmented into 6-hour bins during the day (Morning: 6:00 AM to 12:00 PM, Afternoon: 12:00 PM to 6:00 PM, Evening: 6:00 PM to 12:00 AM, Night: 12:00 AM to 06:00 AM). After filtering out participants with insufficient passive data, 810 data points consisting of pairs of biweekly wearable data and PHQ-9 scores from 84 participants remain20. We further retain only those data points representing consecutive two-week periods, resulting in a final dataset of 666 data points. This approach requires strict adherence to ethical standards, including safeguarding the privacy of participants and ensuring fairness in analysis to mitigate potential biases. All participants provided informed consent to be part of the study. This study was approved by the Ethical Committee of the Helsinki and Uusimaa Health District (12.09.2018; HUS/2337/2018). The project was granted a research permit by the Department of Psychiatry at the Helsinki University Hospital. Task definition and data labeling This study evaluates the ability of LLMs to detect changes in depressive states using digital phenotyping data. Specifically, given the participant’s daily behavioral sequence from the previous two weeks and the current two weeks, along with the depressive state following the previous two-week period, the model is tasked with detecting whether the depressive state will change after the current two-week period. To systematically evaluate prompt sensitivity, we designed four distinct prompt formats (Basic, Health Context, Statistics) as well as a combined format (All), each varying in how contextual and clinical information is framed for the model. We select a subset of diverse features that are used and reported to be important for predicting changes in depressive states using the same dataset20. These features include maximum acceleration magnitude, which reflects the most significant movement or activity during a given time period; average battery level in the afternoon, indicating typical smartphone usage patterns during afternoon hours; screen-off duration during the night, representing periods of inactivity or sleep; and screen usage duration in the afternoon, highlighting engagement with the smartphone during the afternoon. While richer feature sets may provide additional predictive power, focusing on a minimal and diverse subset allows us to reduce overfitting risks in our imbalanced dataset and isolate whether LLMs can accurately analyze digital phenotyping data. To evaluate the predictive value of these features, we define our main experimental setups by training and testing models using different combinations of the selected features. Specifically, we assess model performance when using (i) each feature individually, (ii) each pair of features, (iii) each triplet of features, and (iv) all four features together. The same model architecture and hyperparameters are applied across all experimental conditions to ensure comparability. Figure 1 shows the process of data labeling. To capture temporal dynamics, we segment the behavioral data for each participant into two consecutive two-week periods, enabling the models to identify changes in depression state that reflect gradual changes over time. These PHQ-9 score changes are defined by comparing PHQ-9 scores at the start and end of each 2-week period. Following prior clinical work, a 3-point difference on the PHQ-9 has been shown to correspond to a meaningful change in patient-reported outcomes71,72. In addition, our choice is motivated by the distributional characteristics of PHQ-9 scores in longitudinal monitoring. Depressive symptoms typically evolve gradually, with most patients showing only modest score fluctuations over two-week intervals. A lower threshold (e.g., 1–2 points) would risk misclassifying natural variability or measurement noise as meaningful change, whereas a higher threshold (e.g., 5 points) would capture only larger shifts, overlooking subtle but important early signs of deterioration or improvement. Although originally developed as a screening instrument, the PHQ-9 is now widely used in routine clinical care for outcome monitoring due to its brevity and practicality. All patients are initially diagnosed by experienced psychiatrists using structured clinical interviews (MINI and SCID), ensuring that the baseline clinical validity of their depressive symptoms is firmly established. Our operationalization of depression change should be interpreted as a proxy for symptom fluctuation in population-level screening contexts, rather than as a direct measure of treatment response. Based on this threshold, we classify depressive states into three categories: (1) “More Depressed,” indicating a worsening condition marked by an increase in PHQ-9 score by 3 or more points from the previous week; (2) “Less Depressed,” signifying improvement, with a decrease in PHQ-9 score by 3 or more points from the previous week; and (3) “Remains stable,” reflecting no significant change, where PHQ-9 scores differed by less than 3 points between weeks. In the final dataset, there are 62 data points labeled More Depressed, 78 labeled Less Depressed, and 526 labeled Remains stable. Data splitting and augmentation We use the group shuffle split methodology73 to split our dataset, where each random seed uniquely determines the assignment of subject groups to the training and testing sets, thereby inducing a different group-based 60/40 train-test split. This group-based splitting ensures a fair distribution of samples across the test and evaluation sets and prevents data leakage by ensuring that records from the same subject do not appear in multiple splits. For each of the five random seeds, the dataset is initially split into 60% training and 40% testing sets. This choice reflects the relatively small dataset size and the limited representation of minority classes (More Depressed and Less Depressed), allowing for a more reliable estimation of generalization performance. For hyperparameter tuning, the training set is further divided into training and validation subsets in a 50:50 ratio based on the random seed. Once optimal hyperparameters are determined, the models are retrained on the full training data and evaluated on the hold-out test set. To account for randomness, all experiments are repeated across five different random seeds, and we report mean scores with standard deviations. A significant challenge in this study is the large class imbalance in depressive state change labels: 62 More Depressed, 78 Less Depressed, and 526 Remains Stable instances, with the majority class comprising over 80% of the dataset. We address the pronounced class imbalance in depressive state change labels by applying oversampling on the training set. Specifically, after the initial split, we compute the mean number of samples across classes in the training data. For each underrepresented class (More Depressed, Less Depressed), we randomly resample existing samples with replacement until the class count matches this mean. Evaluation metrics During the evaluation phase, we reported macro F1 scores as the primary metric, since this measure balances performance across all classes and mitigates the impact of the substantial class imbalance in our dataset, where more than 80% of cases belong to the majority class. To further clarify how models handle clinically important minority outcomes, we report per-class precision, recall, and confusion metrics in the Supplementary Information. LLM-based Classification Model After defining our task and building our dataset, we focus on evaluating the performance of LLMs to detect changes in the depression state. We use a broader set of open-source LLMs, including Llama 3.1 8B, Gemma 3-4B, Mistral-7B, and Qwen-3-8B. These models represent different architectures and training paradigms, allowing us to probe whether the observed effects are specific to one model or generalizable across model families. All LLMs are tested in both in-context learning and fine-tuning settings. These LLMs demonstrate good performance in diverse natural language tasks, including generating a summary of medical notes, clinical phenotype identification, and physical activity recognition74–76. One of the most exciting aspects of LLMs is their ability to solve complex problems using clear prompts tailored to specific tasks without inputting domain knowledge directly into the model. This capability enables us to evaluate LLMs by providing task-specific instructions and formatted input data. This study starts by testing the performance of four LLMs with zero-shot prompts for detecting changes in depression state. Prompts are formatted to include smartphone sensor sequences and contextual information about depressive states, with the task restricted to predicting whether the user becomes “More Depressed,” “Less Depressed,” or “Remains Stable.” To assess the robustness of prompting strategies, we design four systematic prompt formats (Table 2). The four prompt formats are designed according to an additive, ablation-style logic rooted in established principles of context-aware prompting. The Basic format serves as a minimal baseline consistent with standard few-shot prompting11. Health Context prompt adds a brief description of the PHQ-9 instrument to anchor the behavioral data within a clinically meaningful framework, following the principle that domain-specific framing can guide LLMs toward task-relevant reasoning77. The Statistics component follows findings that providing pre-computed summaries of numerical sequences reduces the pattern extraction burden for LLMs operating on time-series data77,78. The All format, as a full combination, directly mirrors the context enhancement ablation design of Kim et al., who similarly found that combining user profile, health knowledge, and temporal context yielded the strongest performance in LLM-based health prediction from wearable data 77 One complete prompt example for each format is provided in the Supplementary Information.Basic: Includes only the previous two weeks and the current two weeks of raw behavioral sequences.Health Information: Incorporates a brief description of the PHQ-9 instrument to connect behavioral sequences with clinical symptom interpretation.Statistics: Supplements the Basic prompt with statistical summaries (e.g., mean and variance of battery, screen-off, screen-use, and magnitude features) to highlight aggregate behavioral patterns.All: Combines PHQ-9 information, statistical summaries, and raw behavioral sequences into a comprehensive prompt.Table 2Four context enhancement strategies for depression state detectionPromptInputBasicMobile phone data over the previous two weeks: Average battery levels in the afternoon over the previous two weeks, reported as a percentage: {53, 82,…,61}. This person was in non-depression over the previous two weeks. Mobile phone data over the current two weeks: Average battery levels in the afternoon over the current two weeks, reported as a percentage: {80, 32,…, 41}.Health ContextPHQ-9 is an established diagnostic instrument designed to screen for the presence and measure the severity of depressive symptoms in individuals. Respondents of the PHQ-9 are asked to reflect on their experiences over the past two weeks, rating the frequency of symptoms such as sleep disturbance, loss of interest, energy levels, and mood changes. [same as Basic].StatisticsWithin the previous two weeks, the average mobile phone usage was: battery {80.3}%. [same as Basic].AllPHQ-9 is an established diagnostic instrument designed to screen for the presence and measure the severity of depressive symptoms in individuals. Respondents of the PHQ-9 are asked to reflect on their experiences over the past two weeks, rating the frequency of symptoms such as sleep disturbance, loss of interest, energy levels, and mood changes. Within the previous two weeks, the average mobile phone usage was: battery {80.3}%. [same as Basic].The table shows four context enhancement strategies (Basic, Health Context, Statistics, and All). Each strategy provides varying levels of contextual information from mobile sensing data and PHQ-9 descriptions to guide the model in detecting changes in users’ depression states. Basic: Includes only the previous two weeks and the current two weeks of raw behavioral sequences. Basic: Includes only the previous two weeks and the current two weeks of raw behavioral sequences. Health Information: Incorporates a brief description of the PHQ-9 instrument to connect behavioral sequences with clinical symptom interpretation. Health Information: Incorporates a brief description of the PHQ-9 instrument to connect behavioral sequences with clinical symptom interpretation. Statistics: Supplements the Basic prompt with statistical summaries (e.g., mean and variance of battery, screen-off, screen-use, and magnitude features) to highlight aggregate behavioral patterns. Statistics: Supplements the Basic prompt with statistical summaries (e.g., mean and variance of battery, screen-off, screen-use, and magnitude features) to highlight aggregate behavioral patterns. All: Combines PHQ-9 information, statistical summaries, and raw behavioral sequences into a comprehensive prompt. All: Combines PHQ-9 information, statistical summaries, and raw behavioral sequences into a comprehensive prompt. Table 2Four context enhancement strategies for depression state detectionPromptInputBasicMobile phone data over the previous two weeks: Average battery levels in the afternoon over the previous two weeks, reported as a percentage: {53, 82,…,61}. This person was in non-depression over the previous two weeks. Mobile phone data over the current two weeks: Average battery levels in the afternoon over the current two weeks, reported as a percentage: {80, 32,…, 41}.Health ContextPHQ-9 is an established diagnostic instrument designed to screen for the presence and measure the severity of depressive symptoms in individuals. Respondents of the PHQ-9 are asked to reflect on their experiences over the past two weeks, rating the frequency of symptoms such as sleep disturbance, loss of interest, energy levels, and mood changes. [same as Basic].StatisticsWithin the previous two weeks, the average mobile phone usage was: battery {80.3}%. [same as Basic].AllPHQ-9 is an established diagnostic instrument designed to screen for the presence and measure the severity of depressive symptoms in individuals. Respondents of the PHQ-9 are asked to reflect on their experiences over the past two weeks, rating the frequency of symptoms such as sleep disturbance, loss of interest, energy levels, and mood changes. Within the previous two weeks, the average mobile phone usage was: battery {80.3}%. [same as Basic].The table shows four context enhancement strategies (Basic, Health Context, Statistics, and All). Each strategy provides varying levels of contextual information from mobile sensing data and PHQ-9 descriptions to guide the model in detecting changes in users’ depression states. Four context enhancement strategies for depression state detection The table shows four context enhancement strategies (Basic, Health Context, Statistics, and All). Each strategy provides varying levels of contextual information from mobile sensing data and PHQ-9 descriptions to guide the model in detecting changes in users’ depression states. Except for zero-shot prompting, researchers have proposed few-shot prompting techniques with LLMs, using a small number of task examples to aid in-context learning. These labeled examples are used only in the prompts sent to the model while the parameters of the LLMs are frozen. We test few-shot prompting, where the model is provided with examples as demonstrations within the prompt79. We randomly select 1, 3, 5, 10, 15, and 25 examples (shots) as part of the prompt to explore how the number of examples influences the model’s accuracy in detecting depression state changes. Prior studies have shown that zero-shot, low-shot (1-5), and higher-shot settings represent qualitatively distinct learning regimes, with small shot counts often exhibiting high variance and non-monotonic behavior due to sensitivity to demonstration selection6,11,80. The upper bound of 25 shots is further constrained by context length limits given the long, structured prompts required for digital phenotyping data, consistent with prior evaluations. Prompt length varies with the number of in-context examples and the selected prompt format (Basic, Health Context, Statistics, or All). In the most demanding configuration, using 25-shot prompting with all four behavioral features requires 18k-20k tokens. Generation is deterministic with a maximum of 16 new tokens to prevent verbose or off-format responses. All constructed prompts remain within the maximum context window limits of the four evaluated models. We evaluate the performance of LLMs for detecting depressive state changes using two fine-tuning modes: parameter-efficient fine-tuning using QLoRA38,55 and fine-tuning only the embedding layers39,81,82. We apply QLoRA, where low-rank adaptation (LoRA) modules are inserted across all layers of the model55. Unlike some parameter-efficient approaches that only modify a few layers or components, this setup enables updates across the entire model architecture. This technique enhances the fine-tuning process’s efficiency, preserving the pre-trained model’s generalization capabilities while focusing on performance improvements. The model is loaded in 4-bit with a quantization type of nf4 (normal four-bit float) data type. The model is configured for a 32-bit paged AdamW optimizer, a batch size of 1, a warmup ratio of 0.03, gradient accumulation steps of 4, and a cosine learning rate scheduler. The QLoRA configuration includes a dropout rate of 0, a rank (r) of 64, and an alpha parameter of 16 to control the adaptation’s capacity. In embedding-only mode, the fine-tuning process updates only the embedding layer parameters, focusing on refining token representations while keeping the rest of the model frozen39. By freezing the higher layers of the LLM and modifying only the embedding layers, this approach minimizes computational overhead while retaining the generalization capability of the pre-trained model. This is configured using the AdamW optimizer and similar hyperparameters as QLoRA fine-tuning mode. Comparison to baselines We compare the in-context learning and fine-tuning classification performance with both conventional machine learning and deep learning time-series models, including XGBoost, Random Forest, LSTM, and CNN-LSTM. The dataset used for baseline models contains the same features as those selected for in-context learning and fine-tuning. The data is segmented into biweekly intervals. For each time segment, a feature vector is constructed to capture sensor-based behavioral data from the preceding two weeks. This feature vector includes numerical representations of key behavioral metrics derived from passive smartphone sensor data, including average battery level in the afternoon, screen-off duration at night, screen usage duration in the afternoon, and maximum acceleration magnitude per day. To ensure consistency across models, we apply identical data augmentation techniques to each feature dataset and use the same split as in in-context learning and fine-tuning. To prevent discrepancies arising from varying feature scales, we standardize all input features before training. Different scaling strategies are adopted for traditional machine-learning and deep learning models due to their distinct optimization characteristics. Traditional models are standardized using z-score normalization to ensure comparable feature variance and stable regularization, whereas deep learning models employ min-max normalization to bound inputs within 0 to 1, facilitating gradient-based optimization and preserving relative temporal dynamics in behavioral time-series data. In all cases, scalers are fit exclusively on the training data to avoid information leakage. Hyperparameter tuning is performed using 3-fold cross-validation83 on the combined training and validation dataset. For each experimental setup, corresponding to a combination of different input features, the optimal hyperparameter combination is selected based on the average macro F1-score across the validation folds. Final model performance is reported on the test set using the macro F1-score to account for class imbalance. To ensure the robustness and reproducibility of results, each baseline model is trained and evaluated five times using different random seeds, and we report the mean performance across these runs. This rigorous tuning and evaluation protocol ensures a fair and reproducible comparison with in-context learning and fine-tuning approaches. Mixed-effects regression analysis To quantify the contribution of individual digital phenotyping features and their model-specific effects on LLM performance, we conduct a linear mixed-effects regression analysis on Macro-F1 scores. We fit a linear mixed-effects model with Macro-F1 score as the outcome variable. Fixed effects include the main effects of each binary feature and their interactions with the model architecture. Random intercepts are included for the random seed. The full model is specified as:1\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{array}{l}\mathrm{MacroF}{1}_{i}={\beta }_{0}+\mathop{\sum }\limits_{f\in \{B,SO,SU,M\}}{\beta }_{f}{f}_{i}\\ \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,+\mathop{\sum }\limits_{f\in \{B,SO,SU,M\}}\mathop{\sum }\limits_{k}{\gamma }_{f,k}\,{f}_{i}\,{\rm{ {\mathbb{I}} }}({\mathrm{Model}}_{i}=k)+{u}_{s[i]}+{\varepsilon }_{i},\end{array}$$\end{document}MacroF1i=β0+∑f∈{B,SO,SU,M}βffi+∑f∈{B,SO,SU,M}∑kγf,kfi𝕀(Modeli=k)+us[i]+εi,where β0 denotes the intercept; βf represent average feature main effects across models; γf,k capture feature × model interaction effects for model k; \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\mathbb{I}}(\cdot )$$\end{document}I(⋅) is an indicator function; \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${u}_{s[i]} \sim {\mathcal{N}}(0,{\sigma }_{u}^{2})$$\end{document}us[i]~N(0,σu2) is a random intercept for random seed s; and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\varepsilon }_{i} \sim {\mathcal{N}}(0,{\sigma }^{2})$$\end{document}εi~N(0,σ2) denotes the residual error. For model comparison, we fit a reduced model that includes only model architecture as a fixed effect and random intercepts for random seed:2\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${{\rm{MacroF1}}}_{i}={\beta }_{0}+\mathop{\sum }\limits_{k}{\delta }_{k}\,{\mathbb{I}}({{\rm{Model}}}_{i}=k)+{u}_{s[i]}+{\varepsilon }_{i}.$$\end{document}MacroF1i=β0+ ∑kδkI(Modeli=k)+us[i]+εi. Both models are estimated using maximum likelihood. We conduct an omnibus likelihood-ratio test to assess whether inclusion of feature main effects and feature × model interactions significantly improves model fit relative to the reduced model. Statistical significance is evaluated using a two-sided threshold of α = 0.05. Only statistically significant coefficients are reported. Supplementary information Supplementary Information Supplementary Information