Sparse Sleep Scoring with Sequence-Level Training

A night of sleep recording is a sequence of about a thousand 30-second windows ("epochs"). An expert labels each one as Wake, N1, N2, N3 or REM, and fully scoring a single night takes hours. The usual way to save labels is to score a few nights completely and train a classifier on each window independently. This proposal tests a different way to spend the same expert time. Experts score a small, scattered fraction of epochs across many nights. The model is then trained with a sequence-level objective: instead of treating each window as its own question, it scores whole stage sequences. The objective raises the total probability of every stage sequence that agrees with the scored epochs, follows plausible sleep-stage transitions, and is not ruled out by the model's own confident predictions. It lowers the probability of all other sequences. Speech recognition calls this kind of objective sequence-discriminative training, and the unscored stretches of each night are handled by summing over the plausible stage paths rather than by guessing a single answer.

The opportunity comes from two literatures that have not met. Speech recognition has spent a decade learning how to train on partially trusted sequences. It represents a set of acceptable label sequences as a graph and trains the model against that whole set, not against one point estimate, and this has been shown to reduce the bias that comes from trusting a single decoded hypothesis. Biosignal foundation models, meaning large encoders pretrained on unlabeled EEG or ECG, are adapted to sequence tasks almost entirely through window-level cross-entropy. The two-sentence version is this: sparse labels spread across many nights carry more information than dense labels on few nights, but only if the training objective can propagate them through the sleep-stage grammar. A pretrained encoder makes that propagation trustworthy enough that the heavy uncertainty machinery speech needed (repeated dropout decoding, separate error detectors) may become unnecessary.

Core Claim

Hold the annotation budget fixed, for example 2% of all epochs in a cohort. Under that budget, scattered epoch labels over many nights, combined with a sequence-level objective whose "acceptable set" is pruned by a self-supervised encoder's own posteriors, will beat two alternatives: dense scoring of few nights with per-window cross-entropy, and 1-best pseudo-labeling. The gain should be largest on transition-sensitive stages (N1, and REM onsets) and on sleep-architecture quantities derived from the whole sequence.

Formally, let $x_n$ be night $n$ and $s=(s_1,\dots,s_T)$ a stage sequence. The model assigns $p(s\mid x_n)\propto \exp\big(\sum_t f_\theta(x_n)_{t,s_t} + \sum_t \log g(s_{t-1},s_t)\big)$, where $f_\theta$ is the encoder's per-epoch score and $g$ is a stage-transition model with minimum-duration states. The normalizer is computed by forward-backward over all sequences; speech recognition calls this the "denominator graph." Training minimizes

$$\mathcal{L}(\theta)=-\sum_n \log \sum_{s\in\mathcal{N}_n} p(s\mid x_n),$$

where $\mathcal{N}_n$, the "numerator set," contains the sequences that match night $n$'s scored epochs and keep, at every unscored epoch, only stages whose posterior under a lagged copy of the model exceeds a threshold $\tau$. Three limits of this set correspond to familiar methods. With $\tau=0$ the objective is a partial-label linear-chain conditional random field (CRF), which sums over all completions of the unscored epochs. With $\tau$ high enough to leave one path, it becomes hard pseudo-labeling. The claim is that an intermediate, encoder-pruned set beats both limits.

Relation to Prior Work

The method comes from speech. Sequential Classification Criteria for NNs in ASR trains against the correct path versus competing paths in a lattice. Xiong et al. and Purely Sequence-Trained Neural Networks Based on LF-MMI removed precomputed lattices and cross-entropy initialization. Our denominator is the same lattice-free construction, and it becomes cheap because five stages over a thousand epochs is a tiny graph. LF-MMI Adaptation of Self-Supervised Pretrained Acoustic Models is the closest single paper. It shows that sequence-level adaptation of a masked-pretrained encoder beats cross-entropy adaptation, with roughly 10% relative word-error reduction on LibriSpeech test-clean and 35.3% on test-other. However, it uses 100 hours of fully transcribed speech and never studies partial or uncertain supervision. Our proposal differs on both axes: it uses non-speech biosignals, and its central object is a pruned set of acceptable sequences under a fixed label budget.

Three semi-supervised speech papers motivate the numerator design, and they also constrain it. Unbiased Semi-Supervised LF-MMI Using Dropout shows that numerator graphs built from a single seed-model estimate bias training. Plain semi-supervised training recovers 53.7% of the possible word-error improvement on Fisher, while sampling 20 dropout decodings recovers 77.6%. On Semi-Supervised LF-MMI with Limited Data shows that with 4–5 labeled hours, noisy hypotheses damage training unless a separately trained error detector widens the graph in suspect regions. Leveraging Unlabeled Speech for Sequence Discriminative Training instead relies on a strong teacher trained on tens of thousands of labeled hours. All three widen the numerator to fight bias, but each pays for it with repeated decoding, an extra detector, or a big teacher. We test whether a self-supervised encoder's single-pass posteriors, constrained by expert anchors scattered throughout each night, can do the widening themselves. That is the open question the file's Gap 2 identifies.

On the biosignal side, DeepSleepNet and U-Sleep both treat transitions as important, but they encode them architecturally under per-epoch cross-entropy. DeepSleepNet also needs a class-rebalancing pretraining stage. Both serve as fully supervised reference points rather than competitors in the label-scarce regime. TS-TCC supplies a self-supervised encoder with a public codebase (TS-TCC code). It reports about 70% accuracy on activity recognition with 1% of labels, and it was evaluated on Sleep-EDF, but no reported Sleep-EDF number was found on Lacuna. LaBraM (code) offers a larger EEG encoder pretrained on more than 2,500 hours. Benchmarking ECG FMs motivates the work from the other direction. It finds 3.3–9x label efficiency for foundation models, but also a gap on structured and sequential tasks, and adaptation there was always window-level.

