arXiv:2610.19557cs.LGOct 2026

Manuscript Offprint

arXiv:2610.19557

TEX-MEX: Similarity-Guided Temporal Contrastive Learning for Time Series

Aditya Radhakrishnan, Maxwell A. Xu, Wanting Mao, Santosh Kumar, Harish Haresamudram, James M. Rehg

ABSTRACT

Contrastive learning for time series depends on deciding which pairs of inputs should be treated as similar and dissimilar. Because few augmentations reliably preserve meaning in time series, prior methods have relied on two disjoint notions of similarity between windows: structural similarity, which relates windows with similar morphology, and temporal similarity, which relates windows that occur close together in time. We introduce TEX-MEX, to our knowledge the first approach to unify the two into a single relationship. Given a random batch of windows drawn across the dataset, TEX-MEX uses the encoder to identify which windows are structurally similar or dissimilar to each other. It then pulls each window toward the temporally shifted versions of similar windows and pushes it away from those of dissimilar ones, learning what typically accompanies similar windows in time. Across PPG, EEG, ECG, accelerometry, and continuous glucose monitoring, TEX-MEX broadly achieves state-of-the-art performance against contrastive, reconstructive, JEPA-based, and modality-specific approaches, establishing it as a strong general SSL objective. We further train a 560K-parameter PPG foundation model that achieves state-of-the-art performance across a broad range of downstream benchmarks while being roughly 50×50\times smaller than the next-best unimodally pretrained PPG foundation model in our evaluation. We will release this foundation model open-source and open-weight to the community to support future work and practical applications.

1 INTRODUCTION

Self-supervised learning (SSL) has emerged as the dominant paradigm for learning generalizable representations from large-scale unlabeled data (Chen et al., 2020; He et al., 2022). This approach is particularly attractive for modeling physiological signals, such as photoplethysmography (PPG) or electrocardiography (ECG), which are routinely captured as time series data by wearables (e.g. smart watches) or medical devices. Labeling clinically-important events in such data (such as atrial fibrillation in an ECG recording) typically requires expert interpretation, invasive assays, or controlled clinical settings (Xu et al., 2024), and is very difficult to perform at scale. At the same time, the increasing adoption of smart watches by the general public and the large-scale aggregation of waveform data within electronic health records has created an opportunity to develop foundation models for such physiological signals (Xu et al., 2025; Saha et al., 2025; Ansari et al., 2025). Such models could enable new data-driven approaches to modeling states of health and disease.

Time series representation learning is challenging due to the need to capture statistical dependencies across widely-varying temporal scales (Goldberger et al., 2002). For example, heart rate, which is measurable via PPG, is correlated at the level of minutes in responding to physiological demands such as exercise, but is also correlated at the level of hours due to the diurnal cycle. Weekly patterns of stress or physical activity, such as regular commute times or exercise routines, can induce even longer-range correlational structure. A key step in developing foundation models for such data is the identification of effective pretext tasks. Two common approaches are contrastive learning,

∗^{*}Also affiliated with Google.

Figure

Sample random batch of windows across the dataset.

2

Figure

Use encoder fθf_{\theta} representation distance to score how similar windows are.

3

Random past or future window δ\delta

Figure

Draw similar shifted windows toward anchor against dissimilar shifted windows.

Figure 1: Overview of TEX-MEX. (1) Windows of sensor data are randomly sampled from the dataset; (2) The encoder scores each window's similarity to an anchor (here, x1x_1) using cosine similarity; (3) Each window is offset in time (forward or backward) by a random δ\delta (here, +3 windows). The anchor is pulled toward the temporal shifts of similar windows and away from those of dissimilar ones, in proportion to the similarity, composing structural and temporal notions.

which extracts windows of samples from a time series recording to construct positive and negative pairs, and masked autoencoding, which uses temporal context to reconstruct the samples within a masked-out window. Contrastive learning is a particularly useful lens for examining time series representation learning as it provides a way to explicitly reason about similarity and dissimilarity.

Unfortunately, time series recordings typically lack a rich set of well-defined invariances from which positive pairs can be constructed (Xu et al., 2024). As a consequence, prior contrastive learning works have adopted one of two disjoint approaches to defining similarity between windows: structural similarity approaches that index on signal morphology or frequency content (i.e., windows are similar if they contain similar waveform shapes, like two heart beats in an ECG waveform) (Xu et al., 2025; 2024), and temporal similarity measures that index on temporal proximity (i.e., two windows are similar if they occur close together in time, such as when a cool-down period follows a period of vigorous exercise) (Tonekaboni et al., 2021; Oord et al., 2018). In contrast, this paper proposes, to our knowledge, the first contrastive learning approach which unifies structural and temporal similarity measures into a single framework. We demonstrate that the standard approach of generating positive pairs by mining morphologically-similar patterns from time series recordings (Xu et al., 2024) can be extended by composing it with temporal similarity, drawing positive and negative pairs from the temporal context of similar and dissimilar windows. This unifies the two primary sources of similarity in time series modeling: windows that correspond to similar physiological processes (e.g., two heartbeats) will have similar morphology, while windows which map onto stable patterns of human behavior (e.g., cool-down following exercise) will be temporally co-occurring. An exercise window, for instance, can learn from the cool-downs that follow exercise in other recordings, capturing what typically follows exercise rather than what followed it once.

We introduce TEX-MEX: for each anchor window, it first identifies similar and dissimilar windows within a random batch drawn across the dataset. Every window is then shifted by the same random offset, forward or backward in time, redrawn in each batch to span many timescales. TEX-MEX pulls the anchor toward the shifted versions of similar windows and pushes it away from those of dissimilar windows. We find that the encoder's own representations suffice for measuring this similarity, eliminating the costly signal distance measures of prior methods (Xu et al., 2024). Unlike those fixed measures, this similarity improves as the encoder trains, ultimately surpassing them. Because it is graded rather than binary, TEX-MEX is naturally a soft contrastive method (Lee et al., 2024; Xu et al., 2025), weighting each shifted window by its source window's similarity to the anchor, which captures degrees of relatedness and adds robustness to false negatives. The main contributions of our work are as follows:

  1. We introduce TEX-MEX, a contrastive objective that unifies structural and temporal similarity by contrasting the shifted versions of similar windows against those of dissimilar windows, with similarity derived from the encoder's own representations.

  2. We show that this representation-space similarity improves throughout training, surpassing existing signal distance approaches as a predictor of mutual class membership.

  3. We demonstrate the generality of TEX-MEX across PPG, ECG, accelerometry, EEG, and CGM, where it broadly achieves state-of-the-art performance against leading contrastive, reconstructive, JEPA-based, and modality-specific methods.

  4. Leveraging its efficiency, we train and will release an open-source, open-weight PPG foundation model that achieves state-of-the-art performance across a range of downstream tasks with just 560K parameters, roughly 50×50\times smaller than the next-best unimodally pretrained PPG foundation model in our evaluation.

References (42)