A unified time-frequency foundation model for sleep decoding

Domain: physics
Published: 2026-01-13
Editorial outcome: major_revision

Abstract
Sleep decoding is key to revealing sleep architecture and its links to health, yet prevailing deep-learning models rely on supervised, task-specific designs and dual encoders that isolate time-domain and frequency-domain information, limiting generalizability and scalability. We introduce SleepGPT for sleep decoding, a time-frequency foundation model based on generative pretrained transformer, developed using multi-pretext pretraining strategy on 86,335 hours of polysomnography (PSG) from 8,377 subjects. SleepGPT includes a channel-adaptive mechanism for variable channel configurations and a unified time-frequency fusion module that enables deep cross-domain interaction. Evaluations across diverse PSG datasets demonstrate that SleepGPT sets a new benchmark for sleep decoding tasks, achieving superior performance in sleep staging, sleep-related pathology classification, sleep data generation, and sleep spindle detection. Moreover, it reveals channel- and stage-specific physiological patterns underlying sleep decoding. In sum, SleepGPT is an all-in-one method with exceptional generalizability and scalability, offering transformative potential in addressing sleep decoding challenges.

Introduction
Sleep is a critical physiological process essential for human health, influencing a diverse array of cognitive, emotional, and physical functions1,2. Decoding of sleep patterns is fundamental for elucidating its role in health maintenance and the management of sleep-related disorders3–5. Traditional methods of sleep decoding, such as the manual scoring of polysomnography (PSG) recordings, are labor-intensive, time-consuming, and prone to inter-rater variability. Advances in artificial intelligence (AI) have demonstrated significant potential to automate these processes6–8. Sleep data annotation is expensive and has emerged as an important bottleneck to progress in sleep research. While recent advances like U-Sleep7 have largely alleviated the need for additional annotations in sleep staging, other tasks such as spindle detection and disorder classification still face limited annotated data. Recently, self-supervised learning has demonstrated the potential to leverage unannotated data to pretrain foundation models, thereby significantly reducing the demand for task-specific annotations9–12. Owing to their ability to leverage large-scale unlabeled data while minimizing reliance on annotated datasets, foundation models have been successfully developed and used in biomedical research and genomics13–19. Several self-supervised or pre-trained models for EEG and sleep staging have already been proposed. However, to the best of our knowledge, a multi-task foundation model specifically designed for sleep decoding has not yet been reported.

The development and application of foundation models in sleep research faces three major challenges. First, the lack of self-supervised methods for pretraining poses a significant challenge in developing foundation models for sleep decoding. While different self-supervised pretraining approaches significantly influence model performance16,17, the strategies for scaling these methods to extract robust and diverse sleep representations remain unclear. Second, variability in channel configurations and acquisition protocols across PSG datasets creates significant barriers to model generalization. Although fixed-channel dependencies have historically limited many models in integrating heterogeneous PSG recordings collected using different equipment and setups, recent advances in sleep staging, such as U-Sleep and GSSC20, have demonstrated strong flexibility and can operate with a wide range of channel configurations without strict fixed-channel requirements21. Nevertheless, beyond sleep staging, many existing approaches still rely on fixed-channel assumptions, which continue to restrict large-scale multi-dataset training and adaptation. Finally, integrating time-domain and frequency-domain features remains a significant challenge in sleep decoding. Both domains are essential for a comprehensive understanding of sleep signals22, yet current fusion methods often rely on dual-encoder architectures that process them in isolation6,23, failing to capture their interdependencies. As a result, the potential to leverage complementary features for a more robust, scalable and integrated time-frequency analysis remains limited.

In this study, we present Sleep Generative Pretrained Transformer (SleepGPT), an open-weight foundation model pretrained and evaluated on 86,335 h of PSG recordings from 8377 subjects, specifically designed to these three challenges.

First, SleepGPT adopts a multi-pretext task approach for pretraining, incorporating a time-frequency contrastive learning24,25 approach to align features across domains, a time-frequency matching approach with hard negative pairs to accelerate this alignment, and a masked autoencoder26,27 approach to enhance contextual understanding. The model is pretrained on 59,267 h of PSG recordings from 5132 subjects, representing the largest self-supervised pretraining effort in sleep decoding to date. By leveraging this approach, SleepGPT effectively generalizes across diverse datasets and captures the complex, multifaceted nature of sleep signals. While it is true that many supervised models have been trained on even larger PSG datasets7, the focus of this work is on self-supervised learning, which enables SleepGPT to effectively learn from unannotated data and generalize across a range of sleep tasks.

Second, to overcome the variability in PSG channel configurations across datasets, SleepGPT integrates a channel-adaptive mechanism through channel-wise convolution and masked multi-head self-attention within its Transformer framework28. These innovations enable flexible adaptation to diverse channel combinations, allowing the model to effectively integrate eight key PSG channels, including six electroencephalogram (EEG) channels (C3, C4, F3, FPz, O1, and Pz), one electromyogram (EMG) channel, and one electrooculogram (EOG) channel. This approach not only facilitates the extraction of intrinsic signal features but also enhances the model’s ability to learn inter-channel relationships and generalize across diverse datasets.

Third, to integrate time-domain and frequency-domain features for a deeper understanding of PSG recordings, we develop a unified time-frequency fusion mechanism inspired by the mixture-of-modality-experts Transformer framework29. This time-frequency fusion mechanism leverages a shared attention matrix to jointly align and encode features from both domains, while replacing traditional feed-forward layers with domain-selecting perceptrons that dynamically adapt to emphasize domain-specific characteristics. Unlike dual-encoder approaches that process each domain independently, our unified architecture minimizes redundancy, improves computational efficiency, and uncovers intricate cross-domain relationships, offering a robust and scalable solution for comprehensive sleep decoding.

To systematically evaluate the effectiveness of SleepGPT as a foundational model for sleep decoding in real-world scenarios, we evaluated its performance across four primary tasks: sleep staging, sleep-related pathology classification, sleep data generation, and sleep spindle detection. The evaluation, including fine-tuning and testing, was conducted on publicly available and widely adopted PSG datasets. Compared to other supervised learning methods, SleepGPT achieves state-of-the-art (SOTA) performance in sleep staging, either surpassing or matching the best-performing models. In comparison with other unsupervised methods, SleepGPT also demonstrates SOTA performance even with minimal labeled data, highlighting its versatility and robustness. Furthermore, SleepGPT shows strong adaptability to wearable single-channel data, highlighting its potential for deployment in resource-limited and home-based sleep monitoring scenarios. By training on multiple channels without direct mixing, the proposed model enables detailed analysis of each channel’s contribution to sleep staging. Notably, it identifies that the F3 and Pz channels consistently exhibit higher importance and deliver superior sleep staging performance across diverse PSG datasets. Additionally, SleepGPT leverages entire-night PSG recordings to classify sleep-related pathologies. The model uses the EEG, EOG, and EMG signals to effectively determine disease types without requiring additional derivations or diagnostic information from patients. Furthermore, we analyzed the contribution of sleep stages to disease classification, providing insights into the underlying mechanisms of sleep-related pathologies. SleepGPT exhibits exceptional performance in generating sleep data, with its effectiveness validated through randomly masked scenarios designed to simulate noise artifacts commonly observed during PSG data collection. Moreover, the findings indicate that leveraging the model’s generative capabilities to expand the dataset substantially enhances the accuracy and reliability of sleep staging. Lastly, the model demonstrates exceptional performance in sleep spindle detection, significantly achieving high recall – an essential metric for accurate diagnosis and effective treatment in clinical applications. In sum, SleepGPT demonstrates its potential to assist clinical diagnostics while advancing deep learning research in the field of sleep decoding.

Results
Overview of SleepGPT
The input to SleepGPT consists of time-frequency PSG signals derived from a single epoch of multi-channel PSG recordings, initially represented in the time domain and spanning 0 to 30s (Supplementary Note 1). Each channel in this multi-channel epoch undergoes an independent short-time Fourier transform to produce a spectrogram. Rather than interpreting the spectrogram as a combined time-frequency map, each time window is treated separately to allow granular analysis of short-term frequency dynamics (Methods). The resulting frequency-domain signals are then integrated with the original time-domain signals, forming time-frequency, multi-channel signals. These signals are mapped into high-dimensional embeddings, which are subsequently processed within a unified time-frequency (UTF) transformer framework, thereby providing rich, time-frequency and multi-channel embeddings for both pretraining and downstream tasks. SleepGPT training proceeds in two stages: an initial pretraining phase on large-scale PSG datasets to capture general-purpose representations, followed by fine-tuning on smaller PSG datasets optimized for specific downstream tasks (Fig. 1a).

Building on this time-frequency representation, channel-wise convolutions are first applied to time-domain and frequency-domain signals, segmenting the input into smaller patches and mapping them to high-dimensional features, referred to as patch tokens (Fig. 1). A masking strategy on patch tokens facilitates flexible adaptation to diverse channel configurations, resulting in robust and unified representations. The core of SleepGPT is the UTF transformer block, which integrates domain-selecting perceptrons. This module dynamically selects or fuses embeddings from both time-domain and frequency-domain, capturing complementary features for robust representations by leveraging the time-domain and frequency-domain characteristics of PSG signals (Fig. 1b).

To pretrain robust features from multi-channel PSG signals, we employed the time-frequency contrastive learning approach with hard sample pairs to predict matching pairs (Supplementary Figs. 1, 2) and applied the masked autoencoder approach to reconstruct original signals in time-domain and frequency-domain (Supplementary Fig. 3). For downstream tasks, SleepGPT’s outputs are adapted based on task requirements, either by aggregating features across adjacent epochs or directly using the embeddings. We evaluated SleepGPT on four downstream tasks to assess its performance (Fig. 1c).

Overview of PSG datasets
In this study, databases refer to collections of PSG recordings derived from independent clinical or basic research studies, often conducted over multiple rounds of data collection or sub-cohort divisions. Within each database, PSG recordings are categorized into datasets based on study-specific criteria, such as collection protocols, participant cohorts, or experimental conditions (Methods).

SleepGPT was pretrained and evaluated on 14 PSG datasets sourced from seven PSG databases, comprising 86,335 h of recordings from 8377 subjects (Supplementary Table 1).

For pretraining, we utilized four PSG datasets sourced from three PSG databases, comprising 7650 PSG recordings collected from 5132 subjects, spanning a total of 59,267 h (Supplementary Table 2). These datasets include the PhysioNet2018-test dataset from the PhysioNet/Computing in Cardiology Challenge 2018 (PhysioNet2018) database30; the SHHS-1 (Visit 1) and SHHS-2 (Visit 2) datasets from the Sleep Heart Health Study (SHHS) database31,32; and the Sleep EEG fMRI dataset from the Sleep EEG fMRI database33,34.

For evaluation in downstream tasks, we employed 11 PSG datasets sourced from six PSG databases to fine-tune and test our model, consisting of 7325 PSG recordings from 7250 unique subjects, collectively totaling 57,053 hours (Supplementary Table 3). These datasets include the CAP dataset from the CAP database35, five subsets (MASS-SS1 to SS5) from the Montreal Archive of Sleep Studies (MASS) database36; the PhysioNet2018-training dataset from the PhysioNet2018 database; the SHHS-1; two versions from the Sleep-EDF database37, which includes the 2013 version (SleepEDF-20) and the 2018 version (SleepEDF-78); and the UMind Sleep (UMS) dataset from UMS database38.

More details on dataset composition and usage can be found in Methods section and Supplementary Tables 1–4.

SleepGPT surpasses SOTA supervised learning methods in sleep staging
Sleep staging is a fundamental process in sleep research and clinical practice, serving as the cornerstone for diagnosing sleep disorders, evaluating sleep quality, and understanding neurological and physiological functions during sleep. Sleep staging generally involves segmenting PSG recordings into 30-second intervals, and classifying each interval into a specific physiological stage: wakefulness (W), non-rapid eye movement (NREM) sleep stages 1 (N1), 2 (N2), and 3 (N3), rapid eye movement (REM) sleep, or UNKNOWN, according to the American Association of Sleep Medicine (AASM) guidelines39 (Supplementary Table 5). In the context of sleep staging, an epoch refers to a standard 30-second interval of PSG recordings used for classification. We conducted a comprehensive evaluation of our model, SleepGPT, by benchmarking it against SOTA supervised learning methods, including Cross-modal SleepTransformer40 and SleepXViT41, as well as other strong baselines6,8,42–45 using nine datasets: MASS-SS1 to SS5, PhysioNet2018-training, SHHS-1, SleepEDF-20 and SleepEDF-78 (Supplementary Table 6). Following the evaluations scheme adopted by these SOTA methods, the MASS-SS1 to SS5 datasets were combined and treated as a single dataset for fine-tuning and testing. Both overall metrics (accuracy (ACC), macro F1 score (MF1)46, and Cohen’s kappa score (Kappa)47) and per-class F1 score were adopted for the evaluation (Fig. 2a and Supplementary Table 7). Visualization of fine-tuned SleepGPT embeddings are presented by uniform manifold approximation and projection (UMAP)48 (Fig. 2b).

SleepGPT outperformed or matched SOTA supervised learning methods across five benchmark datasets for sleep staging (Fig. 2a). These results underscore SleepGPT’s robust generalizability, demonstrating consistent performance on both small and large datasets, irrespective of channel configurations. Notably, on the largest dataset SHHS-1, SleepGPT achieved an ACC of 89.1%, a MF1 of 82.4%, and a Kappa of 0.845. For key sleep stages such as N2 and REM, the model achieved F1 scores of 90.2% and 91.6%, respectively, reflecting its capacity to precisely classify stages critical to understanding sleep architecture. To evaluate the model’s adaptability to diverse channel configurations and its downstream task performance, we implemented two fine-tuning strategies in the MASS-SS1 to SS5 datasets. The first employed fixed channel configurations across all datasets, while the second adapted to the specific channel settings of each dataset. The adaptive strategy yielded superior results, achieving an MF1 of 85.1%, demonstrating the model’s ability to flexibly accommodate heterogeneous channel setups, leading to improved classification. Overall results were calculated by averaging confusion matrices across four datasets (Fig. 3c). SleepGPT with the Pz channel showed substantial improvements in average F1 scores across W, N1, N2, N3, and REM stages (8.8 p.p., 15.6 p.p., 2.2 p.p., 3.7 p.p., and 3.9 p.p., respectively). It also achieved enhanced overall metrics, increasing ACC by 6.8 p.p. (P < 0.0001), MF1 by 3.7 p.p. (P < 0.0001), and Kappa by 0.059 (P < 0.0001). These findings suggest that the Pz channel may offer superior utility for sleep monitoring, potentially guiding the design of more efficient and accurate single-channel wearable devices for continuous, non-invasive sleep assessment and personalized health monitoring.

SleepGPT surpasses SOTA unsupervised learning methods in sleep staging
To evaluate the effectiveness of our method in sleep staging within an unsupervised learning framework, we conducted a comprehensive comparison against SOTA unsupervised learning methods, including: 1) Neuro-Bert49, leveraging the masked autoencoder approach; 2) ContraWR50, leveraging the contrastive learning approach optimized for minimal labeled data; 3) MulEEG51, employing the dual-encoder architecture to process time-frequency PSG signals in isolation; and 4) TS-TCC52, an established framework for time-series representation learning. Each method corresponds to a specific evaluation scheme. Each experiment was conducted with five random seeds, assessed by mean and standard deviation of the three overall metrics (Supplementary Tables 9, 10). We also compared SleepGPT’s performance against other advanced methods9,53–57 under the evaluation scheme adopted by TS-TCC (Fig. 2c) and visualized embeddings learned by SleepGPT using UMAP (Fig. 2d).

Against Neuro-Bert, which utilized the masked autoencoder approach and the transformer backbone, SleepGPT showed a notable performance increase, with 0.9 p.p. in ACC and 2.7 p.p. in MF1. Meanwhile, SleepGPT also got an improvement of 2.3 p.p. for ACC and 4.2 p.p. for MF1 against MAE26, a prominent transformer model in computer vision using the masked autoencoder approach. SleepGPT can also consistently perform well in case the amount of labeled data available is not sufficient. Our model surpassed ContraWR by 0.4 p.p. in ACC with only 5.0% labeled data. When testing on MulEEG with 20 subjects under cross-validation evaluation scheme, SleepGPT improved ACC and MF1 by 6.3 p.p. and 8.8 p.p., respectively. This highlights the superiority of our proposed transformer backbone with a unified fusion block over dual-encoder models using unsupervised methods. In addition, our model outperformed TS-TCC, enhancing ACC by 1.6 p.p. and boosting MF1 by 7.1 p.p. These results confirm that our hybrid pretraining method significantly enhanced representations.

SleepGPT performing on wearable data
To evaluate the adaptability of SleepGPT to wearable data, we conducted experiments on the UMS dataset, which provides single-channel EEG from a wearable forehead recorder alongside PSG. Following previous research38, we grouped N1 and N2 as light sleep and treated N3 as deep sleep for a 4-class setting. SleepGPT achieved an ACC of 82.1% (MF1: 78.0%, Kappa: 0.694), and incorporating SpO2 further improved performance to 82.6% ACC (MF1: 78.6%, Kappa: 0.701) (Supplementary Table 11).

In addition, we evaluated SleepGPT on the same dataset under the original 5-stage classification setting (Wake, N1, N2, N3, REM). SleepGPT with SpO2 achieved an ACC of 76.6% (MF1: 67.5%, Kappa: 0.653) with per-class F1 scores of 72.5% (Wake), 28.2% (N1), 85.2% (N2), 75.2% (N3), and 76.1% (REM) (Supplementary Table 12). These results show that SleepGPT is capable of maintaining strong performance even when handling the full 5-class staging with single-channel input, highlighting its ability to generalize beyond standard PSG configurations and its potential applicability in wearable-device scenarios.

The F3 and Pz channels play critical roles in sleep staging
To explore the contribution of different channels on sleep staging, we assessed the channel weights during sleep staging (Fig. 3a). Four datasets (MASS-SS1 to SS3 and MASS-SS5) were selected based on channel availability and a heatmap was employed to visualize how different sleep stages and channels interacted. The heatmap revealed that the Pz channel consistently had more influence across all sleep stages compared to other channels, while the F3 channel showed a secondary level of influence, except in MASS-SS2 dataset.

We further compared per-class F1 scores across the four datasets by fine-tuning using either the F3 or Pz channels (Fig. 3b). The F3 channel was specifically chosen due to its significant impact on sleep staging, its inclusion in AASM guidelines, and its common use in wearable devices as a frontopolar EEG electrode. Across all four datasets, SleepGPT utilizing the Pz channel consistently achieved higher per-class F1 scores in the W and N1 stages compared to its performance with the F3 channel. For both the MASS-SS1 and MASS-SS2 datasets, SleepGPT leveraging the Pz channel demonstrated notable improvements across nearly all sleep stages, with particularly strong contributions to the detection of N3 and REM stages, which are critical for deep sleep and dreaming phases.