Research Program

We build one training pipeline with three swappable parts. The first is the encoder: a TS-TCC encoder pretrained on all unlabeled nights, a LaBraM encoder, and a randomly initialized control. The second is a transition model $g$, estimated from scored adjacent-epoch pairs and smoothed toward a generic sleep prior, with minimum-duration chains for N3 and REM. The third is the numerator constructor, controlled by $\tau$ and refreshed every few epochs from an exponential-moving-average copy of the model. Forward-backward runs in plain PyTorch. Pkwrap is a drop-in option if we later move to finite-state-transducer graphs.

Annotation is simulated from fully scored corpora by revealing epochs under a fixed budget $B$ of 1%, 2%, 5% or 10% of all epochs. We compare three allocation schemes. "Dense" scores whole nights. "Scattered" scores random epochs across all nights. "Spaced" scores epochs at roughly fixed intervals within each night. The analysis asks how the value of an anchor depends on its distance to the nearest other anchor, and whether the pruned numerator stays correct, meaning it still contains the true path, as anchors become rarer. Numerator coverage of the true sequence is the main diagnostic. Our hypothesis is that self-supervised pretraining raises coverage at a fixed numerator size compared with a scratch encoder, which would answer Gap 2 directly.

Baselines

The naive reference is per-epoch cross-entropy on the scored epochs only, applied to the same pretrained encoder with a linear head. We report it under both dense and scattered allocation, because dense allocation is what labs do today. A second reference adds post-hoc smoothing: the same classifier decoded at test time with Viterbi under $g$. This checks whether the grammar helps only at inference.

The strongest existing competitor is a sequence-aware encoder trained with cross-entropy, in the style of DeepSleepNet: the pretrained encoder followed by a bidirectional recurrent layer, trained on dense nights. Its fully supervised numbers bound what full labels buy. DeepSleepNet reports 82.0% accuracy and 76.9 macro-F1 on Sleep-EDF and 86.2% / 81.7 on MASS, and U-Sleep reports F1 of 0.79 on DOD-H and 0.76 on DOD-O. We will rerun this architecture ourselves at every budget rather than compare to these full-label figures. A second strong competitor is hard pseudo-labeling with confidence thresholding on unscored epochs. A third is the speech-style remedy for numerator bias: dropout-sampled numerators with 20 passes, following the Unbiased LF-MMI paper.

The key ablation is the $\tau$ sweep. It isolates the proposal's ingredient, encoder-pruned numerators, from its two limits, the partial-label CRF at $\tau=0$ and pseudo-labeling with a single path.

All arms share encoder checkpoints, the same scored epochs, and the same unlabeled nights. Each gets an equal hyperparameter search of 30 trials on a held-out set of subjects, and training is matched in wall-clock time. The dropout baseline gets its extra decoding passes free of charge so that it is not penalized for compute. Beating the field means a statistically significant macro-F1 gain at 2% or fewer epochs over both the best cross-entropy arm and the $\tau=0$ CRF, evaluated with cross-validation over subjects across at least three seeds.

Why not just…?

Why not just use a partial-label CRF? This is the real threat. With a fixed grammar, our objective at $\tau=0$ is exactly a partial-label CRF. If the CRF matches the pruned version, the honest conclusion is that the contribution is the allocation result, scattered labels plus sequence marginalization, rather than a new objective. The $\tau$ sweep settles this directly. Our hypothesis is that at very sparse budgets, $\tau=0$ spreads probability mass over implausible completions of long unscored stretches, and this is the same bias the semi-supervised speech papers documented in the opposite direction. Coverage-versus-size curves will show whether that happens.

Why not just pseudo-label with confidence thresholds? The Unbiased LF-MMI paper shows that single-hypothesis supervision recovers far less (53.7% versus 77.6% recovery), and the limited-data LF-MMI paper shows it can actively degrade models when seed data is scarce. Both results come from speech, though, and a strong pretrained encoder could close the gap. Pseudo-labeling is run as the single-path limit of the same sweep, so it is compared under identical conditions.

Why not just fine-tune a temporal encoder with cross-entropy on densely scored nights? The LF-MMI adaptation paper found that bidirectional attention did not remove the benefit of a sequence-level loss in speech. Dense allocation also concentrates labels on few subjects, which increases variation between subjects. The dense-versus-scattered comparison measures both effects, and if dense cross-entropy wins at matched budget, the proposal fails.

Decisive Checks

The work succeeds if three things hold together. Scattered allocation with pruned numerators must beat dense cross-entropy at 1–2% budgets on Sleep-EDF and MASS. The gain must persist on the apnea cohort DOD-O, where transitions are disrupted. And pretrained encoders must achieve higher numerator coverage than scratch encoders at equal numerator size. Beyond per-epoch accuracy and macro-F1, we report N1 F1, transition-count error, and error in derived quantities: wake after sleep onset, REM latency, and minutes in N3. A sequence objective should show its advantage most clearly in these. A null result is also informative. If the $\tau=0$ CRF, dense cross-entropy, and the pruned objective tie, then the encoder already captures sleep structure, and the speech literature's numerator machinery is unnecessary once representations are pretrained.