SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2312.10308 · NeurIPS · 2023

Event-Based Contrastive Learning for Medical Time Series

Aparna Balagopalan, Matthew Mcdermott, Collin Stultz, Nassim Oufattole, Hyewon Jeong, Bryan Jangeesingh

arXiv · PDF · Open in the Atlas

Code that ran

8 of 14 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (5 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 2 failures of our instrument; 6 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2312.10308.json · badge: /api/ran/2312.10308.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
mit-ccrg/ebcl canonical (classifier label)
classifier basis: classifier_2025
8 ran · 6 no recorded run
FunctionStatusWhere it lives
CVE Ran
ran on a synthesized input · constructed an object; no result was computed
mit-ccrg/ebcl/src/model/ebcl_model.py
code served (permissive licence) · get_code("69d80d4524739a8a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, CVE: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from torch import nn

torch.manual_seed(0)

class Args:
    def __init__(self):
        self.embed_size = 4

ARGS = {
    'args': Args()
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type CVE — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a CVE output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
EBCLPretrainOutput Ran
ran on a synthesized input · constructed an object; no result was computed
mit-ccrg/ebcl/src/model/ebcl_model.py
code served (permissive licence) · get_code("2111533cca8418e0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, EBCLPretrainOutput: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import dataclasses

torch.manual_seed(0)

# Create tiny tensors with distinct dimensions
batch_size = 2
embed_dim = 4
num_tokens = 3
attention_heads = 2

# Loss as float
loss_value = 0.5

# Logits tensors (batch, sequence, vocab or similar)
logits_per_pre = torch.randn(batch_size, num_tokens, embed_dim)
logits_per_post = torch.randn(batch_size, num_tokens, embed_dim)

# Embedding tensors
post_embeds = torch.randn(batch_size, num_tokens, embed_dim)
pre_embeds = torch.randn(batch_size, num_tokens, embed_dim)

# Normalized embeddings
pre_norm_embeds = torch.randn(batch_size, num_tokens, embed_dim)
post_norm_embeds = torch.randn(batch_size, num_tokens, embed_dim)

# Model outputs
post_model_output = torch.randn(batch_size, num_tokens, embed_dim)
pre_model_output = torch.randn(batch_size, num_tokens, embed_dim)

# Attention tensors
pre_attn = torch.randn(batch_size, attention_heads, num_tokens, num_tokens)
post_attn = torch.randn(batch_size, attention_heads, num_tokens, num_tokens)

ARGS = {
    'loss': loss_value,
    'logits_per_pre': logits_per_pre,
    'logits_per_post': logits_per_post,
    'post_embeds': post_embeds,
    'pre_embeds': pre_embeds,
    'pre_norm_embeds': pre_norm_embeds,
    'post_norm_embeds': post_norm_embeds,
    'post_model_output': post_model_output,
    'pre_model_output': pre_model_output,
    'pre_attn': pre_attn,
    'post_attn': post_attn,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EBCLPretrainOutput — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a EBCLPretrainOutput output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
FFAttention Ran
ran on a synthesized input
mit-ccrg/ebcl/src/model/ebcl_model.py
code served (permissive licence) · get_code("9fb5d2d2844f8a56")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

class Args:
    def __init__(self):
        self.seq_len = 5
        self.embed_size = 4

args_obj = Args()

INIT_ARGS = {
    'args': args_obj
}

batch_size = 2
seq_len = 5
embed_size = 4

x_e = torch.randn(batch_size, seq_len, embed_size)
mask = torch.zeros(batch_size, seq_len)

ARGS = {
    'x_e': x_e,
    'mask': mask,
    'training': True
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
OutputBase Ran
ran on a synthesized input · constructed an object; no result was computed
mit-ccrg/ebcl/src/model/ebcl_model.py
code served (permissive licence) · get_code("11cab82b5016e637")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, OutputBase: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import dataclasses
import torch

torch.manual_seed(0)

@dataclasses.dataclass
class OutputBase:
    loss: torch.Tensor

# Construct a small loss tensor
loss_tensor = torch.tensor([0.5], dtype=torch.float32)

# Define arguments dict
ARGS = {
    'loss': loss_tensor
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type OutputBase — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a OutputBase output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
StratsModelConfig Ran
ran on a synthesized input · constructed an object; no result was computed
mit-ccrg/ebcl/src/model/ebcl_model.py
code served (permissive licence) · get_code("5aa07e7c9e4e7cdc")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, StratsModelConfig: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import dataclasses
import enum
import re
from typing import Any
import hydra

class Architecture(enum.Enum):
    XFORMER = 'xformer'
    SMALL = 'small'
    MEDIUM = 'medium'
    LARGE = 'large'

class SupervisedView(enum.Enum):
    PRE = 'pre'
    POST = 'post'
    EARLY_FUSION = 'early_fusion'
    PRE_AND_POST = 'pre_and_post'

def hydra_dataclass(dataclass: Any) -> Any:
    """Decorator that allows you to use a dataclass as a hydra config via the `ConfigStore`"""
    dataclass = dataclasses.dataclass(dataclass)
    name = dataclass.__name__
    name = re.sub('(?<!^)(?=[A-Z])', '_', name).lower()
    cs = hydra.core.config_store.ConfigStore.instance()
    cs.store(name=name, node=dataclass)
    return dataclass

@hydra_dataclass
class StratsModelConfig:
    """EBCL Configuration"""
    pretrain: bool = True
    seq_len: int = 512
    embed_size: int = 32
    dim_feedforward: int = 128
    dropout: float = 0.5
    projection_dim: int = 32
    encoder_dim: int = 32
    architecture_size: Architecture = Architecture.MEDIUM
    n_cat_value: int = 7761
    n_variable: int = 3275
    n_cat_variable: int = 52
    eps: float = 0.0001
    modalities: SupervisedView = SupervisedView.PRE_AND_POST
    lr: float = 0.0003
    shared_transformer: bool = True
    batch_size: int = 256
    half_dtype: bool = False
    batch_first: bool = True
    bootstrap: bool = False

    def __post_init__(self):
        assert self.embed_size == self.projection_dim
        assert self.embed_size == self.encoder_dim

ARGS = {
    'pretrain': True,
    'seq_len': 512,
    'embed_size': 32,
    'dim_feedforward': 128,
    'dropout': 0.5,
    'projection_dim': 32,
    'encoder_dim': 32,
    'architecture_size': Architecture.MEDIUM,
    'n_cat_value': 7761,
    'n_variable': 3275,
    'n_cat_variable': 52,
    'eps': 0.0001,
    'modalities': SupervisedView.PRE_AND_POST,
    'lr': 0.0003,
    'shared_transformer': True,
    'batch_size': 256,
    'half_dtype': False,
    'batch_first': True,
    'bootstrap': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
hydra — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type StratsModelConfig — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a StratsModelConfig output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
SupervisedOutput Ran
ran on a synthesized input · constructed an object; no result was computed
mit-ccrg/ebcl/src/model/ebcl_model.py
code served (permissive licence) · get_code("47502c05315c780f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, SupervisedOutput: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import dataclasses

torch.manual_seed(0)

@dataclasses.dataclass
class OutputBase:
    loss: torch.Tensor

@dataclasses.dataclass
class SupervisedOutput(OutputBase):
    final_output: torch.Tensor
    post_embeds: torch.Tensor
    pre_embeds: torch.Tensor
    post_model_output: torch.Tensor
    pre_model_output: torch.Tensor
    pre_attn: torch.Tensor
    post_attn: torch.Tensor
    loss: torch.Tensor

ARGS = {
    "loss": torch.randn(2),
    "final_output": torch.randn(2, 4),
    "post_embeds": torch.randn(2, 3),
    "pre_embeds": torch.randn(2, 5),
    "post_model_output": torch.randn(2, 6),
    "pre_model_output": torch.randn(2, 7),
    "pre_attn": torch.randn(2, 8),
    "post_attn": torch.randn(2, 9),
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type SupervisedOutput — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a SupervisedOutput output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
hydra_dataclass Ran
ran; our contract draft was wrong, not the code
mit-ccrg/ebcl/src/model/ebcl_model.py
code served (permissive licence) · get_code("567a16ae6c552b3a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned type. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import dataclasses
import torch
import hydra
from hydra.core.config_store import ConfigStore

# Define a simple dataclass to pass as the argument
@dataclasses.dataclass
class SampleConfig:
    learning_rate: float = 0.001
    batch_size: int = 32
    epochs: int = 10

ARGS = {
    "dataclass": SampleConfig
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
hydra, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type type — a type output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a type output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
sequence_mask Ran
ran; our contract draft was wrong, not the code
mit-ccrg/ebcl/src/model/ebcl_model.py
code served (permissive licence) · get_code("edd8dd6147b4ded8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Construct arguments for sequence_mask function
lengths = torch.tensor([2, 3], dtype=torch.long)  # batch size 2
maxlen = 4
dtype = torch.bool

ARGS = {
    "lengths": lengths,
    "maxlen": maxlen,
    "dtype": dtype
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
Architecture Not yet run
unverified (harvested, no recorded run)
mit-ccrg/ebcl/src/model/ebcl_model.py
code served (permissive licence) · get_code("2847195cff078ccc")
How it ran

no invocation recorded.

Dtype Not yet run
unverified (harvested, no recorded run)
mit-ccrg/ebcl/src/model/ebcl_model.py
code served (permissive licence) · get_code("df0b4dffc58cc48c")
How it ran

no invocation recorded.

EBCLModule Not yet run
unverified (harvested, no recorded run)
mit-ccrg/ebcl/src/model/ebcl_model.py
code served (permissive licence) · get_code("abe335dfe4a571a9")
How it ran

no invocation recorded.

SupervisedModule Not yet run
unverified (harvested, no recorded run)
mit-ccrg/ebcl/src/model/ebcl_model.py
code served (permissive licence) · get_code("55d7852fe9814e49")
How it ran

no invocation recorded.

SupervisedView Not yet run
unverified (harvested, no recorded run)
mit-ccrg/ebcl/src/model/ebcl_model.py
code served (permissive licence) · get_code("bbbc72e4a38d2348")
How it ran

no invocation recorded.

TransformerModel Not yet run
unverified (harvested, no recorded run)
mit-ccrg/ebcl/src/model/ebcl_model.py
code served (permissive licence) · get_code("55450ad42bd86a07")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 14 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

In clinical practice, one often needs to identify whether a patient is at high risk of adverse outcomes after some key medical event. For example, quantifying the risk of adverse outcomes after an acute cardiovascular event helps healthcare providers identify those patients at the highest risk of poor outcomes; i.e., patients who benefit from invasive therapies that can lower their risk. Assessing the risk of adverse outcomes, however, is challenging due to the complexity, variability, and heterogeneity of longitudinal medical data, especially for individuals suffering from chronic diseases like heart failure. In this paper, we introduce Event-Based Contrastive Learning (EBCL) -a method for learning embeddings of heterogeneous patient data that preserves temporal information before and after key index events. We demonstrate that EBCL can be used to construct models that yield improved performance on important downstream tasks relative to other pretraining methods. We develop and test the method using a cohort of heart failure patients obtained from a large hospital network and the publicly available MIMIC-IV dataset consisting of patients in an intensive care unit at a large tertiary care center. On both cohorts, EBCL pretraining yields models that are performant with respect to a number of downstream tasks, including mortality, hospital readmission, and length of stay. In addition, unsupervised EBCL embeddings effectively cluster heart failure patients into subgroups with distinct outcomes, thereby providing information that helps identify new heart failure phenotypes. The contrastive framework around the index event can be adapted to a wide array of time-series datasets and provides information that can be used to guide personalized care. * Equal contribution.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2312.10308")
get_code_for_paper("2312.10308")
have("2312.10308")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2312.10308.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2312.10308.svg)](https://syntology.ai/paper/2312.10308)

Connect an agent — have() is free.