Sleep-related pathology classification and the impact of sleep stages
Sleep-related pathology impact individuals globally and are associated with serious health issues. When wake/sleep complaints remain undiagnosed and untreated, they impose a substantial burden, both personally, in terms of suffering, and societally, in terms of economic consequences58. Physicians diagnose sleep-related diseases by analyzing overnight sleep signals, a process that is both time-consuming and increasingly challenging given the rising prevalence of sleep disorders. Comprehensive overnight sleep monitoring is essential for accurate detection, yet existing methods rarely leverage overnight signals for automated sleep-related disease classification. SleepGPT addresses this gap by efficiently utilizing overnight PSG recordings for classification. We evaluated its performance on two datasets: the SHHS-1 dataset, performing binary classification between healthy controls (HC) and patients with severe sleep apnea (SSA) and the CAP dataset, focusing on three-class classification among individuals with nocturnal frontal lobe epilepsy (NFLE), REM behavior disorder (RBD), and HC (Methods and Supplementary Note 3).

We found that SleepGPT effectively classifies patients with SSA and HC without relying on electrocardiography or respiratory channels, achieving an average receiver operating characteristic (ROC) area under the curve (AUC) of 0.847 ± 0.002 (Fig. 4a). Evaluation metrics across test results, including ACC, F1 score, precision, and recall, demonstrate robust performance in classifying SSA and HC (Fig. 4b). The confusion matrix results further highlight reliable classification between these two groups (Fig. 4c). In the three-class classification task, SleepGPT demonstrated robust pathology detection capabilities, achieving an average ROC AUC of 0.906 ± 0.010 for NFLE and 0.942 ± 0.012 for RBD (Fig. 4d). Notably, the model exhibited exceptional recall for NFLE, with an average value of 0.915 (Fig. 4e, f). Furthermore, we analyzed the contributions of different sleep stages to the classification of these sleep-related pathologies by comparing the results of using features from all sleep stages versus excluding features from a specific sleep stage. For binary classification between SSA and HC, all sleep stages except the N3 and REM stage showed significant importance: Wake stage (P < 0.0001), N1 stage (P < 0.0001) and N2 stage (P < 0.001) (Fig. 4g). For three-class classification of NFLE, RBD, and HC, features from the N1 stage appeared to interfere with model performance (P < 0.05) (Fig. 4h, i), indicating potential challenges in leveraging this stage for precise pathology classification.

Generative performance across channels and mask ratios
During full-night sleep monitoring, various artifacts can occur, potentially affecting data quality. Excessive nocturnal sweating is a common issue in apnea patients59 and often introduces low-frequency artifacts that interfere with signal integrity60. These sweating-induced artifacts can degrade the accuracy of sleep staging and related analyses. To address this challenge, we incorporated a sleep data generation module into SleepGPT, enabling the generation of multi-channel PSG signals for denoising purposes. To evaluate the model’s generative capabilities, we tested its performance in reconstructing missing PSG signals, simulating scenarios of artifact-induced data corruption.

The reconstruction results across all eight channels, obtained using a randomly masked strategy, demonstrate that SleepGPT effectively reconstructs missing multi-channel PSG signals at the epoch level (30 seconds) (Supplementary Fig. 4). By leveraging features from other channels, the model showcases its robust capability to generate high-quality PSG signals, enhancing the overall quality and accuracy of sleep analysis.

To quantitatively evaluate SleepGPT’s reconstruction performance, we assessed its ability to reconstruct 30-second epochs of PSG signals across multiple downstream task datasets, including MASS-SS1 to SS5, PhysioNet2018-training, SHHS-1, and SleepEDF-78 (which contains SleepEDF-20), using Normalized Mean Squared Error (NMSE) as the evaluation metric (Fig. 5a). The mask strategy and mask ratio used are identical as those specified in the pretraining configuration (Methods). NMSE is a statistical measure used to quantify the difference between predicted values generated by a model and the actual values observed from the environment that the model aims to predict. It is a normalized version of the Mean Squared Error, which is commonly used in the masked autoencoder approach26,61, providing a dimensionless quantity that can be more easily compared across different channels.

The C3 and C4 channels, due to their similar electrode placements, exhibited nearly identical performances as reflected by their NMSE metrics. Remarkably, the F3, FPz, Pz channel consistently outperformed other channels in all datasets that recorded these three channels. The overall boxplot details the NMSE across all eight channels, highlighting that the FPz and Pz channels achieved better outcomes with NMSE metrics nearly one tenth of others, emphasizing their superior performance.

We further illustrate the model’s performance across different mask ratio configurations (Fig. 5b). The F3 and Pz channels were individually evaluated across datasets, selected for their consistently superior performance and presence in five of the eight channels analyzed (Fig. 5a). As the mask ratio increases, the F3 channel’s NMSE rises gradually to 1.546, 1.156, 1.246, 1.074, and 1.270 across the MASS-SS1, MASS-SS2, MASS-SS3, MASS-SS5, and PhysioNet2018-test datasets respectively at a 90.0% mask ratio. Meanwhile, the Pz channel’s NMSE slightly increases to 0.423, 0.223, 0.143, 0.170, and 0.137 for the MASS-SS1, MASS-SS2, MASS-SS3, MASS-SS5 and SleepEDF-78 datasets respectively. This indicates the model’s robust generative capability of these two channels under various conditions. The overall results show that FPz and Pz channels consistently perform well with minimal NMSE fluctuations of around 0.500 and 0.050, respectively. Across all channels except EMG, the maximum NMSE fluctuation is 0.595, demonstrating stable performance.

Enhancement in sleep staging via sleep data generation
Generative models have demonstrated potential in augmenting small sleep datasets62–64, yet limited by a focus on single-task applications or the inability to support multi-channel sleep data generation, hinder their effectiveness in achieving comprehensive and scalable sleep decoding. To address this, we evaluated whether a multi-channel sleep data generation strategy (Methods), using SleepGPT, could improve sleep staging performance in scenarios with extreme data scarcity. Both the SleepEDF-20 dataset, comprising 20 subjects with 4 subjects reserved for validation, and the MASS-SS2 dataset, comprising 19 subjects with 3 subjects reserved for validation, were adopted for the study. We conducted four experiments to assess the impact of sleep data generation through PSG signal synthesis at the epoch level (30 seconds). In each experiment, the training set consisted of 1, 2, 5, or 12 subjects, respectively, while the test set, comprising 4 subjects, was held constant across all experiments (Methods). The experiments compared performance metrics for models trained on the original datasets, which contain unaltered PSG recordings, versus those trained on the augmented datasets (Methods), highlighting the impact of PSG signal generation on improving sleep staging accuracy and robustness. The augmented dataset was generated by combining the original dataset with reconstructed data obtained by applying a 75.0% mask ratio to the original dataset, where epochs were randomly masked. This process effectively doubled the dataset size.

For the SleepEDF-20 dataset, significant improvements were observed on the usage of augmented dataset compared to the original dataset (Fig. 5c): ACC increased by 24.1 p.p. (P < 0.0001), MF1 by 34.7 p.p. (P < 0.001), and Kappa by 0.521 (P < 0.0001) with 2 subjects. In terms of per-class F1 scores, SleepGPT fine-tuned with augmented dataset showed the capability to correctly classify different sleep stages (Fig. 5d). Notably, for the W and N2 stages, using augmented datasets with two subjects led to a statistically significant enhancement in F1 score (P < 0.0001) (Supplementary Table 13).

In the MASS-SS2 dataset, classification of sleep stages using 1, 2, and 5 subjects from the original dataset predominantly resulted in misclassifications (Supplementary Fig. 5). However, employing an augmented dataset with 5 subjects led to notable increases in ACC, MF1, and Kappa, reaching 72.6%, 51.4%, and 0.542, respectively. The per-class F1 scores analysis with 5 subjects revealed that the most significant improvement was in the Wake stage, which increased by 0.8 p.p. to 40.5% (P < 0.05) (Supplementary Table 14).

Evaluation of sleep spindle detection leveraging the original dataset
Sleep spindle detection is essential for identifying sleep stages and diagnosing neurological disorders65. It aids in understanding crucial aspects of sleep quality and brain function. Inspired by success of Spindle U-Net66,67, we approached the detection task as an event-wise classification problem, where ones represents sleep spindles and zeros represent non-sleep spindles (Methods). In this context, we utilized the original MASS-SS2 dataset, consisting of unaugmented, raw PSG recordings where each epoch has a duration of 20s. We reported the F1 score, precision and recall metrics68. Precision is the proportion of true positives among all positive predictions, showing how accurate the model’s positive predictions are. Recall, on the other hand, the proportion of true positives among all actual positives, reflecting the model’s ability to identify positive cases. The F1 score balances precision and recall, providing a single metric that accounts for both false positives and false negatives.

To ensure an unbiased evaluation, annotations from two independent experts with extensive experience in sleep medicine, referred to as Expert 1 and Expert 2, were utilized as the ground truth, respectively. Details about the data and annotations are provided (Supplementary Note 4). Using the original dataset, our model demonstrated substantial capability in detecting sleep spindles, achieving an F1 score of 71.7%, precision of 65.7% and recall of 78.7% with annotations from Expert 1. In addition, with Expert 2’s annotation, the model achieved an F1 score of 79.1%, precision of 77.3% and recall of 81.0%. These results underscored the model’s robust performance, particularly with Expert 2, where it tended to produce more consistent and higher metrics (Fig. 6a). The F1 scores of most subjects are relatively stable with both Expert 1 and Expert 2. However, the model’s performance is limited by the small dataset size. We assessed the correlation between the number of sleep spindles and F1 scores using Pearson’s correlation coefficient (r) to quantify the strength of the linear relationship, and P-values to evaluate statistical significance. The correlations for both experts were significant (Expert 1, Pearson’s r = 0.677, P = 0.001; Expert 2, Pearson’s r = 0.679, P = 0.005).

Sleep spindle detection enhanced through dataset augmentation
Due to the high costs associated with manual labeling, obtaining annotated sleep spindles is challenging. Enhancing detection performance through dataset generation is an effective strategy to get sufficient training data69. Inspired by the success of Spindle U-Net, which manually doubled the size of the MASS-SS2 dataset, and drawing from our own experiments examining the correlation between sleep spindle counts and classification performance, we leveraged the model’s capability to generate new epochs, thus constructing an augmented dataset (Fig. 6b). Specifically, during the preprocessing stage, we randomly masked patches within the epochs, ensuring that each epoch retains at least one-quarter of a sleep spindle. Subsequently, we generated the masked portions once to synthesize new epochs. This masking process was applied to both the time and frequency domains, using a mask ratio of 75.0% (Methods). The final training dataset, referred to as the augmented dataset, was a combination of the new synthetic dataset and the original dataset.

Leveraging the augmented training dataset generated through data augmentation, we reported the F1 score, precision, and recall for each subject annotated by Expert 1 and Expert 2 (Fig. 6c). Using Expert 1’s annotations, the overall F1 score, precision and recall were 72.2%, 66.7% and 78.7%, respectively. With Expert 2’s annotations, these metrics were 79.2%, 78.2% and 80.3%, respectively. Compared to the original dataset, employing the augmented dataset resulted in improved performance. With Expert 1’s annotations, the F1 score increased by 0.5 p.p., and precision improved by 0.9 p.p. For Expert 2’s annotations, the F1 score increased by 0.1 p.p., and precision by 0.9 p.p. Overall, the use of the augmented dataset led to more balanced and robust performance across all metrics.

Methods
Details of dataset
SleepGPT is developed using 14 PSG datasets from six independent databases (Supplementary Table 1). All databases are linked to independent clinical or basic studies. All participants provided written informed consent before participating in the study, in accordance with the protocols approved by the relevant institutional ethics committees.

We pretrain SleepGPT on four datasets: PhysioNet2018-test, SHHS-1, SHHS-2, and SleepEEGfMRI. It is important to note that we randomly split the SHHS-1 dataset into 70.0% pretraining data and 30.0% testing data, which aligns with the practices of some previous supervised learning studies6,42 (Supplementary Table 2). The channels used in each dataset during pretraining, along with the validation set, are shown in Supplementary Table 4.

To assess our model’s sleep staging capabilities, we apply both supervised and unsupervised learning methods evaluation scheme. In comparison to other supervised learning methods, a K-Fold cross-validation evaluation scheme was employed for comprehensive dataset assessments, ensuring no overlap with datasets used during pretraining. This approach highlights the fine-tuning challenges inherent in supervised learning (Supplementary Table 6). Only the SHHS-1 dataset uses a hold-out evaluation scheme exposed during pretraining6. In contrast, unsupervised learning evaluation scheme divides datasets into pretraining, fine-tuning, and testing segments, requiring minimal labeled data to achieve satisfactory performance. We adhere to specified partitioning protocols from respective publications for a fair performance comparison and follow publicly available code where applicable (Supplementary Tables 10, 11). Notably, we utilize only fine-tuning and testing datasets, without any additional pretraining on new datasets. When evaluating on wearable data, we applied a 20-fold cross-validation scheme. In assessing the individual effects of the F3 and Pz channels across four MASS datasets, we randomly select 70.0% of the dataset as training sets and reserve the remaining 30.0% for testing. For the sleep-related pathology classification task, we utilize the CAP and SHHS-1 datasets (Supplementary Note 3). To validate the generative ability of our model on the sleep staging task, we randomly select sub-datasets of 1, 2, 5, and 12 subjects from the SleepEDF-20 and MASS-SS2 datasets as training sets, respectively. This selection represents conditions of extreme data scarcity. For validation, a separate set of 4 subjects (from SleepEDF-20) or 3 subjects (from MASS-SS2) is used, while the remaining 4 subjects are designated as the test set in both the SleepEDF-20 and MASS-SS2 datasets. For sleep spindles wave detection, we maintain consistency with prior works66,74,75, employing a 5-fold cross-validation evaluation scheme and using our model’s generative capabilities to enrich the MASS-SS2 dataset (Supplementary Note 4).

CAP
The CAP sleep database is a comprehensive dataset focusing on the cyclic alternating pattern, a periodic EEG activity observed during NREM sleep, which is associated with various sleep-related disorders. Collected from the Sleep Disorders Center at Ospedale Maggiore in Parma, Italy, the database consists of 108 PSG recordings. It includes signals from at least three EEG channels (F3/F4, C3/C4, O1/O2, referenced to A1/A2), a CHIN1-CHIN2 EMG channel, a bilateral anterior tibial EMG channel, two EOG channels, electrocardiograph channels, and respiratory signals (airflow, abdominal and thoracic effort, SaO2), as well as annotations for sleep stages and cyclic alternating pattern events. The dataset includes recordings from 16 healthy subjects and 92 patients diagnosed with various pathologies such as NFLE, RBD, periodic leg movements, insomnia, narcolepsy, sleep-disordered breathing and bruxism, offering valuable resources for both clinical research and the development of automated cyclical alternating pattern analysis systems.

MASS
MASS is an extensive collection specifically designed to support the scientific community in sleep analysis and automatic sleep stage classification. It is collected by the Center for Advanced Research in Sleep Medicine (CÉAMS), located in Montreal, Canada. This database comprises five subsets (MASS-SS1 to SS5) and includes 200 whole-night sleep recordings from a diverse population, including healthy subjects, individuals with insomnia, and those with sleep apnea. Sleep stages in MASS are manually annotated by experts according to the AASM guidelines for the MASS-SS1 and MASS-SS3 datasets, and the Rechtschaffen and Kales (R&K) standard76 for the MASS-SS2, MASS-SS4, and MASS-SS5 datasets. Under the R&K standard, epochs are classified into eight categories: W, N1, N2, N3, NREM stages 4 (N4), REM, MOVEMENT, and UNKNOWN. Following previous practices6,42,44, to convert R&K annotations into AASM sleep stages (W, N1, N2, N3, and REM), the N3 and N4 stages are merged into a single N3 stage and epochs labeled MOVEMENT or UNKNOWN are excluded to ensure data quality and consistency. For sleep staging, 20s epochs are expanded to 30s by incorporating additional 5s segments before and after each epoch. Due to the variability in channels across different subsets, we offer two supervised learning strategies: one using consistent channels across all five subsets, and another using variable channels suited to each subset specific data when aligning with our model (Supplementary Table 6). For sleep spindle detection, we used the MASS-SS2 dataset. We utilized 20s epochs and focused on the C4 channel to ensure comparability and accuracy in sleep spindle detection (Supplementary Note 4).

PhysioNet2018
The PhysioNet2018 database, also known as the “You Snooze, You Win" challenge, focuses on classifying sleep stages from a large set of recordings sourced from Massachusetts General Hospital’s sleep laboratory. This database comprises 1983 subjects and is utilized in the 2018 PhysioNet challenge to detect arousal during sleep. It contains two datasets, training and testing, but only the training subset includes annotations for sleep stages according to the AASM guidelines. We employ the C3-M2, C4-M1, F3-M2 and O1-M2 EEG channels along with the CHIN1-CHIN2 EMG channel, and the E1-M2 EOG channel (M2 and M1 are reference points for zero potential in EEG and EOG and CHIN1-CHIN2 represents EMG signals recorded between two electrodes placed on the chin).

SHHS
The SHHS database is a multicenter cohort study aimed at investigating the cardiovascular and other health consequences of sleep-disordered breathing. Data are collected from multiple clinical research centers across the United States31,32. It features two rounds of PSG recordings, the SHHS-1 dataset with 5791 subjects and the SHHS-2 dataset with 2651 subjects, encompassing a wide age range from 39 to 90 years. The manual scoring is completed using the R&K guidelines. Similar to other databases annotated with the R&K rule, we merge N3 and N4 stages into a single N3 stage and exclude MOVEMENT and UNKNOWN epochs. We utilize the C4-A1 EEG channel, the C3-A2 EEG channel, the bipolar submental EMG channel, and the LOC EOG channel in our experiments (A1 and A2 are reference points for zero potential in EEG, and LOC EOG represents the left outer canthus electrode used to monitor eye movements). We exclude certain subjects with erroneous markings, consistent with previous studies6. After exclusion, the SHHS-1 and the SHHS-2 datasets comprised 5,721 and 2,518 subjects, respectively

Sleep-EDF
The Sleep-EDF Expanded collection consists of two datasets: SleepEDF-20 (2013 version) and SleepEDF-78 (2018 version), both providing recordings for sleep analysis. Data for the Sleep-EDF collection are sourced from the Sleep Disorder Center of the Hôpital Hôtel-Dieu in Paris, France. The SleepEDF-20 dataset comprises recordings from 20 younger subjects (25–34 years old), while the SleepEDF-78 dataset includes data from 78 healthy Caucasian subjects aged 25–101. Each subject underwent two consecutive day-night recordings, except for a few data losses due to equipment failures (one night for subject 13 in the SleepEDF-20 dataset, and subjects 13, 36, and 52 in the SleepEDF-78 dataset). Recordings are segmented into 30-second epochs and manually annotated by sleep experts following the R&K standards. Epochs are classified into eight categories: W, N1, N2, N3, N4, REM, MOVEMENT, and UNKNOWN. For sleep staging, N3 and N4 stages are combined into a single N3 stage, and epochs labeled as MOVEMENT or UNKNOWN are excluded to ensure data quality and consistency. Both datasets employ the FPz-Cz and Pz-Oz EEG channels (with Cz and Oz as reference points), the horizontal EOG channel, but omit the EMG channel due to its unavailability. To address the disproportionate size of the W class, only 30 minutes of W epochs before and after the sleep period are included in the analysis6,42,44.

SleepEEGfMRI
The database contains 138 individuals, each participant underwent data acquisition on a 3T Siemens MAGNETOM Prisma MRI scanner (Siemens Healthineers, Erlangen, Germany) together with a 64-channel MRI-compatible EEG system (Brain Products, Munich, Germany) in the Center for MRI Research at Peking University in Beijing, China. Simultaneous EEG and fMRI data collection continued until the participant was fully awake and unable to sleep77. Only the EEG data is analyzed in the current study. The EEG data are processed using BrainVision Analyzer 2.1 (Brain Products, Munich, Germany), with sleep stages classified into W, N1, N2, N3, and REM, or UNKNOWN, according to the AASM guidelines. UNKNOWN epochs are excluded. We utilize eight channels including six EEG channels: C3, C4, F3, FPz, O1, and Pz, along with one EMG channel and one EOG channel. The signals from the M1 and M2 electrodes are averaged to serve as the reference for these recordings. This specific montage is chosen to optimize spatial resolution and signal quality, essential for detailed analysis of sleep stages. The SleepEEGfMRI protocols were approved by the Institutional Review Board at Peking University. Each subject signed consent form.

UMS
This study utilized data from an observational study with a within-subject design, conducted at the Sleep Medicine Center of Shenzhen People’s Hospital in China between October 14, 2020 and May 12, 2021. All procedures were approved by the Ethics Committee of Drug Clinical Trial of Shenzhen People’s Hospital (approval number: SYL-202010-03). In total, 203 Chinese adults recruited from a sleep medicine center underwent an overnight study wearing a forehead sleep recorder (UMind Sleep, EEG Smart Co., Ltd.) and PSG simultaneously. During data collection, each participant underwent full-night in-laboratory monitoring using the Philips Alice 6 PSG system (Philips, Respironics, Murrysville, Pennsylvania). The recorded signals included comprehensive electrophysiological channels for sleep evaluation, airflow measurements via thermistor and nasal pressure, and pulse oximetry. Ultimately, data from 197 participants without PSG artifacts or UMind Sleep disconnection, aged 20–63 years (mean ± SD: 37 ± 8.7 years; 148 males) were included in the final analysis. Among these, 171 participants (86.8%) were diagnosed with obstructive sleep apnea (OSA) by standard PSG. Because our goal was to perform sleep staging based on wearable signals, it was necessary to align the wearable recordings with the simultaneously collected PSG signals and use the PSG scoring as the gold standard. To ensure data quality, we excluded PSG recordings in which more than half of the sleep stage labels were unscored, as well as wearable recordings that, after alignment with PSG, contained less than two hours of valid data. After applying these criteria, data from 179 participants were retained for further analysis.

Preprocessing
No preprocessing is conducted on the raw data, except for the SHHS-1 and SHHS-2 datasets. The SHHS-1 and SHHS-2 data are filtered between 0.3–35 Hz, and electrocardiogram noise is attenuated using a linear model. We refer to the dataset that undergoes preprocessing as the “original dataset", while the “augmented dataset" refers to an expanded version of the original dataset, which incorporates additional synthetic data generated through our model.

Patches and patch tokens
In the context of SleepGPT, a patch refers to a smaller, localized segment of the input signal or spectrogram. Patches are extracted to enable fine-grained feature learning and ensure compatibility with Transformer-based architectures. For time-domain signals, patches are obtained by segmenting each channel’s signal into fixed-length windows capturing temporal patterns within localized time intervals. For frequency-domain signals, patches are created by slicing the spectrogram along the temporal axis. Each patch represents the frequency-domain characteristics of the signal within a small-time window, preserving short-term frequency dynamics. This segmentation allows the model to capture local spectral features while maintaining alignment with corresponding time-domain patches. These patches are subsequently mapped into high-dimensional feature representations, known as patch tokens, which serve as the input to the transformer model.

Input embeddings
We demonstrate the keys symbols used in the embedding, pretraining, UTF transformer and downstream tasks section together with their definitions and roles in the model (Supplementary Table 16). We harness a training dataset fX gN comprising N epochs, where each epoch X={x∣i=1,…,L} signifies a sleep PSG recording of length L (equivalent to the sampling rate f multiplied by the epoch duration T). The dataset is initially normalized, aligning it with global mean and standard deviation values that are precomputed across the entire dataset to ensure consistent standardization.

Acknowledging the complex nature of sleep dynamics, our model is adeptly designed to incorporate time-frequency inputs, effectively representing the data in both time-domain and frequency-domain. To achieve this, each epoch X is transformed into a time-frequency spectrogram by short-time Fourier transform, utilizing a 2-second Hamming window with a 50.0% overlap and a 256-point Fast Fourier Transform (FFT). The amplitude spectrum obtained from the FFT is then log-transformed. To retain physiologically relevant features, only the low-frequency (the first f frequency bins) components are preserved, with higher frequencies discarded, denoted as F. This processing yields a paired representation of each epoch, denoted as S=fX ,F gN , which integrates both time-domain and frequency-domain signals.

For the 1D time-domain signals X 2RC×L, we employ channel-wise 1D convolution to segment and reshape them into P =L patch tokens XP 2RC×PT×D, where L is the length of signals, r denotes the time-domain patch resolution, C is the number of channels and D represent the input embeddings dimension (Supplementary Fig. 6). These time-domain patch tokens are subsequently flattened along first two dimensions, and a special marker patch, [T_CLS], is appended at the beginning of the sequence XFlatten 2R(C(cid:2)PT+1)×D. The final time-domain embeddings XInput 2R(C(cid:2)PT+1)×D are derived by summing the flattened patch tokens, 1D learnable positional embeddings, channel embeddings, and token type embeddings.

A similar methodology is applied to the 2D frequency signals F 2RC×T×H. These signals are processed using channel-wise 2D convolution and are partitioned and reshaped into P =T ×H patch tokens FP 2RC×PF×D, where (l, h) specifies the frequency patch resolution, T represents the maximum duration of one epoch, and H denotes the points obtained from FFT. Frequency patches are also flattened and a specially marked [F_CLS] is added to the sequence FInput 2R(C(cid:2)PF+1)×D. The embeddings in the frequency-domain are similarly obtained by summing the corresponding embeddings.

In our model, we synchronize the number of patches across the time-domain and frequency-domain. This synchronization facilitates the precise alignment of time stamps across different domains, thereby enhancing the coherence of time-frequency integration. Specifically, the time-domain resolution r is determined by the product of the frequency-domain window length l and the sampling rate f, such that r=l×f. Furthermore, we set the other parameter in the frequency resolution h equals H. The final stage involves the concatenation of the two embeddings into a single composite H =½XInput;FInput(cid:3) 2R(C(cid:2)2P+2)×D, where P equals to P or P . This composite embedding, H , integrates both domains and serves as the input to the zeroth layer of the UTF transformer, enabling joint processing of time-domain and frequency-domain features.

UTF transformer
The UTF transformer framework, central to our model, is designed to capture the complex relationships between time-domain and frequency-domain signals in PSG. We demonstrate through ablation experiments the necessity of time-frequency fusion and the use of the unified transformer architecture (Supplementary Fig. 7). Specifically, replacing the unified transformer with a dual-encoder architecture (SleepGPT-Dual) or using only the EEG signal (SleepGPT-EO) results in performance degradation. These results highlight the effectiveness of both modality fusion and unified modeling in achieving robust sleep staging. Furthermore, leveraging only the frequency-domain input (SleepGPT-FO) or the time-domain input (SleepGPT-TO) leads to performance drops across all metrics, demonstrating the importance of both representations.

Through a masked multi-head self-attention (MSA) mechanism within its M-depth blocks, it effectively aligns and synthesizes time-domain and frequency-data, capturing both local and global patterns in the time-frequency spectrum (Supplementary Fig. 8). For the i-th UTF transformer block, the masked MSA operation takes the output H i−1 from the (i-1)-th UTF transformer block as input and is formulated as:

H0=MSA(LN(H ))+H , (1)
i i(cid:4)1 i(cid:4)1

where LN is layer normalization. The UTF transformer diverges from traditional architectures by incorporating switching perceptron functions–time-domain, frequency-domain, and unified–in lieu of the usual feed-forward layers, allowing distinct domain representations to be mapped to their respective latent spaces. Initially, in the bottom of (M−K) blocks, the time-domain perceptron (T-PCN) and frequency-domain perceptron (F-PCN) separately process their respective time-domain representations derived from the masked MSA, preserving inherent domain-specific features and facilitating the learning of intra- and inter-domain connections within a reduced semantic space.

In the model’s upper layers, particularly the top K blocks, a trio of domain-specific perceptron functions is introduced to process input representations derived from the masked MSA, which contain both time-domain and frequency-domain information. Depending on the task requirements, the inputs are either processed separately through the T-PCN and F-PCN or integrated directly through the unified perceptron (U-PCN). This architecture ensures that the model does not conflatet the domains, maintaining the integrity of the features in each domain and enabling a comprehensive learning of the interconnections between them. The outputs of i-th UTF transformer block are formulated as follows:

Hi= Concat(T-PCN(LN(H0 i T)) + H0 i T, F-PCN(LN(H0 i F)) + H0 i F), if T-PCN and F-PCN are used; U-PCN(LN(H0 i)) + H0 i, if U-PCN is used. (2)

Input representations H0T and H0F are time-domain and frequency-domain embeddings from the output of the masked MSA. The final outputs of the UTF transformer, referred to as epoch embeddings, are defined as O.

Pretraining stage
Our model introduces an innovative multi-pretext task learning framework, harnessing the strengths of well-established strategies, including contrastive learning, hard negative mining, and masked autoencoder techniques. This integrated approach leverages contrastive learning to refine the coherence and reinforce the complementarity of cross-domain features, while hard negative mining accelerates the process by enhancing the model’s ability to distinguish and align features across different domains. Additionally, the masked autoencoder approach focuses on reconstructing original signals from latent representations, uncovering the intricate structure and nuanced information inherent in the data.

In the process of contrastive learning, for a given batch size of N, the model embarks on a time-frequency contrast task, striving to identify matched pairs among N×N potential time-frequency pairs. The time-domain embeddings are processed through M stacked UTF transformer blocks with the T-PCN. Similarly, frequency-domain embeddings are processed through M stacked UTF transformer blocks with the F-PCN (Supplementary Fig. 1). For outputs O and O from batch i and batch j, the model leverages the time ([T_CLS]) and frequency ([F_CLS]) markers from the final output, representing OT and OF respectively, which encapsulate global time and frequency inter- and intra-relations. The contrastive matrices for time-to-frequency (T2F) and frequency-to-time (F2T) are calculated by measuring the similarity scores between time-domain and frequency-domain embeddings, and are defined as follows:

SimT2F=LN(OT)×LN(TP(OF))=σ, SimF2T=LN(OF)×LN(TP(OT))=σ, (3)

where TP denotes the transpose operation and σ represents a learnable temperature parameter. The contrastive loss, designed to enhance the similarity of time-frequency pairs within the same batch, is defined as:

Loss contrastive = (cid:4) 1/N log SimT i, 2 i F+log SimF i, 2 i T: (4)

Post this contrastive learning phase, the model, equipped with U-PCN at the top K blocks, identifies hard negative samples to perform time-frequency matching, thereby distinguishing time-domain and frequency-domain embedding pairs across different epochs (Supplementary Fig. 2). Hard negative samples are selected using a contrastive matrix. Specifically, the softmax function is applied to each T2F and F2T similarity score, transforming raw scores into a probability distribution:

softmax(SimT2F)=exp SimT, 2 F / P exp SimT, 2 F, softmax(SimF2T)=exp SimF, 2 T / P exp SimF, 2 T: (5)

Subsequently, the diagonal of the similarity matrices is masked to exclude correct pairs, and a stochastic sampling process generates a new batch of mismatched pairs. These pairs are then fed back into the model for binary classification with cross entropy loss, determining the matching status using the [T_CLS] marker. To ensure true robust feature representation learning in both time-domain and frequency-domain, batches from different GPUs are consolidated during the time-frequency matching and contrastive learning stages. The large batch size introduces a wider array of negative samples, compelling the model to develop more robust and distinct feature representations.

During the masked autoencoder process, our model reconstructs both the raw time-domain and frequency-domain signals. This dual reconstruction enables the model to assimilate the frequency composition and periodic nature of the signal, as well as to grasp the signal’s raw structure and its sequential dependencies. Specifically, the model processes the input time-domain embeddings, XInput, and frequency-domain embeddings, FInput, through a pair of randomly generated mask matrices. These matrices determine the specific patches targeted for reconstruction and are applied to the self-attention processing to make model focus on unmasked patches. Furthermore, at the top K blocks, we use the U-PCN to harmonize and integrate domains (Supplementary Fig. 3). The final outputs are then simply fed into a linear layer, and the reconstruction discrepancies are quantified using the F1 loss:

Loss MAE = jR(cid:4)GTj (6)

where R represents the reconstructed time-domain and frequency-domain signals, and GT denotes the time-domain and frequency-domain ground truth signals. The operation is performed within each respective domain. In each step of the pretraining phase, the three methods are applied concurrently within a shared transformer encoder. The total loss is computed as the sum of the losses from contrastive learning, hard negative binary classification, and reconstruction.

Fine-tuning stage
During the fine-tuning stage, different downstream tasks may use different task-specific heads to achieve optimal performance. For example, for sleep staging we use a Swin Transformer head. This process is highly modular: we always use the embeddings generated by SleepGPT and then feed these embeddings into the chosen task-specific head for further optimization.

For all downstream evaluations, SleepGPT was fine-tuned and tested in a dataset-specific manner. The model was trained on a portion of a given dataset and evaluated on a held-out split of the same dataset, or fine-tuned and evaluated using a k-fold cross-validation protocol within that dataset. This design ensures that each downstream comparison is based on within-dataset evaluation, enabling fair and interpretable results.

Attention gate
To consolidate the output along the time dimension, we employ an attention gate to compress information along the channel dimension. Initially, the output O is mapped into attentional hidden states. The final embeddings are then derived through a weighted summation of these attentional hidden states. Specifically, the final fused embeddings of the i-th patch are formulated via a weighted summation of O along the channel dimension:

O c i = ω i,c ×O i,c , (7)

where ω represents the attention weight at channel c. The attention weight is obtained by applying the softmax function to the attention score over:

ω i,c = exp(α i,c) / P exp(α i,c), (8)

where the α i,c is the scalar value. Formally, it can be derived by simple linear function:

α=σ(OW attn +b)W score (9)

with W attn and W score representing two trainable matrices, and σ denoting the activation function, here chosen to be the Tanh function for scaling the scores. b is the trainable bias.

1D Swin transformer
The Swin Transformer distinguishes itself from typical transformer architectures by replacing the standard multi-head self-attention with a shifted window-based self-attention. Unlike global self-attention in standard transformers, window-based transformers confine attention within fixed local windows, meticulously segmenting representations of consecutive epochs in a non-overlapping manner. To address the limitations of disconnected windows, the Swin Transformer introduces a shifted window partitioning approach, alternating between two partitioning configurations in consecutive transformer blocks. In contrast to the original Swin Transformer designed for two-dimensional image data, our approach adapts this architecture for one-dimensional data, such as time-series PSG signals, enabling efficient feature extraction tailored to the sequential nature of the input.

Assuming a window size of W=L×3, the transformation applied to the feature map from SleepGPT and attention gate Ω 2R(L(cid:2)P)×D0 achieves a resolution of R=P, restructuring Ω 2RR×W×D0 . The first Swin Transformer block employs regular window partitioning, while the subsequent Swin Transformer block adopts a shifted windowing configuration, rolling W/2 patches from the start window to the end. To produce the hierarchical representation, we merge the patches after two consecutive Swin Transformer blocks, by concatenating the features of each group of R neighboring patches. A linear layer is then applied to the merging patches to make output dimension to 2D0. A new two consecutive Swin Transformer blocks are applied to the output to get the final embeddings F 2R1×W×2D0 , where the window size is equal to the number of patches. The whole processing with shifted window partitioning approach is derived by

Ω1=PM(SW(Ω0)), F=SW(Ω1), (10)

where SW denotes two consecutive Swin Transformer blocks with alternating partitioning configurations, and PM symbolizes the patch merging block.

Automated sleep staging
Sleep staging stands as a fundamental component in sleep analysis, hinging on the dynamic interplay between information from the current epoch and its contextual surroundings. To address the multifaceted nature of this classification task, substantial prior research has employed advanced architectures Convolutional Neural Networks (CNNs), Long Short-Term Memory networks, and Transformers. These architectures are adept at integrating representations from sequential epochs, thereby capturing both the localized details and the broader contextual nuances of the data. In an innovative approach, we introduce the 1D Swin Transformer to enhance the extraction of information from sleep epochs. This model innovatively incorporates a hierarchical structure like CNNs for detailed local feature extraction, while simultaneously employing an attention mechanism to encompass global information. Specifically, given the input J=f([XInput;FInput],y)g L, where XInput and FInput are the embeddings of time-domain and frequency-domain respectively, L is the length of consecutive epochs. The stages of classification are represented by y i ∈{0,1,2,3,4}, signifying five classification stages in our study. We input these vectors through the UTF transformer blocks and at top K blocks we use U-PCN. The model outputs represent O=f[OT-stage;OF-stage]g L, where OT-stage 2RC×P×D and OF-stage 2RC×P×D represent time-domain and frequency-domain embeddings with their respective C channels and P patches, excluding the time ([T_CLS]) and frequency ([F_CLS]) markers. We then compress information along the channel dimension by attention gate. Subsequently, we concatenate the output of the consecutive epochs from the 1D Swin transformer attention gate Ωb = [O c 1 ;O c 2 ;:::;O c L] along the patch dimension. These are then reshaped into global hidden space Ω 2R(L(cid:2)P)×D0 to capture long-term dependencies across the entire sequence of epochs. The global hidden variables are subsequently processed by the 1D Swin Transformer to encode global information, resulting in the final embeddings F 2RP0×D0 , where P0 denotes the final length of these encoded global embeddings. Finally, to align the results with the length of sequential epochs, we apply adaptive 1D average pooling to F, followed by a linear layer for classification.

Evaluation on wearable data
Because SleepGPT was pretrained on PSG data, we selected a PSG channel that closely matches the placement of the single-channel wearable device, using the F3 channel for evaluation. Given that a large proportion of participants were diagnosed with obstructive sleep apnea, we additionally incorporated the SpO2 signal to enhance model performance. Specifically, the SpO2 features were injected into one layer of the UTF transformer block through a cross-attention mechanism, enabling the model to exploit oxygen desaturation information. Furthermore, we implemented a dual-task learning framework, optimizing both for sleep stage classification and the detection of oxygen desaturation events within each epoch. For the latter task, we formulated it as a binary classification problem, distinguishing epochs that contain oxygen desaturation events from those that do not.

Channels contribution visualization
In the sleep staging task, our model integrates local representations from SleepGPT into a global encoder by combining these representations from different channels into a single vector via an attention gate. This gate facilitates the visualization of epoch-level contributions of different channels to various sleep stages through attention weights ω. We employ heatmaps to display these attention weights, using checkpoints that have been fine-tuned on each dataset. Furthermore, we train our model using only a single channel to underscore the significance of individual channels when trained in isolation.

Leveraging overnight PSG recordings for sleep-related pathology classification
As SleepGPT processes signals at the granularity of a single epoch, subject-level tasks require the integration of data across an entire night of recordings. SleepGPT’s ability to extract rich feature representations allows us to employ a straightforward approach: features from epochs with the same channels and sleep stages are averaged to produce subject-level embeddings. For SSA classification, we employed a simple MLP classifier, leveraging the aggregated features. In contrast, for NFLE and RBD classification – where data is more limited and class distribution is imbalanced – a Random Forest classifier was used to achieve robust performance. To integrate information across different channels and sleep stages, we utilized weighted averaging of class probabilities predicted by SleepGPT for each stage and channel. This fusion strategy combines the contributions of diverse sleep stages and channels, yielding a final classification probability that enhances the overall accuracy and robustness of pathology classification.

Enhancement of sleep staging on small dataset by sleep data generation
We validated generative capability of the proposed model in both the SleepEDF-20 and MASS-SS2 datasets, with a small number of subjects. Sleep data generation process is applied to randomly selected subjects. We firstly apply masking to patches of both time-domain and frequency-domain signals over the same time period in an epoch (30 seconds). Subsequently we synthesize new, complete epochs to augment the dataset by SleepGPT. The new augmented datasets comprises both original and synthetic data, effectively doubling the size of the original dataset. Each experiment uses the same training configuration.

Method of sleep spindle detection
Our model adeptly identifies subtle yet critical events such as sleep spindles. Specifically, the SleepGPT’s output epoch embeddings are processed using only the C3 channel. A streamlined MLP is employed as the task head for sleep spindle detection, producing a sequence of binary labels that correspond to each input epoch. Consecutive labels marked as one are identified as predicted sleep spindles, provided their duration exceeds 0.5s. Predicted sleep spindles are classified as true positives if they meet a predefined overlap threshold based on the intersection over union66. Multiple overlaps are not allowed, ensuring that each predicted sleep spindle uniquely matches a true sleep spindle.

Sleep data generation in sleep spindle detection
To improve the performance on sleep spindle detection, we introduce an innovative PSG signal generation strategy. Initially, raw data are mapped to input embeddings. Subsequently, we randomly mask patches of epochs in both the time-domain and frequency-domain, ensuring that at least a quarter of the true sleep spindles are retained. Leveraging our model’s generative prowess, we synthesize new, complete epochs to augment the dataset, thereby enhancing the model’s performance in sleep spindle detection. After generating new epochs, we reverse the epochs with a probability of 0.5. We augment every selected epoch once in original dataset and the expanded dataset is subsequently used for model training.

Inference in sleep spindle detection
During the inference stage, each PSG recording is sampled consecutively from the raw dataset with a 50.0% overlap, and only the central half of the prediction points are utilized. These points are concatenated to form a continuous segment, while the peripheral half is discarded to mitigate border effects.

Post-processing is carried out to the final output from the model. Firstly, transform the point-wise probability outputs into binary predictions using several candidate detection thresholds, generated at equal intervals between 0.4 and 1.0. The results of binary predictions are obtained where a point is labeled 1 as the probability exceeds the thresholds, otherwise, assigned to 0, finally receiving alternative segments of consecutive ones and zeros. We follow the Spindle U-Net post-processing with binary predictions, removed the intervals which potential predictions are shorter than 0.5 seconds, and no other processing is applied to the binary predictions.

Details of pretraining
The pretraining of SleepGPT was conducted in multiple stages to progressively align and fuse time-domain and frequency-domain representations. We first performed multi-pretext training for 20 epochs, jointly optimizing three objectives: (1) time-frequency contrastive learning, (2) time-frequency matching with hard negative pairs, and (3) masked autoencoding. Training details and hyperparameters are listed in Supplementary Table 17.

We observed that the time-frequency matching with hard negative pairs substantially accelerated the alignment between the two domains. Specifically, to reduce the contrastive loss below 0.7, using matching required only about 5 epochs, whereas without matching this required approximately 15 epochs. After the alignment stabilized, we conducted a final stage of masked autoencoder training for 100 epochs. At this point, the time-frequency alignment had converged and the loss plateaued. Training details and hyperparameters are listed in Supplementary Table 18. To evaluate the effect of explicit alignment, we conducted ablation experiments comparing models trained with and without the time-frequency contrastive learning and matching step. Adding this alignment step resulted in improved downstream performance (Supplementary Fig. 9). For reference, we also implemented a masked CNN autoencoder as a lightweight baseline. While the CNN-based approach offered faster training and inference due to its lower computational complexity, it did not achieve performance comparable to the Transformer-based multi-pretext approach.

SleepGPT implementation
SleepGPT contains approximately 134 million parameters. The pretraining process was conducted on 32 NVIDIA V100 GPUs (32 GB each) and required about 33.3 hours in total; Fine-tuning was performed on 12 NVIDIA V100 GPUs (32GB each), with a processing speed of roughly 8 seconds for 4800 PSG epochs. During inference, SleepGPT runs efficiently on a single NVIDIA A100 GPU (80GB), processing approximately 5120 PSG epochs in about 3 seconds. These details illustrate that, while large-scale resources were used for pretraining, both fine-tuning and inference can be accomplished with moderate computational requirements, supporting SleepGPT’s feasibility for adaptation and deployment in clinical environments.

Peer review rounds
[{"round": 1, "reviewer_comments": {"reviewer_1": "In this manuscript, the authors propose SleepGPT, a multimodal generative pre-trained transformer model for sleep analysis tasks including sleep staging, spindle detection, and EEG generation. The authors demonstrate that SleepGPT achieves state-of-the-art performance on several public datasets. The work is promising and could have substantial impact in sleep medicine. However, I have a few clinical questions and suggestions to enhance its practical value:\n1.The authors demonstrated SleepGPT's strong generalization across various PSG channel configurations. From a clinical perspective, polysomnography is resource-intensive and less accessible for routine screening. Can the authors discuss the potential of adapting SleepGPT to lightweight wearable sleep-tracking devices, which typically record limited channels (e.g., single-channel EEG or peripheral physiological signals)? This discussion could greatly clarify the clinical applicability of the proposed method.\n2.SleepGPT shows promising results for spindle detection, an important biomarker for various neurological conditions. It would be interesting if the authors could briefly comment on the potential extensibility of SleepGPT to other clinically relevant sleep events, such as apnea episodes, arousals, or periodic limb movements.\n3.Clinical interpretability and transparency are important in facilitating physician acceptance of deep learning methods. Could the authors provide insights into the interpretability of SleepGPT’s decisions—specifically, can clinicians easily identify which EEG features or patterns contribute significantly to SleepGPT’s outputs?\n4.The authors evaluated SleepGPT on sleep spindle detection tasks and sleep-disorder classification scenarios, yet they did not include comparisons with specific benchmark models for these particular tasks. It would be helpful for the authors to justify this choice clearly, as the selection of appropriate baseline methods significantly impacts the interpretation of SleepGPT’s relative clinical value.\n5.Sleep stage classification is known to be clinically important, especially for diagnosing and managing conditions such as narcolepsy or insomnia. It would be beneficial if authors could briefly discuss whether SleepGPT has the capacity to classify or screen for specific sleep disorders based on abnormal sleep stage distributions or transitions observed over the entire sleep duration.\n6.Finally, as sleep medicine moves towards personalized patient care, it is important to consider patient-specific variations. Can SleepGPT adaptively fine-tune on individual patient recordings in a clinical setting (such as multiple visits or longitudinal monitoring)? Clarifying this would highlight its practical value for personalized medicine approaches.\n7.Currently, the manuscript lacks sufficient details on computational resources and training efficiency (e.g., training time, parameter counts, GPU usage) associated with model pre-training and fine-tuning. Given practical constraints in clinical settings, it would be helpful if the authors could provide explicit information about these aspects, as this will allow readers to better evaluate the model’s deployability in resource-constrained environments.\n8.In Line 890, the authors should check whether the time-domain perceptron is abbreviated U-PCN or T-PCN.\n9.In figure 1b, input embedding, please check whether the horizontal title should be time or frequency.", "reviewer_2": "The current code repository is insufficiently documented and lacks essential components for reproducibility and community use:\n❌ README File: The README is currently empty or missing critical content. It does not include any instructions for installation, required dependencies, data access, or how to run pretraining, fine-tuning, or inference scripts.\n❌ Setup and Environment: There is no environment configuration file (e.g., requirements.txt, environment.yml, or setup.py) to reproduce the environment in which the model was trained or tested.\nRecommendation\nThe authors should urgently improve the code repository by:\nProviding a detailed README.md with:\nClear setup instructions.\nStep-by-step guide for running pretraining, fine-tuning, and evaluation.\nDescriptions of input formats and expected data organization.\nIncluding a requirements.txt or equivalent environment configuration.", "reviewer_3": "It is reasonable to pursue a sleep data foundation model (FM) in this field, particularly to support sleep decoding tasks across diverse and variable data sources from wearables.\nThis ties into the main high-level critique of the paper, which focuses on the use of FMs for traditional PSG data. While the premise that sleep annotations are costly is valid, there is already a wealth of publicly available PSG data with annotations for many sleep events - including from the same cohorts used in this study. This raises the question: is unsupervised pre-training truly necessary in this context? I would have preferred to see the SleepGPT model trained on, and more importantly evaluated on, out-of-sample wearable data rather than PSG, which has been extensively studied for both sleep staging and spindle detection with ML.\nAnother major concern is that SleepGPT combines several recent technological advances for sleep decoding in a single system. While this integration may be valuable, it remains unclear which components contribute most to the model’s (demonstrated strong) performance on multiple tasks. Is it the dual-domain inputs, the time-frequency fusion mechanism, the 1D Swin Transformer, the self-supervised pre-training strategy, or the use of multiple input channels and modalities? Each of these components and methodologies are theoretically sound (but also, to my knowledge, previously published). While SleepGPT may indeed be more than the sum of its parts, an ablation study would greatly benefit the community by clarifying which elements or groups of elements are most effective. Without such analysis, future work built on this paper may introduce unnecessary complexity into downstream systems.\nBelow, find a more detailed list of specific strengths, some concrete points of criticisms that must be addressed, and suggestions for improvement and clarification:\n*\n* Positive aspects:\n*\n* The authors provide an open-source project with publicly available weights, which is a strong contribution to the community.\n* SleepGPT supports multiple downstream tasks - evaluated on sleep staging, pathology classification, sleep data generation, and spindle detection - and can be\nfine-tuned with minimal data.\n* The manuscriptincludes extensive evaluations, clearly reflecting significant effort.\n* The analysis of channel importance for sleep stages, and the influence of sleep stages on pathology classification, is a valuable addition.\n* The use of time-frequency contrastive learning for pre-training is methodologically sound (though not novel).\n* The model is compared to established baselines in each downstream domain; while not all comparisons are directly fair due to mismatched setups, the effort is appreciated.\n* An interesting application of SleepGPT’s generative capabilities is the augmentation of datasets, particularly for generating epochs with partially “real” sleep spindles.\n* Figures are clear and descriptive, and the manuscript is well written overall.\n*\n* Negative aspects, open questions:\n*\n* “However, existing AI-based models predominantly rely on supervised learning 53 frameworks, which depend heavily on annotated datasets. Sleep data annotation is expensive 54 and has emerged as an important bottleneck to progress in sleep research.” (l. 52-): This requires a more differentiated discussion. For example,this is not a limitation anymore in the domain of sleep staging, where models such as U-Sleep [7] exist that work across measurement protocols, hardware, and patent populations, and do not require fine-tuning. Here the field has moved beyond the need to have a model specialized/fine-tuned for a clinic.\n* “Fixed-channel dependencies in current models limit their ability to integrate heterogeneous PSG recordings collected using different equipment and setups, restricting the scope of multi-dataset training and adaptation”. This is not correct for sleep staging, where models such as U-Sleep [7] and GSSC presented in\nHanna J, Flöel A. An accessible and versatile deep learning-based sleep stage classifier. Front Neuroinform. 2023 Mar 2;17:1086634. doi: 10.3389/fninf.2023.1086634. PMID: 36938361; PMCID: PMC10017438.\nwork with almost an arbitrary number of channels and channel combinations.\n* “Finally, integrating time-domain and frequency-domain features remains a significant challenge in sleep decoding. Both domains are essential for a comprehensive understanding of sleep signals”: Why? This statement lacks support. The current state-of-the-art in sleep staging does not require a frequency embedding. Deep learning systems can figure such an embedding out themselves; even in the domain of speech processing research is moving away from frequency embeddings. The value of “dual-domain” inputs is also unclear. The explanation that time windows are treated separately for “granular analysis of short-term frequency dynamics” is not intuitive. Why can’t a combined time-frequency map be used for this purpose? Is this tied to channel subset processing at inference? More explanation would help.\n* An “ablation study” showing the performance of the proposed system just using the time domain is mandatory.\n* The results section is not very clearly structured, such an evaluation could hide somewhere in the many tables.\n* “U-Sleep [7] is a model that utilizes a convolutional-only architecture for large-scale, cross-dataset supervised training, achieving sleep staging accuracy comparable to that of human experts. Although direct comparisons are challenging due to differing training and evaluation setups, we have included results for U-Sleep across the four datasets we analyzed (Supplementary Table 9).”: If the results cannot be compared, no comparison should be presented. This part lacks a detailed discussion of what the differences in the evaluation protocols were. Furthermore, “Supplementary Table 9| shows a “Comparison among different contextual encoders.”, not considering U-Sleep.\nThat is all very confusing: The caption of “Supplementary Table 8” states “Performance of U-Sleep on four datasets using a hold out evaluation scheme.”, but Supplementary Table 8 shows something different. U-Time is mentioned in Supplementary Table 7, but U-Time and U-Sleep are different. This part must be considerably revised.\nSome comparisons on downstream tasks appear to be misleading. For example, U-Sleep is evaluated on MASS without fine-tuning, while SleepGPT (as I understand) is fine-tuned on a subset of studies from that same dataset. SleepGPT also benefits from additional input modalities (e.g., EMG), making comparisons somewhat uneven (although EMG is later shown to not have great influence on sleep staging; an important observation in itself aligning with previous research).\n* The usefulness of a foundation model in practice must be discussed in a more differentiated way. For almost all clinics,a model that works out of the box because it is robust (GSSC, U-Sleep) is preferable to a model that requires fine-tuning. Most clinics do not have the resources to fine-tune a deep learning model on their data.\n* Are the sleep spindle annotations by experts 1 and 2 of the freely available MASS-SS2 data set available? This would be a good community service. If not, why are they not provided alongside the study?\n* There is an important difference between percent (%) and percentage points (p.p.). Going from 50% to 60% is an increase by 10 p.p., not by 10%.\n* The discussion of the results seems to be biased. For example, when discussing the effect of data augmentation in the sleep spindle tasks, the increase in precision for expert 2 is highlighted, however, this comes with a drop in recall. It seems that the improvement in precision is 0.9 p.p. (and not 1% as stated in the manuscript) and a drop in recall of 0.7 p.p.\n* “Although U-Sleep employs an adaptive channel strategy, its training is limited to using only one EEG and one EOG channel at a time. This approach suggests that U-Sleep's adaptability to multi-channel data isn't truly flexible since it requires multiple evaluations for multi-channel configurations, increasing time costs and failing to capture the relationships between different PSG channels.” (line 475): These statements lack support and may not be correct. Why is the approach not highly flexible? How is the presented approach more flexible? U-Sleep and GSSC work well for all kinds of channel combinations, even if they are wrongly labelled, see also\nFiorillo, L., Monachino, G., van der Meer, J. et al. U-Sleep’s resilience to AASM guidelines. npj Digit. Med. 6, 33 (2023).\nhttps://doi.org/10.1038/s41746-023-00784-0\nIn general The limitation attributed to “fixed channel dependencies” is somewhat overstated. As shown in U-Sleep and GSSC, high correlation among PSG channels allows simple channel-swap augmentations to build robustness to missing or variable channel setups.\n* The statement “increasing time costs and failing” seems to be very misleading and lacks quantitative support. The proposed SleepGPT transformer architecture is very complex. The authors must provide a wall -clock time comparison of U-Sleep and SleepGPT. This is mandatory. This comparison should include both GPU and CPU environments.\nMore general, SleepGPT appears computationally heavy compared to CNN-based approaches. Could similar performance be achieved using a simpler masked CNN autoencoder? A comparison with such lightweight baselines would be useful.\n* The model description in the methods section could be clearer. However, the model is complex and uses advanced concepts. It would be interesting for the reader if it would be explained in more detail how the transformer architecture makes use of different channels. How is the channel information aligned and fused, given that the number of channels can vary.\n* The claim that no other foundation model exists is somewhat overstated. Several self-supervised pre-trained models for EEG already exist , for example\nQ. Xiao et al., \"Self-Supervised Learning for Sleep Stage Classification with Predictive and Discriminative Contrastive Coding,\" ICASSP 2021 - 2021 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), Toronto, ON, Canada, 2021, pp. 1290-1294, doi: 10.1109/ICASSP39728.2021.9414752.\nThapa R, Kjær MR, He B, Covert I, Moore H, Hanif U, Ganjoo G, Westover MB, Jennum P, Brink-Kjær A, Mignot E, Zou J. A Multimodal Sleep Foundation Model Developed with 500K Hours of Sleep Recordings for Disease Predictions. medRxiv [Preprint]. 2025 Feb 9:2025.02.04.25321675. doi: 10.1101/2025.02.04.25321675. PMID: 39974074; PMCID: PMC11838666.\nX. Jiang, J. Zhao, B. Du and Z. Yuan, \"Self-supervised Contrastive Learning for EEG-based Sleep Staging,\" 2021 International Joint Conference on Neural Networks (IJCNN), Shenzhen, China, 2021, pp. 1-8, doi: 10.1109/IJCNN52387.2021.9533305.\nThat said, SleepGPT may be the most extensive and rigorously evaluated (peer-reviewed) effort in this space.\n* The authors state that 59,267 hours from 5,132 subjects represents the largest dataset for self-supervised learning. While this may be true specifically for self-supervised methods in PSG, many supervised models have been trained on even larger PSG datasets. Given the potential of self-supervision, the question arises: why not use even larger unannotated datasets, including from wearable devices where high quality annotations may not be available? The authors should address this point in the manuscript.\n* Despite the large dataset used, several publicly available datasets (e.g., from NSRR, PhysioNet) are omitted. Including them would increase both the robustness and applicability of the model.\n* It’s unclear to me how the model handles varying input channel counts. Pre-training seems to use 8 channels, and although the text mentions single-channel fine-tuning for downstream tasks several times, the figures suggest multiple channels (with a concat operation to combine channel representations). Please clarify both in text and visuals.\n* The fine-tuning procedure for downstream tasks also lacks detail more generally. For instance, was SleepGPT fine-tuned on part of the evaluation dataset or trained on other datasets for the same task and then evaluated on entirely new cohorts? This is especially important for interpreting downstream comparisons with methods that were not fine-tuned on the same cohort.\n* Training details and hyperparameters seem to be missing. A summary table with optimization parameters per training stage would be very helpful.\n* The code repository is public, but is missing a README file and is not documented even in the code (no comments, docstrings or type hints). This makes it non-trivial to use the current code base or look up answers to some of the questions raised here. The authors testify in the ML checklist that a README is available in the repository, so this should be added and (preferably) the code cleaned prior to publication.\n* The need for a “unified time-frequency fusion mechanism” is not clearly justified. Couldn’t deep convolutional networks learn both time and frequency features inherently? Please elaborate on the rationale.\n* Processing only 30-second windows during pre-training may be limiting. Although a method is provided for aggregating representations across time during downstream tasks, a broader context during pre-training could improve those representations as well.\n* Regarding the data generation experiment: Why are only four test studies used? As authors mention the datasets contain a total of 19 and 20 studies, respectively, with 12 used for training, there should be 7–8 left. Were some used for validation or excluded? Please clarify.\n* This sentence is unclear: “By accurately determining each PSG channel’s influence, clinicians can devise more personalized treatment strategies...” It's hard to see how this would be applied at the individual patient level. Wouldn’t clinicians just use the best-performing channel based on prior retrospective analysis in clinical practice?\n*\n* Minor comments:\n*\n* Abstract: It is not clear what is meant by a “fixed-channel architecture”\n* Lines 56-56: The PSG data is more similar to speech signals, thus, in addition to 9-11, it is suggested to refer also to Abdelrahman Mohamed et al. Self-Supervised Speech Representation Learning: A Review. IEEE Journal of Selected Topics in Signal Processing, 16(6):1179–1210, 2022\n* “Inspired by …” starting in line 444 is not a full sentence.\n* Consider removing loaded or promotional language, such as “we innovatively…”", "reviewer_4": "I co-reviewed this manuscript with one of the reviewers who provided the listed reports. This is part of the Nature Communications initiative to facilitate training in peer review and to provide appropriate recognition for Early Career Researchers who co-review manuscripts."}, "author_response": "Response to the Reviewers\nThe reviewers' comments are in italics, and our responses are in boldface. Additionally,\nall changes in the manuscript are written in blue.\nWe sincerely thank the reviewers for their thoughtful comments on our\nmanuscript. We found the feedback to be extremely valuable and have made\nsignificant improvements to our manuscript as a result. Our detailed point-by-\npoint responses are presented below.\nReviewers' comments:\nReviewer #1:In this manuscript, the authors propose SleepGPT, a multimodal\ngenerative pre-trained transformer model for sleep analysis tasks including sleep\nstaging, spindle detection, and EEG generation. The authors demonstrate that\nSleepGPT achieves state-of-the-art performance on several public datasets. The work\nis promising and could have substantial impact in sleep medicine.\nWe would like to thank the reviewer for the overall positive comments on our work.\nHowever, I have a few clinical questions and suggestions to enhance its practical value:\nComment 1:The authors demonstrated SleepGPT's strong generalization across\nvarious PSG channel configurations. From a clinical perspective, polysomnography is\nresource-intensive and less accessible for routine screening. Can the authors discuss\nthe potential of adapting SleepGPT to lightweight wearable sleep-tracking devices,\nwhich typically record limited channels (e.g., single-channel EEG or peripheral\nphysiological signals)? This discussion could greatly clarify the clinical applicability\nof the proposed method.\nWe thank the reviewer for this important comment regarding the clinical\napplicability of SleepGPT in resource-limited settings. We fully agree that\nstandard PSG is resource-intensive and less accessible for routine large-scale\nscreening.\nTo address this comment, we have conducted additional experiments using a\nwearable single‑channel EEG device. Specifically, we used the UMS dataset\n(Supplementary Table 1), which includes 179 Chinese adults who underwent\novernight studies with a single‑channel, EEG‑based wearable forehead recorder\n(UMindSleep, EEGSmart Co., Ltd.) simultaneously with standard PSG.\nConsistent with previous study1, we combined N1 and N2 stages into light sleep\nwhile classifying N3 as deep sleep. Using the commercial software provided by\nthe device manufacturer, automatic sleep staging on the UMS dataset achieved an\naccuracy of 76.0% across subjects, with staging labels manually rated based on\nPSG.\nIn addition, oxygen saturation (SpO ) signals are also available from the wearable\n2\nforehead recorder. We have further incorporated SpO signals into the model,\n2\nwhich enhance the staging performance (Supplementary Table 11).\nSleepGPT not only achieves competitive performance under a 4‑class setting but\nis also capable of performing standard 5‑class classification. For example, under\nthe 5‑class setting, SleepGPT achieves an overall staging accuracy of 76.6%\n(Supplementary Table 12).\nThese findings demonstrate that SleepGPT can be deployed not only in\ncomprehensive PSG environments but also in simplified configurations, such as\nthose provided by wearable devices, thereby improving accessibility for routine\nscreening and home-based monitoring. We have added these experimental results\nto the Results section (pages 13-14, lines 274-288; Supplementary tables 11-12),\nprovided relevant discussions (page 23, lines 497-498), and included the\nexperimental setup in the Methods section (pages 52-53, lines 1135-1145) in the\nrevised manuscript.\nComment 2.SleepGPT shows promising results for spindle detection, an important\nbiomarker for various neurological conditions. It would be interesting if the authors\ncould briefly comment on the potential extensibility of SleepGPT to other clinically\nrelevant sleep events, such as apnea episodes, arousals, or periodic limb movements.\nBeyond spindle detection, SleepGPT is designed as a generalizable backbone that\ncan be extended to other clinically relevant sleep events. In principle, the same\npretraining framework and multi‑channel fusion strategy can be adapted for\nevent‑level detection tasks. For example, by fine‑tuning on appropriately labeled\ndatasets, SleepGPT could be extended to detect apnea episodes, arousals, or\nperiodic limb movements. These events demonstrate distinct temporal and\nspectral signatures embedded in PSG signals, and our architecture’s ability to\ncapture both time‑domain and frequency‑domain patterns make such adaptations\nfeasible. We have added a brief discussion in the revised manuscript to highlight\nthis potential extensibility (page 26, lines 553-560).\nComment 3.Clinical interpretability and transparency are important in facilitating\nphysician acceptance of deep learning methods. Could the authors provide insights into\nthe interpretability of SleepGPT’s decisions—specifically, can clinicians easily identify\nwhich EEG features or patterns contribute significantly to SleepGPT’s outputs?\nWe agree with the reviewer that interpretability and transparency are essential for\nclinical adoption. Several mature interpretability techniques can be readily\napplied to SleepGPT to help clinicians understand its decision process such as\nattention visualization2 and Integrated Gradients3.\nBeyond highlighting EEG features or patterns, our model’s architecture also\nincorporates channel‑wise attention mechanisms, enabling interpretability at the\nchannel level. Through learned channel attention weights, clinicians can further\nidentify which EEG channels are most informative for a given prediction.\nWe have added a discussion of these techniques and their clinical implications in\nthe revised manuscript to clarify how SleepGPT’s decisions can be interpreted and\ntrusted in practice (page 23, lines 492-497).\nComment 4.The authors evaluated SleepGPT on sleep spindle detection tasks and\nsleep-disorder classification scenarios, yet they did not include comparisons with\nspecific benchmark models for these particular tasks. It would be helpful for the authors\nto justify this choice clearly, as the selection of appropriate baseline methods\nsignificantly impacts the interpretation of SleepGPT’s relative clinical value.\nWe thank the reviewer for this important comment. There are two main\nconsiderations why we did not include direct comparisons with specific deep\nlearning benchmark models for spindle detection and sleep‑disorder classification:\n1. Limited availability of open‑source deep learning baselines\nFor these two tasks, existing open‑source implementations of deep learning\nmethods are very limited. Most publicly available baselines are either traditional\nmachine‑learning approaches (e.g., feature‑engineering with classical classifiers)\nor are not released with reproducible code or pre‑trained weights, making fair\ndirect comparison difficult.\n2. Historical focus on machine learning methods in prior research\nThe majority of prior published work on spindle detection and sleep‑disorder\nclassification has employed classical machine learning techniques rather than\nend‑to‑end deep learning models. As a result, widely accepted deep learning\nbenchmarks for these specific tasks have not yet been established.\nWe have now clarified these points in the revised manuscript (page 27, lines 578-\n582) to justify our choice and to emphasize that, despite the lack of direct deep\nlearning baselines, SleepGPT’s design and results provide a valuable step toward\nestablishing robust benchmarks for these clinically relevant tasks.\nComment 5.Sleep stage classification is known to be clinically important, especially for\ndiagnosing and managing conditions such as narcolepsy or insomnia. It would be\nbeneficial if authors could briefly discuss whether SleepGPT has the capacity to classify\nor screen for specific sleep disorders based on abnormal sleep stage distributions or\ntransitions observed over the entire sleep duration.\nSleepGPT can be extended to classify or screen for specific sleep disorders by\nleveraging abnormal sleep stage distributions over the entire sleep duration. In the\nsleep‑disorder classification experiments (for example, distinguishing patients\nwith sleep apnea), we already utilize global features derived from the overall\ndistribution of sleep stages throughout the recording. These aggregated\ndistributional patterns often reflect pathological sleep architecture and therefore\ncontribute meaningfully to disorder classification. Although our current work\nfocuses on distribution‑based features, incorporating additional temporal\ndynamics such as stage transition patterns remains a promising direction for\nfuture studies and could further enhance SleepGPT’s clinical utility.\nWe have added relevant discussion to the revised manuscript (page 24, lines 520-\n524).\nComment 6.Finally, as sleep medicine moves towards personalized patient care, it is\nimportant to consider patient-specific variations. Can SleepGPT adaptively fine-tune\non individual patient recordings in a clinical setting (such as multiple visits or\nlongitudinal monitoring)? Clarifying this would highlight its practical value for\npersonalized medicine approaches.\nSleepGPT can be adaptively fine‑tuned on individual patient recordings in a\nclinical setting, such as across multiple visits or during longitudinal monitoring.\nBecause SleepGPT is pretrained as a general foundation model on large‑scale PSG\ndatasets, it provides a strong initialization that can be efficiently adapted with a\nsmall amount of patient‑specific data. In practice, this means that after\ndeployment in a clinic, SleepGPT can be incrementally fine‑tuned or updated as\nmore recordings from the same patient become available, allowing the model to\nbetter capture patient‑specific sleep patterns and variations over time. This\ncapability is particularly valuable for personalized medicine approaches, where\nindividualized longitudinal adaptation can support more accurate staging, event\ndetection, and disorder screening.\nWe have added relevant discussion to the revised manuscript (page 23, lines 486-\n490).\n7.Currently, the manuscript lacks sufficient details on computational resources and\ntraining efficiency (e.g., training time, parameter counts, GPU usage) associated with\nmodel pre-training and fine-tuning. Given practical constraints in clinical settings,\nit would be helpful if the authors could provide explicit information about these aspects,\nas this will allow readers to better evaluate the model’s deployability in resource-\nconstrained environments.\nWe appreciate the reviewer’s suggestion and have added explicit details on\ncomputational resources and training efficiency to the revised manuscript (page\n57, lines 1234-1242).\nSleepGPT contains approximately 134 million parameters. Pre‑training was\nconducted on 32 NVIDIA V100 GPUs (32 GB) and required about 33.3 hours in\ntotal. Fine‑tuning was performed on 12 NVIDIA V100 GPUs (32 GB), with a\nprocessing speed of roughly 8 seconds for 4,800 PSG epochs. During inference, the\nmodel runs efficiently on a single NVIDIA A100 GPU (80 GB), processing\napproximately 5,120 PSG epochs in about 3 seconds. These details illustrate that,\nwhile large‑scale resources were used for pre‑training, both fine‑tuning and\ninference can be accomplished with moderate computational requirements,\nsupporting SleepGPT’s feasibility for adaptation and deployment in clinical\nenvironments.\n8.In Line 890, the authors should check whether the time-domain perceptron is\nabbreviated U-PCN or T-PCN.\nWe thank the reviewer for carefully pointing this out. We have double‑checked the\nmanuscript and confirmed that the correct abbreviation should be T‑PCN\n(time‑domain perceptron network), not U‑PCN. We have corrected this problem\nensured consistency throughout the revised manuscript (page 45, lines 970-971).\n9.In figure 1b, input embedding, please check whether the horizontal title should be\ntime or frequency.\nWe appreciate the reviewer’s careful examination. We have checked Fig. 1b and\nconfirmed that the horizontal axis in the input embedding panel should indeed be\nlabeled time.\nReviewer #2 General Assessment\nThis manuscript introduces SleepGPT, a unified, dual-domain foundation model for\nsleep decoding based on generative pretrained transformers. The model is trained on\nan impressive 84,884 hours of PSG recordings and evaluated across a wide range of\ndownstream tasks including sleep staging, pathology classification, sleep spindle\ndetection, and sleep data generation. The paper addresses three major challenges in\ncurrent sleep decoding approaches: reliance on fixed-channel supervised models,\nlimited generalization, and domain-specific architectures.\nOverall, this is a timely, well-motivated, and impactful work that advances the field of\nlarge-scale, selfsupervised sleep signal analysis using foundation models. However,\nseveral areas require clarification, additional validation, and significant improvements,\nespecially in the code documentation and reproducibility domain, before it can be\nconsidered for publication.\nMajor Strengths\n1. Scale and Scope: Pretraining on over 84,000 hours of multi-channel PSG from 8,198\nsubjects is a major strength and likely the largest effort to date in sleep decoding\nresearch.\n2. Dual-Domain Architecture: The use of both time- and frequency-domain features\nwithin a unified Transformer framework (UTF) is novel. Domain-selecting perceptrons\nadd an additional layer of adaptability, allowing the model to dynamically emphasize\ndomain-specific characteristics.\n3. Channel-Adaptive Mechanism: The proposed masked multi-head attention and\nchannel-wise convolutions allow the model to flexibly handle varying PSG channel\nconfigurations, which is important for real-world deployment.\n4. Multi-Task Generalization: The model shows broad applicability across multiple\nclinically relevant downstream tasks, suggesting its potential as a general-purpose tool\nin sleep research.\nWe thank the reviewer for the overall positive and constructive comments on our\nwork.\nMajor Concerns and Recommendations\n1. Reproducibility and Code Usability – Needs Major Improvement\n The publicly released code lacks critical elements necessary for replication\n Recommendation: For this work to serve the community and fulfill the claims of\nbeing a foundation model, the authors must:\n◦ Provide a comprehensive README with installation, setup, and running\ninstructions.\n◦ Include scripts for pretraining and fine-tuning, with example configurations.\n◦ Share trained model checkpoints and data preprocessing pipelines.\n◦ Consider offering a demo notebook or Colab for at least one downstream task.\nWe appreciate the reviewer’s comment regarding reproducibility and code\nusability. We have addressed this comment in the revised submission and updated\nour public repository accordingly. Specifically, we have already:\n Added a comprehensive README that includes detailed installation\ninstructions, environment setup steps, and clear guidelines for running both\npretraining and fine‑tuning pipelines.\n Included complete scripts for pretraining and fine‑tuning, together with\nexample configuration files that allow direct replication of our main\nexperiments.\n Shared trained model checkpoints as well as the data preprocessing pipelines\nused in our experiments.\n Provided a demo notebook demonstrating how to run SleepGPT on a\ndownstream task (e.g., sleep staging) with minimal setup.\n2. Lack of Comparative Baselines\n While the manuscript claims superior performance, it does not compare SleepGPT\nagainst strong recent baselines such as Cross-modal SleepTransformer, or\nSleepXViT.\n Recommendation: Include quantitative comparisons on benchmark datasets with\nexisting stateof-the-art models to validate the claim of improved performance.\nWe appreciate the reviewer’s valuable suggestion. In the revised manuscript, we\nhave added quantitative comparisons with recent comparative baselines,\nincluding Cross‑modal SleepTransformer and SleepXViT, on the benchmark sleep\nstaging datasets. These results are reported in the Results section and\ncorresponding tables (Supplementary Table 7), further validating the claim that\nSleepGPT achieves superior performance relative to existing state‑of‑the‑art\nmodels (pages 10-11, lines 218-222) in this revision.\n3. Pretraining Task Design Not Fully Explained\n The authors mention multiple pretext tasks (contrastive learning, matching,\nmasked autoencoding) but do not describe how these are implemented, combined, or weighted during\ntraining.\n Recommendation: Provide implementation details for each pretext task, and\nideally include ablation studies showing their individual contribution to model\nperformance.\nWe appreciate the reviewer’s recommendation. We have updated the Methods\nsection in this revision to provide detailed implementation descriptions for each\npretext task (contrastive learning, matching, and masked autoencoding),\nincluding how they are integrated and weighted during training (pages 46-48, lines\n989-1048) and details of each pretext task (pages 56-57, lines 1212-1232;\nSupplementary Tables 17-18). To further clarify their contributions, we have\nconducted additional ablation studies and added relevant results in the revised\nmanuscript to strengthen the transparency and validation of our method\n(Supplementary Figs. 7, 9) in this revision.\nSpecifically, because SleepGPT is designed as a generative foundation model, the\nmasked autoencoder objective is fixed as a core component. We performed\nablation experiments on the SHHS dataset using a slightly smaller model (8\nTransformer blocks) to compare multi‑pretext training with masked autoencoding\nalone. The results show that incorporating multiple pretext tasks leads to\nimproved downstream performance compared to using only the masked\nautoencoder.\nAdditionally, we included a pretraining experiment with a simple CNN\nautoencoder as a lightweight baseline, which demonstrated that such a model\ncould not match the performance achieved by the Transformer‑based\nmulti‑pretext approach.\n4. Synthetic Data Generation Pipeline Underdetailed\nThe term “augmented dataset” is used to describe a dataset extended with synthetic\ndata generated by the model. However, no methodology or validation for this synthetic\ndata is provided.\nRecommendation: Describe the generation process, quality metrics, and how synthetic\nsamples affect downstream task performance.\nWe appreciate the reviewer’s valuable suggestion. In the revised manuscript, we\nhave provided detailed descriptions of the generation process for the synthetic\ndata, including how PSG epochs are reconstructed and sampled (page 54, lines\n1169-1176). We have also quantitatively analyzed the reconstruction quality of\nPSG epochs to validate the fidelity of the generated data (pages 16-18, lines 349-\n393) in this revision.\nFurthermore, we have evaluated the impact of incorporating synthetic data into\ndownstream tasks. In this revision, augmented datasets combining real data with\nsynthetic samples generated by SleepGPT were used to train models for both sleep\nstaging (pages 18–20, lines 395–426) and spindle detection (pages 21–22, lines 456–\n478). The results demonstrate measurable performance improvements compared\nwith training on the real datasets alone.\n5. Embedding Section Clarity\n The dual-domain embedding explanation is detailed, but the presentation is\nmathematically dense and difficult to follow in parts.\n The use of symbols like PT, PF, r, l, h, and composite embeddings like H0 could\nbenefit from a summarizing table or diagram for clarity.\n Recommendation: Consider including a figure showing how a single PSG epoch is\ntokenized and encoded into the UTF transformer, with step-by-step explanation\nfrom raw signal to final input embeddings.\nWe appreciate the reviewer’s comment regarding the clarity of the embedding\nsection. As the reviewer recommended, we have added a summarizing table in this\nrevision (Supplementary Table 16) that lists the key symbols together with their\ndefinitions and roles in the model to improve readability. In addition, we have\nadded Supplementary Fig. 6 in this revision that visually illustrates how a single\nPSG epoch is processed—from the raw time‑domain and frequency domain\nsignals, through tokenization and embedding, to the final UTF transformer input\nembeddings. This figure provides a step‑by‑step explanation that complements the\nmathematical description. We have incorporated these figures and tables into the\nrevised manuscript to enhance clarity and accessibility (pages 42-43, lines 910-936;\nSupplementary Fig. 6).\n6. Computational Resources and Practicality Not Addressed\n Given the model’s scale, the paper should provide information on:\n◦ Number of parameters.\n◦ Pretraining hardware and time.\n◦ Inference efficiency and resource requirements.\n Recommendation: Include a performance and resource profile to help readers\nunderstand the model’s practicality in clinical and research settings.\nWe appreciate the reviewer’s suggestion and have added explicit details on\ncomputational resources and training efficiency to the revised manuscript (page\n57, lines 1234-1242), and as below.\nSleepGPT contains approximately 134 million parameters. Pre‑training was\nconducted on 32 NVIDIA V100 GPUs (32 GB each) and required about 33.3 hours\nin total. Fine‑tuning was performed on 12 NVIDIA V100 GPUs (32 GB each), with\na processing speed of approximately 8 seconds for 4,800 PSG epochs. During\ninference, the model runs efficiently on a single NVIDIA A100 GPU (80 GB),\nprocessing approximately 5,120 PSG epochs in about 3 seconds. These details\nillustrate that, while large‑scale resources were necessary for pre‑training, both\nfine‑tuning and inference can be accomplished with moderate computational\nrequirements, facilitating SleepGPT’s practicality for adaptation and deployment\nin clinical and research settings.\nMinor Issues and Clarifications\n Terminology like “dual-domain” and “time-frequency” should be defined clearly\nand used consistently throughout the manuscript.\n Patch extraction strategy should be justified with details on window sizes, overlap,\nand the rationale for separate time and frequency patch handling.\n Clarify whether task-specific heads are used during downstream fine-tuning and\nhow modular this process is across tasks.\nWe thank the reviewer for these helpful suggestions.\n Terminology: We have carefully reviewed the manuscript and revised all\nrelevant sections to consistently use the term time-frequency throughout.\n Patch extraction: We have added a new figure to illustrate the patch token\nextraction process and provided additional explanation on the rationale for\nhandling time‑domain and frequency‑domain patches separately before\nfusion (page 43, lines 938-943; Supplementary Fig. 6) in this revision.\n Task‑specific heads: We have also added a clear description of the task‑specific\noutput heads used during downstream fine‑tuning, explaining how these\nheads can be modularly attached to the shared backbone for different tasks\n(pages 48-49, lines 1050-1060) in this revision.\nFinal Recommendation: Minor Revision This is a promising and innovative manuscript\nthat could serve as a valuable foundation for future sleep signal research. However, the\ncurrent version lacks sufficient code support, comparative benchmarking, and\nmethodological transparency to fully support its claims. A revision focusing on\nimproving reproducibility, adding baseline comparisons, and elaborating on critical\ntechnical components would significantly strengthen the paper.\nWe appreciate the reviewer’s positive comments and have revised the manuscript\nas the reviewer suggested.\nReviewer #2 (Remarks on code availability):\nThe current code repository is insufficiently documented and lacks essential\ncomponents for reproducibility and community use:\n❌ README File: The README is currently empty or missing critical content. It does\nnot include any instructions for installation, required dependencies, data access, or\nhow to run pretraining, fine-tuning, or inference scripts.\n❌ Setup and Environment: There is no environment configuration file (e.g.,\nrequirements.txt, environment.yml, or setup.py) to reproduce the environment in which\nthe model was trained or tested.\nRecommendation\nThe authors should urgently improve the code repository by:\nProviding a detailed README.md with:\nClear setup instructions.\nStep-by-step guide for running pretraining, fine-tuning, and evaluation.\nDescriptions of input formats and expected data organization.\nIncluding a requirements.txt or equivalent environment configuration.\nWe appreciate the reviewer’s insightful comments and recommendations. We have\naddressed the comments raised by significantly improving the code repository for\nreproducibility and community use. Specifically, we have added a detailed\nREADME.md that includes:\n Clear setup instructions, including installation and dependencies.\n A step-by-step guide for running pretraining, fine-tuning, and evaluation\nscripts.\n Descriptions of input formats and expected data organization.\nAdditionally, we have included an environment configuration file\n(requirements.txt) to ensure that the environment in which the model was trained\nor tested can be easily reproduced. These updates streamline the codebase for\neasier use and understanding, enabling seamless adoption by the research\ncommunity.\nReviewer #3 (Remarks to the Author):\nIt is reasonable to pursue a sleep data foundation model (FM) in this field, particularly\nto support sleep decoding tasks across diverse and variable data sources from\nwearables.\nThis ties into the main high-level critique of the paper, which focuses on the use of FMs\nfor traditional PSG data. While the premise that sleep annotations are costly is valid,\nthere is already a wealth of publicly available PSG data with annotations for many\nsleep events - including from the same cohorts used in this study. This raises the\nquestion: is unsupervised pre-training truly necessary in this context? I would have\npreferred to see the SleepGPT model trained on, and more importantly evaluated on,\nout-of-sample wearable data rather than PSG, which has been extensively studied for\nboth sleep staging and spindle detection with ML.\nAnother major concern is that SleepGPT combines several recent technological\nadvances for sleep decoding in a single system. While this integration may be valuable,\nit remains unclear which components contribute most to the model’s (demonstrated\nstrong) performance on multiple tasks. Is it the dual-domain inputs, the time-frequency\nfusion mechanism, the 1D Swin Transformer, the self-supervised pre-training strategy,\nor the use of multiple input channels and modalities? Each of these components and\nmethodologies are theoretically sound (but also, to my knowledge, previously\npublished). While SleepGPT may indeed be more than the sum of its parts, an ablation\nstudy would greatly benefit the community by clarifying which elements or groups of\nelements are most effective. Without such analysis, future work built on this paper may\nintroduce unnecessary complexity into downstream systems.\nWe appreciate the reviewer’s insightful comment on our study.\nRegarding evaluation and pretraining solely on traditional PSG data, we have\nadded new experiments using data acquired with a single-channel EEG wearable\ndevice (UMindSleep, EEGSmart Co., Ltd.) and validated SleepGPT’s pretraining\nis designed to improve cross-task and cross-device generalizability.\nRegarding comment about architectural complexity and the lack of ablation\nstudies, we have conducted comprehensive ablation experiments to isolate the\ncontribution of each model component. Specifically, we evaluated the following\nconfigurations:\n SleepGPT (dual encoder): Uses separate time-domain and frequency-domain\nencoders without the unified Transformer architecture.\n SleepGPT (EEG only): Utilizes EEG channels, excluding other PSG\nmodalities.\n SleepGPT (time-domain only): Uses only time-domain inputs.\n SleepGPT (frequency-domain only): Uses only frequency-domain inputs.\n SleepGPT (without time-frequency contrastive learning and matching):\nRemoves the time-frequency contrastive learning and matching during\npretraining.\n Masked CNN autoencoder: A lightweight CNN-based model.\nFull point-to-point responses addressing these and other comments are provided\nin the following section.\nBelow, find a more detailed list of specific strengths, some concrete points of criticisms\nthat must be addressed, and suggestions for improvement and clarification:\nPositive aspects:\nThe authors provide an open-source project with publicly available weights, which is a\nstrong contribution to the community.\nSleepGPT supports multiple downstream tasks - evaluated on sleep staging, pathology\nclassification, sleep data generation, and spindle detection - and can be\nfine-tuned with minimal data.\nThe manuscriptincludes extensive evaluations, clearly reflecting significant effort.\nThe analysis of channel importance for sleep stages, and the influence of sleep stages\non pathology classification, is a valuable addition.\nThe use of time-frequency contrastive learning for pre-training is methodologically\nsound (though not novel).\nThe model is compared to established baselines in each downstream domain; while\nnot all comparisons are directly fair due to mismatched setups, the effort is appreciated.\nAn interesting application of SleepGPT’s generative capabilities is the augmentation\nof datasets, particularly for generating epochs with partially “real” sleep spindles.\nFigures are clear and descriptive, and the manuscript is well written overall.\nWe thank the reviewer for the overall positive and constructive comments on our\nwork.\nNegative aspects, open questions:\n“However, existing AI-based models predominantly rely on supervised learning 53\nframeworks, which depend heavily on annotated datasets. Sleep data annotation is\nexpensive 54 and has emerged as an important bottleneck to progress in sleep research.”\n(l. 52-): This requires a more differentiated discussion. For example,this is not a\nlimitation anymore in the domain of sleep staging, where models such as U-Sleep [7]\nexist that work across measurement protocols, hardware, and patent populations, and\ndo not require fine-tuning. Here the field has moved beyond the need to have a model\nspecialized/fine-tuned for a clinic.\nWe appreciate this insightful comment. While annotated data have traditionally\nbeen a bottleneck for many sleep-related tasks, we acknowledge the reviewer’s\npoint that in the domain of sleep staging, models such as U-Sleep4 already achieve\nstrong performance across measurement protocols, hardware, and patient\npopulations without requiring additional fine-tuning. However, for other clinically\nrelevant tasks such as sleep spindle detection and sleep-disorder classification, the\nlack of large-scale, high-quality annotations still poses a significant challenge,\nwhich motivates our development of SleepGPT. We have toned down the\ncorresponding statement in the revised manuscript to reflect this clarification\n(page 3, lines 53-55).\n“Fixed-channel dependencies in current models limit their ability to integrate\nheterogeneous PSG recordings collected using different equipment and setups,\nrestricting the scope of multi-dataset training and adaptation”. This is not correct for\nsleep staging, where models such as U-Sleep [7] and GSSC presented in\nHanna J, Flöel A. An accessible and versatile deep learning-based sleep stage classifier.\nFront Neuroinform. 2023 Mar 2;17:1086634. doi: 10.3389/fninf.2023.1086634. PMID:\n36938361; PMCID: PMC10017438.\nwork with almost an arbitrary number of channels and channel combinations.\nWe thank the reviewer for this valuable clarification. We agree that in the field of\nsleep staging, recent models such as U-Sleep and GSSC5 already demonstrate\nrobust performance across different channel configurations. We have revised the\nstatement in the manuscript to acknowledge these advances, while clarified that\nfixed‑channel dependencies remain a limitation in many other downstream tasks\nbeyond sleep staging (page 4, lines 70-76) in this revision.\n“Finally, integrating time-domain and frequency-domain features remains a significant\nchallenge in sleep decoding. Both domains are essential for a comprehensive\nunderstanding of sleep signals”: Why? This statement lacks support. The current state-\nof-the-art in sleep staging does not require a frequency embedding. Deep learning\nsystems can figure such an embedding out themselves; even in the domain of speech\nprocessing research is moving away from frequency embeddings.\nAlthough recent end‑to‑end deep learning approaches have shown that\nmeaningful frequency representations can be learned directly from raw signals,\nmany studies on time‑series analysis—including EEG, biomedical signals, and\nother sequential data—continue to demonstrate that explicitly combining\ntime‑domain and frequency‑domain information can enhance model robustness\nand performance. The two domains offer complementary perspectives: the time\ndomain preserves waveform morphology and temporal context, while the\nfrequency domain emphasizes oscillatory patterns and spectral events that may be\ndiagnostically relevant (e.g., sleep spindles, K‑complexes, or slow waves). Thus, the\nintegration of both domains remains a cornerstone strategy in contemporary\ntime‑series studies6–8.\nWe conducted ablation experiments using only time‑domain inputs, only\nfrequency‑domain inputs, and the unified time‑frequency (UTF) configuration.\nResults have been added in this revision (page 44, lines 949–959; Supplementary\nFig. 7). The UTF configuration consistently outperformed either single‑domain\nvariant, suggesting that incorporating frequency‑domain features alongside\ntime‑domain features contribute to improved generalization across heterogeneous\ndatasets and tasks.\nThe value of “dual-domain” inputs is also unclear. The explanation that time windows\nare treated separately for “granular analysis of short-term frequency dynamics” is not\nintuitive. Why can’t a combined time-frequency map be used for this purpose? Is this\ntied to channel subset processing at inference? More explanation would help.\nWe appreciate the reviewer’s important comment. We haven’t used a single\ncombined time–frequency map was primarily driven by the need to maintain\ntemporal alignment with the time‑domain patches. In our implementation,\ntime‑domain inputs are segmented into patches with a fixed window length (e.g.,\n2 s per patch), and each patch is directly mapped to a token. To ensure one‑to‑one\ncorrespondence between the time‑domain and frequency‑domain streams, we\nextracted frequency‑domain representations using the same 2 s temporal windows,\nrather than generating a single large time–frequency image that could mix or\noverlap these segments.\nThis design simplifies the alignment between the two domains and allows each\ntemporal step in the model to jointly reference a time‑domain token and its\nprecisely corresponding frequency‑domain token (Supplementary Fig. 6).\nMoreover, in the masked autoencoder pretraining task, this alignment enables the\nmodel to reconstruct the signal of a specific time epoch while applying the mask to\nboth the time‑domain and frequency‑domain representations at the same\ntemporal positions, ensuring consistent masking and reconstruction across\ndomains. We have expanded the Methods section to explain this rationale in detail\n(page 43, lines 938-943) in this revision.\nAn “ablation study” showing the performance of the proposed system just using the\ntime domain is mandatory.\nWe thank the reviewer for this important suggestion. Following the\nrecommendation, we have conducted an ablation study in which SleepGPT was\ntrained and evaluated using only the time‑domain inputs, without incorporating\nfrequency‑domain features. Leveraging only the time-domain input leads to\nperformance drops across all metrics, demonstrating the importance of both\nrepresentations. The results of this experiment have been added explicitly to the\nrevised Results section (page 44, lines 949-959; Supplementary Fig. 7), allowing\ndirect comparison with the dual‑domain configuration.\nThe results section is not very clearly structured, such an evaluation could hide\nsomewhere in the many tables.\nWe have restructured the Results section to improve clarity and organization,\nensuring that the ablation results are clearly presented and not hidden within\nother tables. These changes make it straightforward for readers to evaluate the\ncontribution of the frequency‑domain input and the overall effectiveness of the\ntime-frequency design.\n“U-Sleep [7] is a model that utilizes a convolutional-only architecture for large-scale,\ncross-dataset supervised training, achieving sleep staging accuracy comparable to that\nof human experts. Although direct comparisons are challenging due to differing\ntraining and evaluation setups, we have included results for U-Sleep across the four\ndatasets we analyzed (Supplementary Table 9).”: If the results cannot be compared, no\ncomparison should be presented. This part lacks a detailed discussion of what the\ndifferences in the evaluation protocols were. Furthermore, “Supplementary Table 9|\nshows a “Comparison among different contextual encoders.”, not considering U-Sleep.\nThat is all very confusing: The caption of “Supplementary Table 8” states\n“Performance of U-Sleep on four datasets using a hold out evaluation scheme.”, but\nSupplementary Table 8 shows something different. U-Time is mentioned in\nSupplementary Table 7, but U-Time and U-Sleep are different. This part must be\nconsiderably revised.\nWe thank the reviewer for pointing out the inconsistencies and the confusion\ncaused by the comparisons to U-Sleep. Because our training and evaluation\nprotocols differ from those used in U-Sleep, we agree that the results are not\ndirectly comparable. To avoid misleading, we have deleted performance\ncomparisons with U-Sleep from the revised manuscript (pages 11-12, lines 229-\n246). Instead, we now reference U-Sleep only in the Related Work section to\nacknowledge its significant contribution to the field.\nSome comparisons on downstream tasks appear to be misleading. For example, U-\nSleep is evaluated on MASS without fine-tuning, while SleepGPT (as I understand) is\nfine-tuned on a subset of studies from that same dataset. SleepGPT also benefits from\nadditional input modalities (e.g., EMG), making comparisons somewhat uneven\n(although EMG is later shown to not have great influence on sleep staging; an\nimportant observation in itself aligning with previous research).\nWe thank the reviewer for this pointing this out. To avoid potential confusion and\nuneven comparisons, we have deleted the results based on U-Sleep from the\nrevised manuscript (pages 11-12, lines 229-246).\nThe usefulness of a foundation model in practice must be discussed in a more\ndifferentiated way. For almost all clinics,a model that works out of the box because it\nis robust (GSSC, U-Sleep) is preferable to a model that requires fine-tuning. Most\nclinics do not have the resources to fine-tune a deep learning model on their data.\nWe agree with the reviewer that models such as GSSC and U-Sleep are indeed\npreferable for sleep staging in many clinical settings because they can be used “out\nof the box” without additional fine‑tuning. In contrast, our work targets a broader\nscope: SleepGPT is designed as a multi‑task foundation model. After pretraining,\nthe model can already be used directly for generative tasks such as PSG epoch\nreconstruction, and it demonstrates strong cross‑dataset generalization. Moreover,\nits architecture provides high scalability and extensibility, enabling efficient\nfine‑tuning for other clinically relevant tasks (e.g., sleep spindle detection or\nsleep‑disorder classification) when needed. We have added this differentiated\ndiscussion to the revised manuscript to clarify the practical value of SleepGPT\nbeyond sleep staging (page 27, lines 585-588).\nAre the sleep spindle annotations by experts 1 and 2 of the freely available MASS-SS2\ndata set available? This would be a good community service. If not, why are they not\nprovided alongside the study?\nThe expert spindle annotations from the MASS‑SS2 dataset are part of the original\ndata release from the MASS project. Access to MASS‑SS2 (including the expert\nannotations) is governed by the database’s own terms of use and requires\nresearchers to submit an ethics/data‑use application to the dataset administrators\nbefore gaining access. The MASS database is available at http://ceams-\ncarsm.ca/mass/. Therefore, we are not permitted to redistribute these annotations\ndirectly alongside our study. To facilitate access, we have included in the revised\nmanuscript a clear citation and link to the official MASS‑SS2 portal, where\ninterested researchers can apply for access in compliance with the dataset’s\nrequirements (page 58, lines 1250-1251).\nThere is an important difference between percent (%) and percentage points (p.p.).\nGoing from 50% to 60% is an increase by 10 p.p., not by 10%.\nWe thank the reviewer for pointing out these important issues in the presentation\nof our results. We agree with the reviewer that there is a clear distinction between\n“percent (%)” and “percentage points (p.p.).” In the revised manuscript, we have\ncarefully reviewed all reported improvements and corrected the terminology\naccordingly.\n* The discussion of the results seems to be biased. For example, when discussing the\neffect of data augmentation in the sleep spindle tasks, the increase in precision for\nexpert 2 is highlighted, however, this comes with a drop in recall. It seems that the\nimprovement in precision is 0.9 p.p. (and not 1% as stated in the manuscript) and a\ndrop in recall of 0.7 p.p.\nWe have revised the corresponding section to accurately reflect both the\nimprovements and trade‑offs. Specifically, we now state that data augmentation\nresulted in an improvement in precision for expert 2 by 0.9 p.p., accompanied by\na 0.7 p.p. drop in recall, and we have updated the discussion to highlight this\ntrade‑off rather than presenting only the improvement in precision (page 27, lines\n582-585) in this revision.\n* “Although U-Sleep employs an adaptive channel strategy, its training is limited to\nusing only one EEG and one EOG channel at a time. This approach suggests that U-\nSleep's adaptability to multi-channel data isn't truly flexible since it requires multiple\nevaluations for multi-channel configurations, increasing time costs and failing to\ncapture the relationships between different PSG channels.” (line 475): These\nstatements lack support and may not be correct. Why is the approach not highly flexible?\nHow is the presented approach more flexible? U-Sleep and GSSC work well for all\nkinds of channel combinations, even if they are wrongly labelled, see also\nFiorillo, L., Monachino, G., van der Meer, J. et al. U-Sleep’s resilience to AASM\nguidelines. npj Digit. Med. 6, 33 (2023). https://doi.org/10.1038/s41746-023-00784-0\nIn general The limitation attributed to “fixed channel dependencies” is somewhat\noverstated. As shown in U-Sleep and GSSC, high correlation among PSG channels\nallows simple channel-swap augmentations to build robustness to missing or variable\nchannel setups.\nWe thank the reviewer for this important clarification and for sharing the relevant\nreference. We agree that we previously overstated the limitation attributed to\n“fixed‑channel dependencies.” Recent studies show that U-Sleep and GSSC\nexhibit strong robustness across a wide range of channel combinations, even under\nmislabeled or variable configurations, partly due to the high correlation among\nPSG channels and the effectiveness of channel‑swap augmentations.\nTo avoid confusion and unsupported claims, we have removed the original\nstatements suggesting that U-Sleep’s adaptability is “not truly flexible.” In the\nrevised manuscript, we now acknowledge that U-Sleep and GSSC already achieve\nhigh flexibility for channel combinations. We also have clearly described how\nSleepGPT differs from existing methods, ensure accurate positioning of our\ncontributions, and highlights SleepGPT’s design without overstating limitations\nof prior work (page 23, lines 500-505) in this revision.\n* The statement “increasing time costs and failing” seems to be very misleading and\nlacks quantitative support. The proposed SleepGPT transformer architecture is very\ncomplex. The authors must provide a wall -clock time comparison of U-Sleep and\nSleepGPT. This is mandatory. This comparison should include both GPU and CPU\nenvironments.\nMore general, SleepGPT appears computationally heavy compared to CNN-based\napproaches. Could similar performance be achieved using a simpler masked CNN\nautoencoder? A comparison with such lightweight baselines would be useful.\nWe thank the reviewer for this comment. To avoid unsupported claims, we have\nremoved the original statements regarding increased time costs from the\nmanuscript. Though we did not include a formal wall‑clock time comparison\nbetween U-Sleep and SleepGPT, we sincerely acknowledge that, as a\ntransformer‑based architecture, SleepGPT is computationally heavier than\nCNN‑based approaches.\nIn response to the reviewer’s suggestion, we have implemented and added a\ncomparison with a lightweight masked CNN autoencoder baseline. The results of\nthis baseline are reported in the revised manuscript (page 57, lines 1226-1232;\nSupplementary Fig. 9), demonstrating that while the CNN autoencoder can\nperform the reconstruction task, it does not achieve the same downstream\nperformance as SleepGPT.\n* The model description in the methods section could be clearer. However, the model is\ncomplex and uses advanced concepts. It would be interesting for the reader if it would\nbe explained in more detail how the transformer architecture makes use of different\nchannels. How is the channel information aligned and fused, given that the number of\nchannels can vary.\nWe thank the reviewer for this helpful suggestion. In the revised manuscript, we\nhave clarified in detail how SleepGPT handles multi‑channel inputs within the\ntransformer architecture.\nSpecifically, we perform channel‑wise patch tokenization, where each channel is\nsegmented into temporal patches. This process produces a token sequence with\nshape , where C is the number of channels, T is the number of patches\nper channel, and D is the embedding dimension. These channel‑wise embeddings\nare then processed using a masked attention mechanism in the transformer.\nTo accommodate variable channel configurations, we construct the attention\nmatrices such that any missing channels are masked by setting their\ncorresponding attention entries to -inf. This ensures that the transformer ignores\nunavailable channels while still fusing information from all available channels in\na consistent temporal alignment. Through this mechanism, SleepGPT can flexibly\nhandle heterogeneous PSG recordings collected from different setups without\nrequiring a fixed channel configuration.\nThese explanations and a schematic illustration of the channel‑wise tokenization\nand masking have been added to the Methods section of the revised manuscript\n(page 44, lines 961-966; Supplementary Fig. 8).\n* The claim that no other foundation model exists is somewhat overstated. Several self-\nsupervised pre-trained models for EEG already exist, for example\nQ. Xiao et al., \"Self-Supervised Learning for Sleep Stage Classification with Predictive\nand Discriminative Contrastive Coding,\" ICASSP 2021 - 2021 IEEE International\nConference on Acoustics, Speech and Signal Processing (ICASSP), Toronto, ON,\nCanada, 2021, pp. 1290-1294, doi: 10.1109/ICASSP39728.2021.9414752.\nThapa R, Kjær MR, He B, Covert I, Moore H, Hanif U, Ganjoo G, Westover MB,\nJennum P, Brink-Kjær A, Mignot E, Zou J. A Multimodal Sleep Foundation Model\nDeveloped with 500K Hours of Sleep Recordings for Disease Predictions. medRxiv\n[Preprint]. 2025 Feb 9:2025.02.04.25321675. doi: 10.1101/2025.02.04.25321675.\nPMID: 39974074; PMCID: PMC11838666.\nX. Jiang, J. Zhao, B. Du and Z. Yuan, \"Self-supervised Contrastive Learning for EEG-\nbased Sleep Staging,\" 2021 International Joint Conference on Neural Networks\n(IJCNN), Shenzhen, China, 2021, pp. 1-8, doi: 10.1109/IJCNN52387.2021.9533305.\nThat said, SleepGPT may be the most extensive and rigorously evaluated (peer-\nreviewed) effort in this space.\nWe thank the reviewer for pointing out these important references. We agree that\nour original claim that “no other foundation model exists” was overstated. Several\nself‑supervised and pre‑trained models for EEG and sleep staging have indeed\nbeen proposed.\nIn the revised manuscript, we have modified this statement to acknowledge these\nprior efforts. We now clarify that SleepGPT builds upon this line of work but\ndistinguishes itself by integrating time-frequency inputs and by being extensively\nevaluated across multiple tasks and datasets, representing one of the most\ncomprehensive and rigorously validated foundation‑model efforts in the sleep\nresearch domain.\nThese revisions have been incorporated into the Introduction section to ensure an\naccurate and balanced positioning of our contributions (page 3, lines 60-62) in this\nrevision.\n* The authors state that 59,267 hours from 5,132 subjects represents the largest dataset\nfor self-supervised learning. While this may be true specifically for self-supervised\nmethods in PSG, many supervised models have been trained on even larger PSG\ndatasets. Given the potential of self-supervision, the question arises: why not use even\nlarger unannotated datasets, including from wearable devices where high quality\nannotations may not be available? The authors should address this point in the\nmanuscript.\nWe thank the reviewer for these insightful comments.\nRegarding the size of the dataset, we agree that while our 59,267 hours from\n5,132 subjects represent one of the largest datasets specifically used for\nself‑supervised PSG pretraining, there are indeed supervised models that have\nbeen trained on even larger PSG datasets4. We have revised the manuscript to\nmake our statement more precise (page 5, lines 94-96) in this revision.\nWe also agree that incorporating even larger unannotated datasets—including\nthose from wearable devices where high‑quality annotations may not be\navailable—has great potential to further improve the robustness and applicability\nof foundation models. In the current work, we focused on balancing dataset\ndiversity and the computational cost of pretraining, which constrained us from\nincluding additional large‑scale datasets at this stage. We have added a note in the\nDiscussion to indicate that expanding SleepGPT to even larger unannotated PSG\nand wearable datasets is an important direction for future work (page 27, lines\n588-590) in this revision.\nIn addition, we validated SleepGPT's adaptability to wearable EEG devices using\nthe UMS dataset (Supplementary Table 1), which includes overnight recordings\nfrom 179 Chinese adults acquired with a single-channel forehead EEG recorder\n(UMindSleep, EEGSmart Co., Ltd.) simultaneously with standard PSG. Following\nprevious literature1, we adopted a 4-class staging scheme by combining N1 and N2\ninto light sleep and treating N3 as deep sleep.\nOn this dataset, SleepGPT achieved an accuracy of 82.1%, outperforming the\ncommercial software provided by the device manufacturer, which reached 76.0%\naccuracy. We further incorporated SpO₂ signals—also recorded by the wearable\ndevice—via a cross-attention mechanism into the UTF block, which led to\nadditional performance improvements (accuracy: 82.6%) (Supplementary Table\n11).\nSleepGPT not only achieves competitive performance under a 4‑class setting but\nis also capable of performing standard 5‑class classification. For example, under\nthe 5‑class setting, SleepGPT achieves an overall staging accuracy of 76.6%\n(Supplementary Table 12).\nThese findings demonstrate that SleepGPT can be deployed not only in\ncomprehensive PSG environments but also in simplified configurations, such as\nthose provided by wearable devices, thereby improving accessibility for routine\nscreening and home-based monitoring. We have added these experimental results\nto the Results section (pages 13-14, lines 274-288; Supplementary Tables 11-12),\nprovided relevant discussions (page 23, lines 497-498), and included the\nexperimental setup in the Methods section (pages 52-53, lines 1135-1145) in this\nrevision.\n* Despite the large dataset used, several publicly available datasets (e.g., from NSRR,\nPhysioNet) are omitted. Including them would increase both the robustness and\napplicability of the model.\nRegarding publicly available datasets such as those from NSRR and PhysioNet,\nwe acknowledge that incorporating them would further improve robustness and\ncross‑dataset generalization. Due to pretraining time and resource constraints,\nthese datasets were not included in the current study. However, we plan to\nincorporate these additional sources in future expansions of SleepGPT and have\nstated this explicitly in the revised manuscript (page 27, lines 588-590) in this\nrevision.\n* It’s unclear to me how the model handles varying input channel counts. Pre-training\nseems to use 8 channels, and although the text mentions single-channel fine-tuning for\ndownstream tasks several times, the figures suggest multiple channels (with a concat\noperation to combine channel representations). Please clarify both in text and visuals.\nWe thank the reviewer for pointing out this ambiguity. In the revised manuscript,\nwe have clarified in detail how SleepGPT handles varying input channel counts.\nSpecifically, during pretraining we use up to 8 channels, but the model is designed\nwith channel‑wise tokenization and a masked attention mechanism that allows\nflexible operation with any available subset of channels. For downstream tasks,\nboth single‑channel and multi‑channel configurations are supported: channel\nembeddings are first processed individually and then fused via a concatenation\noperation before entering the transformer, with missing channels masked\nappropriately.\nTo make this clear, we have revised the corresponding sections of the text and\nredrawn the relevant figures to explicitly illustrate how multi‑channel inputs are\nhandled, how channel representations are combined, and how missing channels\nare masked during inference. These updates are included in the revised\nmanuscript to remove any ambiguity for readers (page 44, lines 961-966;\nSupplementary Fig. 8).\n* The fine-tuning procedure for downstream tasks also lacks detail more generally. For\ninstance, was SleepGPT fine-tuned on part of the evaluation dataset or trained on other\ndatasets for the same task and then evaluated on entirely new cohorts? This is especially\nimportant for interpreting downstream comparisons with methods that were not fine-\ntuned on the same cohort.\nWe thank the reviewer for this valuable comment. In the revised manuscript, we\nhave clarified the fine‑tuning procedure for all downstream tasks. For each task,\nSleepGPT was fine‑tuned on a single dataset and then evaluated on the held‑out\ntest set or test folds of the same dataset, ensuring that no data leakage occurred\nbetween training and evaluation. For some tasks we used a k‑fold cross‑validation\nscheme, while for others we employed a fixed held‑out split, but in all cases, the\nfine‑tuning and evaluation were performed in a strictly separated manner within\neach dataset.\nThese details have been added to the Methods section to make the fine‑tuning and\nevaluation protocol explicit and transparent (pages 48-49, lines 1050-1060) in this\nrevision.\n* Training details and hyperparameters seem to be missing. A summary table with\noptimization parameters per training stage would be very helpful.\nWe thank the reviewer for this helpful suggestion. In the revised manuscript, we\nhave added comprehensive training details and hyperparameters for both the\npretraining and downstream fine‑tuning stages. To make these settings clear and\naccessible, we have included a summary table that lists key optimization\nparameters such as learning rates, batch sizes, optimizer types, weight decay, the\nnumber of epochs, learning rate schedules, and dropout settings for each stage.\nThis table has been added to the Methods section (page 56, lines 1212-1225) in this\nrevision to provide readers with a concise reference for reproducing our results.\n* The code repository is public, but is missing a README file and is not documented\neven in the code (no comments, docstrings or type hints). This makes it non-trivial to\nuse the current code base or look up answers to some of the questions raised here. The\nauthors testify in the ML checklist that a README is available in the repository, so this\nshould be added and (preferably) the code cleaned prior to publication.\nWe thank the reviewer for highlighting this important point. In response, we have\nadded a comprehensive README to the public repository. The README now\nincludes detailed installation instructions, environment setup, and step‑by‑step\nguidelines for running pretraining, fine‑tuning, and inference.\nIn addition, we have improved the code documentation by adding meaningful\ncomments, docstrings, and type hints throughout the code base to make the\nimplementation easier to follow. These updates have been completed prior to\nresubmission to ensure that the repository is ready for use by the community.\n* The need for a “unified time-frequency fusion mechanism” is not clearly justified.\nCouldn’t deep convolutional networks learn both time and frequency features\ninherently? Please elaborate on the rationale.\nWe appreciate the reviewer’s comment and have elaborated on the rationale\nbehind our unified time–frequency fusion mechanism. In our framework, “unified”\nrefers to leveraging the transformer’s attention matrix to jointly model and\nglobally fuse the time‑domain and frequency‑domain signals during feature\nlearning.\nWhile it is true that deep convolutional networks can, in principle, learn both time\nand frequency features, CNN‑based architectures typically fuse these domains\nearly by stacking or concatenating them as input, and then learn joint features\nthrough local convolutional operations. In contrast, our design keeps the two\ndomains separated at the embedding level, allowing the transformer to explicitly\nattend across time‑domain and frequency‑domain tokens and capture global\ndependencies and cross‑domain interactions through self‑attention.\nTo further justify this design, we conducted an ablation experiment where the two\ndomain streams were not fused via attention but instead simply concatenated at\nthe top (equivalent to not leveraging global cross‑domain attention). The results,\nreported in the revised manuscript (page 44, lines 949-959; Supplementary Fig. 7),\nshow that using the unified attention‑based fusion consistently outperforms the\nlate concatenation approach.\nThese clarifications and the supporting ablation results have been added to the\nMethods and Results sections to make the rationale for the unified time–frequency\nfusion mechanism clear.\n* Processing only 30-second windows during pre-training may be limiting. Although a\nmethod is provided for aggregating representations across time during downstream\ntasks, a broader context during pre-training could improve those representations as\nwell.\nWe thank the reviewer for this thoughtful comment. We agree that processing only\n30‑second windows during pretraining may limit the contextual scope of learned\nrepresentations, and a broader context could potentially improve feature quality,\nespecially for sleep staging. However, increasing the window length substantially\naffects computational efficiency because the transformer architecture used in\nSleepGPT has near‑quadratic complexity with respect to sequence length.\nMoreover, using overly long windows may reduce the model’s ability to capture\nshort‑duration sleep events, such as sleep spindles or K‑complexes, which are\ncritical for certain downstream tasks. Balancing global context and local event\nsensitivity is therefore a key design consideration in this work.\nLooking forward, we plan to leverage more data and explore larger or more\nefficient transformer variants that can jointly capture long‑range global patterns\nand fine‑grained local features without incurring prohibitive computational costs.\nWe have added these points to the Discussion section to clarify the trade‑offs and\nfuture directions (page 29, lines 626-630) in this revision.\n* Regarding the data generation experiment: Why are only four test studies used? As\nauthors mention the datasets contain a total of 19 and 20 studies, respectively, with 12\nused for training, there should be 7–8 left. Were some used for validation or excluded?\nPlease clarify.\nWe thank the reviewer for raising this point. In the data generation experiment,\nonly four studies were reported in the test set because the remaining 3-4 studies\nfrom the datasets were used for validation during model development. To avoid\ndata leakage, these validation studies were not included in the test set (Table R1).\nWe have revised the manuscript to explicitly state this data split and clarified that,\namong the total available studies, a subset was used for training, another subset\nfor validation, and the remaining four for testing in the data generation\nexperiment (page 19, lines 401-407) in this revision.\nTable R1. Dataset split for the data generation experiment\nDataset Total Training Validation Test\nSleepEDF-20 20 12 3 4\nMASS-SS2 19 12 4 4\nThis sentence is unclear: “By accurately determining each PSG channel’s influence,\nclinicians can devise more personalized treatment strategies...” It's hard to see how this\nwould be applied at the individual patient level. Wouldn’t clinicians just use the best-\nperforming channel based on prior retrospective analysis in clinical practice?\nWe thank the reviewer for pointing out this ambiguity. The original sentence\noverstated the direct clinical applicability. We have revised the manuscript to\nclarify that our channel‑wise attention analysis is primarily intended to provide\ninsights into which channels contribute most strongly to model performance\nacross datasets, rather than to dictate personalized treatment plans for individual\npatients (page 24, lines 514-517) in this revision.\n*\n* Minor comments:\n*\n* Abstract: It is not clear what is meant by a “fixed-channel architecture”\nWe have removed the term \"fixed-channel architecture\" from the abstract (page\n2, lines 26-28) in this revision. In the revised manuscript, we explain that while\nexisting models, including U-Sleep, are capable of handling flexible channel\nconfigurations for sleep staging, no models have yet demonstrated the same\nadaptability for other sleep decoding tasks, such as sleep spindle detection or sleep-\ndisorder classification.\n* Lines 56-56: The PSG data is more similar to speech signals, thus, in addition to 9-\n11, it is suggested to refer also to Abdelrahman Mohamed et al. Self-Supervised Speech\nRepresentation Learning: A Review. IEEE Journal of Selected Topics in Signal\nProcessing, 16(6):1179–1210, 2022\nWe thank the reviewer for this suggestion. We have added the study by\nAbdelrahman Mohamed et al. (2022) to the manuscript to further support the\ncomparison between PSG and speech signals (page 3, line 57) in this revision.\n* “Inspired by …” starting in line 444 is not a full sentence.\nWe have revised the sentence to make it complete and grammatically correct,\nensuring clarity and coherence in the manuscript (pages 21-22, lines 459-463) in this revision.\n* Consider removing loaded or promotional language, such as “we innovatively…”\nWe agree with the reviewer’s suggestion. We have removed promotional language\nand revised the manuscript to adopt a more neutral and academic tone throughout.\nReviewer #3 (Remarks on code availability):\nThe code repository is public, but is missing a README file and is not documented\neven in the code (no comments, docstrings or type hints). This makes it non-trivial to\nuse the current code base or look up answers to some of the questions raised here. The\nauthors testify in the ML checklist that a README is available in the repository, so this\nshould be added and (preferably) the code cleaned prior to publication.\nWe thank the reviewer for pointing out the lack of documentation in the code\nrepository. To address this, we have added a comprehensive README.md file,\nwhich includes clear setup instructions, a guide for running pretraining, fine-\ntuning, and evaluation scripts, as well as descriptions of input formats and\nexpected data organization. Additionally, we have included an environment\nconfiguration file (requirements.txt) to facilitate reproducing the training and\ntesting environments. The code has also been cleaned and documented with\ncomments, docstrings, and type hints to improve usability and ensure\nreproducibility.\nReviewer #4 (Remarks to the Author):\nI co-reviewed this manuscript with one of the reviewers who provided the listed reports.\nThis is part of the Nature Communications initiative to facilitate training in peer review\nand to provide appropriate recognition for Early Career Researchers who co-review\nmanuscripts.\nWe appreciate the important comments you raised below.\nReviewer #4 (Remarks on code availability):\nThe code repository is public, but is missing a README file and is not documented\neven in the code (no comments, docstrings or type hints). This makes it non-trivial to\nuse the current code base or look up answers to some of the questions raised here. The\nauthors testify in the ML checklist that a README is available in the repository, so this\nshould be added and (preferably) the code cleaned prior to publication.\nWe appreciate the reviewer’s comments regarding code availability. In response,\nwe have added a detailed README.md file to the public code repository,\nproviding setup instructions, an explanation of the model structure, and guidelines\nfor running pretraining, fine-tuning, and evaluation. Furthermore, we have\nincluded an environment configuration file (requirements.txt) to assist in\nreproducing the training environment. The code has been updated with comments,\ndocstrings, and type hints to improve its clarity and usability. These updates have\nbeen made to enhance the accessibility of the repository for the research\ncommunity.\nReferences\n1. Chen, X. et al. Validation of a wearable forehead sleep recorder against\npolysomnography in sleep staging and desaturation events in a clinical sample. J. Clin.\nSleep Med. 19, 711–718 (2023).\n2. Vig, J. A multiscale visualization of attention in the transformer model. In Prof. of\nthe 57th Annual Meeting of the Association for Computational Linguistics: System\nDemonstrations 37–42 (2019).\n3. Kapishnikov, A. et al. Guided integrated gradients: an adaptive path method for\nremoving noise. In Prof. of the IEEE/CVF Conference on Computer Vision and Pattern\nRecognition 5050–5058 (2021).\n4. Perslev, M. et al. U-sleep: resilient high-frequency sleep staging. NPJ Digit. Med.\n4, 72 (2021).\n5. Hanna, J. & Flöel, A. An accessible and versatile deep learning-based sleep stage\nclassifier. Front. neuroinform. 17, 1086634 (2023).\n6. Zhang, X., Zhao, Z., Tsiligkaridis, T. & Zitnik, M. Self-supervised contrastive pre-\ntraining for time series via time-frequency consistency. Preprint at\nhttp://arxiv.org/abs/2206.08496 (2022).\n7. Luo, Y., Zhang, S., Lyu, Z. & Hu, Y. TFDNet: time–frequency enhanced\ndecomposed network for long-term time series forecasting. Pattern Recognit. 162,\n111412 (2025).\n8. Phan, H. et al. XSleepNet: multi-view sequential model for automatic sleep staging.\nIEEE Trans. Pattern Anal. Mach. Intell. 44, 5903–5915 (2021).\nResponse to the Editor and Reviewers\nThe Reviewers' comments are in italics, and our responses are in boldface. Additionally,\nall changes in the manuscript are written in blue.\nWe sincerely thank the reviewers for their thoughtful comments on our\nmanuscript. We found the feedback to be extremely valuable and have made\nsignificant improvements to our manuscript as a result. Our detailed, point-by-\npoint responses to the Reviewers' comments are presented below.\nReviewer #1 (Remarks to the Author):\nThe author solved all the concerns. I have no more questions.\nWe sincerely thank the reviewer for the thoughtful evaluation and encouraging\nremarks. We are pleased that our revisions have satisfactorily addressed all\nconcerns.\nReviewer #2 (Remarks to the Author):\nI have carefully reviewed the revised version of the manuscript \"SleepGPT: A unified\ndual-domain foundation model for sleep decoding.\" The authors have done an excellent\njob in addressing all of the issues raised in the first round of review. The revisions have\nsubstantially improved the clarity, completeness, and reproducibility of the paper.\n________________________________________\nStrengths of the Revision\n1. Reproducibility and Code Availability\n-The authors have now provided a comprehensive and well-structured README file,\nincluding installation instructions, dataset preparation steps, and example scripts.\n-The code is usable as a community resource, with clear guidelines for pretraining,\nfine-tuning, and evaluation. This directly addresses one of the major limitations of the\noriginal submission.\n2. Benchmarking Against Recent Models\n-The revised manuscript includes comparisons with several additional recent and\ncompetitive models such as Cross-Modal Sleep Transformer, SleePyCo, AttnSleep,\nIITNet, and DeepSleepNet-Lite.\n-This addition significantly strengthens the validity of the experimental evaluation and\ndemonstrates that SleepGPT provides a clear advance over state-of-the-art methods.\n3. Improved Clarity in Embedding Section\n-The description of dual-domain embeddings has been refined and supplemented with\nvisual illustrations, making it easier to follow the mathematical formulation.\n-The presentation is now accessible both to experts in deep learning and readers from\nthe biomedical field.\n4. Synthetic Data and Augmentation Details\n-The revised manuscript now clearly explains the process of generating synthetic data\nand evaluates its effect on performance.\n-This addition clarifies an important methodological aspect and enhances transparency.\n5. Clarity of Embedding Section\n-A summarizing table of key symbols and a new figure (Supplementary Fig. 6) have\nbeen added, greatly improving readability.\n6. Computational Resources and Practicality\n-The authors have included details on parameter count, pretraining/fine-tuning\nhardware, runtime, and inference speed.\n-This information will be valuable for readers considering real-world adoption.\n_______________________________________\nOverall Recommendation\nThe authors have thoroughly addressed all previous concerns and significantly\nstrengthened the manuscript. The revised version is clear, rigorous, reproducible, and\ndemonstrates substantial contribution to the field of sleep analysis and biomedical AI.\nI appreciate the authors’ careful and thoughtful revisions. I now recommend this\nmanuscript for acceptance without further changes.\nWe sincerely thank the reviewer for the thoughtful and detailed evaluation. We\nare encouraged to know that the revisions have met the reviewer’s expectations,\nand we are grateful for the recommendation for acceptance.\nReviewer #2 (Remarks on code availability):\nThe authors have now provided a comprehensive and well-structured README file,\nincluding installation instructions, dataset preparation steps, and example scripts.\nThe code is usable as a community resource, with clear guidelines for pretraining, fine-\ntuning, and evaluation. This directly addresses one of the major limitations of the\noriginal submission.\nWe thank the reviewer for the positive feedback. We are glad that the revised\nREADME file and codebase now meet the standards for community usability. We\nappreciate your recognition that our updated documentation—covering\ninstallation, dataset preparation, pretraining, fine-tuning, and evaluation—\neffectively addresses the previous limitations regarding reproducibility and code\nclarity.\nReviewer #3 (Remarks to the Author):\nOur comments have been carefully addressed in the revision.\nThe new experiments strengthen the arguments made in the study.\nThe more careful wording improved the writing.\nThe new figure is appreciated.\nThe more considerate comparison with other methods is appreciated.\nWe sincerely thank the reviewer for the constructive feedback and positive\nassessment of our revised manuscript. We are pleased that the reviewer finds our\nresponses satisfactory, and appreciates the newly added experiments, improved\nwriting, and the updated figure and comparative analysis.\nQuestions:\nIn lines 1074-1075, what does the superscript 1’D’ mean? Should it be 1xD’?\nThis formatting issue occurred due to a rendering error during the conversion\nfrom Word to PDF. The intended notation was indeed 1×D′, denoting a feature\nvector with D′ dimensions.\nMinor comments:\nSome symbols are not showing in the pdf, it seems to be the symbol for real numbers.\nSimilarly, the missing symbols (such as the set of real numbers ℝ) were also caused\nby PDF export incompatibilities. We have corrected the symbol rendering in the\nupdated manuscript to ensure clarity and proper display.\nReviewer #3 (Remarks on code availability):\nOur concerns regarding the code were addressed in the answer letter.\nWe thank the reviewer for confirming that the concerns regarding code\navailability have been addressed. We appreciate your acknowledgment, and we\nremain committed to maintaining a clear and reproducible codebase for the\nresearch community.\nReviewer #4 (Remarks to the Author):\nI co-reviewed this manuscript with one of the reviewers who provided the listed reports.\nThis is part of the Nature Communications initiative to facilitate training in peer review\nand to provide appropriate recognition for Early Career Researchers who co-review\nmanuscripts.\nWe thank the reviewer and their co-reviewer for taking the time to evaluate our\nmanuscript. We appreciate Nature Communications' initiative to involve and\nrecognize Early Career Researchers in the peer review process, and we are\ngrateful for your constructive feedback and support."}, {"round": 2, "reviewer_comments": {"reviewer_1": "The author solved all the concerns. I have no more questions.", "reviewer_2": "I have carefully reviewed the revised version of the manuscript \"SleepGPT: A unified dual-domain foundation model for sleep decoding.\" The authors have done an excellent job in addressing all of the issues raised in the first round of review. The revisions have substantially improved the clarity, completeness, and reproducibility of the paper.\n________________________________________\nStrengths of the Revision\n1. Reproducibility and Code Availability\n-The authors have now provided a comprehensive and well-structured README file, including installation instructions, dataset preparation steps, and example scripts.\n-The code is usable as a community resource, with clear guidelines for pretraining, fine-tuning, and evaluation. This directly addresses one of the major limitations of the original submission.\n2. Benchmarking Against Recent Models\n-The revised manuscript includes comparisons with several additional recent and competitive models such as Cross-Modal Sleep Transformer, SleePyCo, AttnSleep, IITNet, and DeepSleepNet-Lite.\n-This addition significantly strengthens the validity of the experimental evaluation and demonstrates that SleepGPT provides a clear advance over state-of-the-art methods.\n3. Improved Clarity in Embedding Section\n-The description of dual-domain embeddings has been refined and supplemented with visual illustrations, making it easier to follow the mathematical formulation.\n-The presentation is now accessible both to experts in deep learning and readers from the biomedical field.\n4. Synthetic Data and Augmentation Details\n-The revised manuscript now clearly explains the process of generating synthetic data and evaluates its effect on performance.\n-This addition clarifies an important methodological aspect and enhances transparency.\n5. Clarity of Embedding Section\n-A summarizing table of key symbols and a new figure (Supplementary Fig. 6) have been added, greatly improving readability.\n6. Computational Resources and Practicality\n-The authors have included details on parameter count, pretraining/fine-tuning hardware, runtime, and inference speed.\n-This information will be valuable for readers considering real-world adoption.\n_______________________________________\nOverall Recommendation\nThe authors have thoroughly addressed all previous concerns and significantly strengthened the manuscript. The revised version is clear, rigorous, reproducible, and demonstrates substantial contribution to the field of sleep analysis and biomedical AI.\nI appreciate the authors’ careful and thoughtful revisions. I now recommend this manuscript for acceptance without further changes.", "reviewer_3": "Our comments have been carefully addressed in the revision.\nThe new experiments strengthen the arguments made in the study.\nThe more careful wording improved the writing.\nThe new figure is appreciated.\nThe more considerate comparison with other methods is appreciated.\nQuestions:\nIn lines 1074-1075, what does the superscript 1’D’ mean? Should it be 1xD’?\nMinor comments:\nSome symbols are not showing in the pdf, it seems to be the symbol for real numbers.", "reviewer_4": "I co-reviewed this manuscript with one of the reviewers who provided the listed reports. This is part of the Nature Communications initiative to facilitate training in peer review and to provide appropriate recognition for Early Career Researchers who co-review manuscripts."}, "author_response": "Response to the Editor and Reviewers\nThe Reviewers' comments are in italics, and our responses are in boldface. Additionally,\nall changes in the manuscript are written in blue.\nWe sincerely thank the reviewers for their thoughtful comments on our\nmanuscript. We found the feedback to be extremely valuable and have made\nsignificant improvements to our manuscript as a result. Our detailed, point-by-\npoint responses to the Reviewers' comments are presented below.\nReviewer #1 (Remarks to the Author):\nThe author solved all the concerns. I have no more questions.\nWe sincerely thank the reviewer for the thoughtful evaluation and encouraging\nremarks. We are pleased that our revisions have satisfactorily addressed all\nconcerns.\nReviewer #2 (Remarks to the Author):\nI have carefully reviewed the revised version of the manuscript \"SleepGPT: A unified\ndual-domain foundation model for sleep decoding.\" The authors have done an excellent\njob in addressing all of the issues raised in the first round of review. The revisions have\nsubstantially improved the clarity, completeness, and reproducibility of the paper.\n________________________________________\nStrengths of the Revision\n1. Reproducibility and Code Availability\n-The authors have now provided a comprehensive and well-structured README file,\nincluding installation instructions, dataset preparation steps, and example scripts.\n-The code is usable as a community resource, with clear guidelines for pretraining,\nfine-tuning, and evaluation. This directly addresses one of the major limitations of the\noriginal submission.\n2. Benchmarking Against Recent Models\n-The revised manuscript includes comparisons with several additional recent and\ncompetitive models such as Cross-Modal Sleep Transformer, SleePyCo, AttnSleep,\nIITNet, and DeepSleepNet-Lite.\n-This addition significantly strengthens the validity of the experimental evaluation and\ndemonstrates that SleepGPT provides a clear advance over state-of-the-art methods.\n3. Improved Clarity in Embedding Section\n-The description of dual-domain embeddings has been refined and supplemented with\nvisual illustrations, making it easier to follow the mathematical formulation.\n-The presentation is now accessible both to experts in deep learning and readers from\nthe biomedical field.\n4. Synthetic Data and Augmentation Details\n-The revised manuscript now clearly explains the process of generating synthetic data\nand evaluates its effect on performance.\n-This addition clarifies an important methodological aspect and enhances transparency.\n5. Clarity of Embedding Section\n-A summarizing table of key symbols and a new figure (Supplementary Fig. 6) have\nbeen added, greatly improving readability.\n6. Computational Resources and Practicality\n-The authors have included details on parameter count, pretraining/fine-tuning\nhardware, runtime, and inference speed.\n-This information will be valuable for readers considering real-world adoption.\n_______________________________________\nOverall Recommendation\nThe authors have thoroughly addressed all previous concerns and significantly\nstrengthened the manuscript. The revised version is clear, rigorous, reproducible, and\ndemonstrates substantial contribution to the field of sleep analysis and biomedical AI.\nI appreciate the authors’ careful and thoughtful revisions. I now recommend this\nmanuscript for acceptance without further changes.\nWe sincerely thank the reviewer for the thoughtful and detailed evaluation. We\nare encouraged to know that the revisions have met the reviewer’s expectations,\nand we are grateful for the recommendation for acceptance.\nReviewer #2 (Remarks on code availability):\nThe authors have now provided a comprehensive and well-structured README file,\nincluding installation instructions, dataset preparation steps, and example scripts.\nThe code is usable as a community resource, with clear guidelines for pretraining, fine-\ntuning, and evaluation. This directly addresses one of the major limitations of the\noriginal submission.\nWe thank the reviewer for the positive feedback. We are glad that the revised\nREADME file and codebase now meet the standards for community usability. We\nappreciate your recognition that our updated documentation—covering\ninstallation, dataset preparation, pretraining, fine-tuning, and evaluation—\neffectively addresses the previous limitations regarding reproducibility and code\nclarity.\nReviewer #3 (Remarks to the Author):\nOur comments have been carefully addressed in the revision.\nThe new experiments strengthen the arguments made in the study.\nThe more careful wording improved the writing.\nThe new figure is appreciated.\nThe more considerate comparison with other methods is appreciated.\nWe sincerely thank the reviewer for the constructive feedback and positive\nassessment of our revised manuscript. We are pleased that the reviewer finds our\nresponses satisfactory, and appreciates the newly added experiments, improved\nwriting, and the updated figure and comparative analysis.\nQuestions:\nIn lines 1074-1075, what does the superscript 1’D’ mean? Should it be 1xD’?\nThis formatting issue occurred due to a rendering error during the conversion\nfrom Word to PDF. The intended notation was indeed 1×D′, denoting a feature\nvector with D′ dimensions.\nMinor comments:\nSome symbols are not showing in the pdf, it seems to be the symbol for real numbers.\nSimilarly, the missing symbols (such as the set of real numbers ℝ) were also caused\nby PDF export incompatibilities. We have corrected the symbol rendering in the\nupdated manuscript to ensure clarity and proper display.\nReviewer #3 (Remarks on code availability):\nOur concerns regarding the code were addressed in the answer letter.\nWe thank the reviewer for confirming that the concerns regarding code\navailability have been addressed. We appreciate your acknowledgment, and we\nremain committed to maintaining a clear and reproducible codebase for the\nresearch community.\nReviewer #4 (Remarks to the Author):\nI co-reviewed this manuscript with one of the reviewers who provided the listed reports.\nThis is part of the Nature Communications initiative to facilitate training in peer review\nand to provide appropriate recognition for Early Career Researchers who co-review\nmanuscripts.\nWe thank the reviewer and their co-reviewer for taking the time to evaluate our\nmanuscript. We appreciate Nature Communications' initiative to involve and\nrecognize Early Career Researchers in the peer review process, and we are\ngrateful for your constructive feedback and support."}]

Decision letter