Update card, add dataloader
Browse filesFiles changed (2)
- README.md+75-157
- lapras_dataloader.pyAdded+48
95 unmodified lines969798991001011021031049 unmodified lines1141151161171181191201211221231241251261271281291301318 unmodified lines1401411421431441451461471481491501511521539 unmodified lines16316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931095 unmodified lines- **Curated by:** <AUTHORS>- **Language(s) (NLP):** English- **License:** mixed, per subset (see [Licensing Information](#licensing-information))### Dataset Sources- **Repository:** <CODE_URL>- **Paper:** <ARXIV_URL>9 unmodified lineshuggingface-cli download LeoChen085/Lapras-Reasoning-Datasets --repo-type dataset --include "*.jsonl" --local-dir dataset``````pythonfrom datasets import load_datasetds = load_dataset("LeoChen085/Lapras-Reasoning-Datasets", "sleep")```Use the plain configs for models that receive the series through a separate encoder input (e.g. SLIP), andthe `*_ts_tags` configs for models that splice the series into the token sequence (e.g. ChatTS, OpenTSLM).### Out-of-Scope Use- Clinical decision making. The ECG and Sleep subsets are research benchmarks, not validated diagnostic data.- Treating the reference traces as expert-verified explanations (see [Bias, Risks, and Limitations](#bias-risks-and-limitations)).## Dataset Structure8 unmodified lines| Config | Task | Train | Test | Channels | Length | Answer ||---|---|---:|---:|---:|---:|---|| `ecg` | cardiological diagnosis | 5,800 | 643 | 12 | 1000 | `Yes` / `No` || `sleep` | sleep-stage classification | 7,413 | 923 | 1 | 1500 | 5 stages || `har` | human activity recognition | 68,542 | 8,222 | 3 | 128 | 8 activities || `tsr` | counterfactual consequence prediction | 22,566 | 4,094 | 1 | 128–1020 | option letter + text (`A`–`D`) || `engine` | aero-engine fault diagnosis | 2,305 | 193 | 33 | 600 | option letter (`a`–`d`) |Labels: Sleep — `Wake`, `Non-REM stage 1`, `Non-REM stage 2`, `Non-REM stage 3`, `REM sleep`;HAR — `biking`, `lying`, `running`, `sitting`, `standing`, `walking`, `walking_down`, `walking_up`.### Data Fields- `input` (string): the prompt (question, instructions and, for multiple choice, the options).9 unmodified linesThe `*_with_ts_tags` files contain the same rows in the same order; only `input` differs, by theplaceholder lines prepended to the prompt.## Dataset Creation### Curation RationaleLatent-reasoning methods such as Lapras distill a reference reasoning trace into continuous thoughts, so everytask needs a trace. The five tasks were chosen to span medical, activity, synthetic-scenario and industrialsignals with different channel counts and series lengths.### Source Data#### Data Collection and Processing- **ECG** — from ECG-Reasoning-Benchmark (Oh et al., 2026), whose ECGs come from MIMIC-IV-ECG and PTB-XL(12 leads, 10 s at 100 Hz). The multi-stage benchmark is reformatted into single binary diagnosisquestions; the trace concatenates the per-stage gold answers (criterion selection → findingidentification → ECG grounding → diagnostic decision).- **Engine** — from EngineMT-QA (Wang et al., 2025), built on NASA's N-CMAPSS. Only samples with a certifiedper-component health label are kept; the trace is generated deterministically from these labels(component roll-call → severity → maintenance implication). Examples shared between the source splits were removed.- **HAR** and **Sleep** — prompts, series and labels from the OpenTSLM HAR-CoT and SleepEDF-CoT releases(Langer et al., 2026). HAR-CoT combines DaLiAc, DOMINO, HHAR, PAMAP2, RealWorld and the Shoaib et al.datasets (3-axis accelerometer, 50 Hz, 2.56 s windows); Sleep-CoT uses 30 s EEG epochs from Sleep-EDF.- **TSR** — series pairs (original and counterfactual) from the two-series subset of Merrill et al. (2024),whose series are synthetic and depict real-world scenarios. For each pair, a consequence question withfour options was written with Qwen3.5-27B from a qualitative feature that differs between the two series;only pairs whose correct answers differ were kept. Splits are by source series, so no series appears in both.#### Who are the source data producers?The authors of the source datasets cited below.### Annotations#### Annotation processECG and Engine traces are assembled from the sources' annotated labels. HAR, Sleep and TSR traces aregenerated with Qwen3.5-27B following ARTIST (Messica et al., 2026): the model is conditioned on plots of thesignal, summary statistics and the gold answer, selects at most three segments, and explains the answer fromthem. Traces were checked automatically for answer correctness and template adherence.#### Who are the annotators?No human annotation was added. Labels come from the source datasets; traces are template-based or model-generated.#### Personal and Sensitive InformationECG and Sleep recordings come from de-identified, open-access PhysioNet datasets (MIMIC-IV-ECG, PTB-XL,Sleep-EDF). The ECG `_uid` field carries the de-identified source record identifiers. No names ordemographics are included in the prompts.## Bias, Risks, and Limitations- Model-generated traces (HAR, Sleep, TSR) were produced with access to the gold answer and mayrationalize it rather than reflect evidence in the signal.- TSR series are synthetic, and its questions and options are model-written.- Class imbalance: e.g. `Wake` is ~45% of Sleep and `sitting` ~28% of HAR; the Engine test set has few healthy engines.- Sleep splits are at the epoch level, not the subject level; Engine splits are disjoint by sample id, not by engine unit.- No validation split is provided.### RecommendationsReport results on the test split without using it for model or hyperparameter selection, and do not use thedata for clinical purposes.## Licensing InformationThe collection is released under per-subset terms that follow its sources. The ECG subset is released underthe **Open Database License v1.0 (ODbL)**, as required by the share-alike terms of MIMIC-IV-ECG (as is itsdirect source, ECG-Reasoning-Benchmark). The other subsets remain subject to the terms of their sources:| Subset | Source | Source license ||---|---|---|| ECG | ECG-Reasoning-Benchmark; MIMIC-IV-ECG v1.0; PTB-XL v1.0.3 | ODbL 1.0; ODbL 1.0; CC BY 4.0 || Sleep | OpenTSLM SleepEDF-CoT; Sleep-EDF Database Expanded v1.0.0 | MIT (OpenTSLM project); ODC-By 1.0 || HAR | OpenTSLM HAR-CoT (and its source HAR datasets) | MIT (OpenTSLM project); see each source || TSR | Merrill et al. (2024), `mikeam/time-series-reasoning` | code MIT; the dataset declares no license || Engine | EngineMT-QA (N-CMAPSS) | MIT |## CitationIf you use this dataset, please cite Lapras and the source datasets.**BibTeX:**```bibtex@inproceedings{lapras2027,title = {Lapras: Latent Reasoning for Time Series Language Models},author = {<AUTHORS>},booktitle = {<VENUE>},year = {2027}}@misc{oh2026ecgreasoning,title = {ECG-Reasoning-Benchmark: A Benchmark for Evaluating Clinical Reasoning Capabilities in ECG Interpretation},author = {Jungwoo Oh and Hyunseung Chung and Junhee Lee and Min-Gyu Kim and Hangyul Yoon and Ki Seong Lee and Youngchae Lee and Muhan Yeo and Edward Choi},year = {2026},eprint = {2603.14326},archivePrefix = {arXiv}}@misc{langer2026opentslm,title = {OpenTSLM: Time-Series Language Models for Reasoning over Multivariate Medical Text- and Time-Series Data},author = {Patrick Langer and Thomas Kaar and Max Rosenblattl and Maxwell A. Xu and Winnie Chow and Martin Maritsch and Robert Jakob and Ning Wang and Juncheng Liu and Aradhana Verma and Brian Han and Daniel Seung Kim and Henry Chubb and Scott Ceresnak and Aydin Zahedivash and Alexander Tarlochan Singh Sandhu and Fatima Rodriguez and Daniel McDuff and Elgar Fleisch and Oliver Aalami and Filipe Barata and Paul Schmiedmayer},year = {2026},eprint = {2510.02410},archivePrefix = {arXiv}}@inproceedings{merrill2024language,title = {Language Models Still Struggle to Zero-shot Reason about Time Series},author = {Merrill, Mike A and Tan, Mingtian and Gupta, Vinayak and Hartvigsen, Thomas and Althoff, Tim},booktitle = {Findings of the Association for Computational Linguistics: EMNLP 2024},pages = {3512--3533},year = {2024},doi = {10.18653/v1/2024.findings-emnlp.201}}@misc{wang2025itformer,title = {ITFormer: Bridging Time Series and Natural Language for Multi-Modal QA with Large-Scale Multitask Dataset},author = {Yilin Wang and Peixuan Lei and Jie Song and Yuzhe Hao and Tao Chen and Yuxuan Zhang and Lei Jia and Yuanxiang Li and Zhongyu Wei},year = {2025},eprint = {2506.20093},archivePrefix = {arXiv}}@misc{messica2026artist,title = {Adaptive Time Series Reasoning via Segment Selection},author = {Shvat Messica and Jiawen Zhang and Kevin Li and Theodoros Tsiligkaridis and Marinka Zitnik},year = {2026},eprint = {2602.18645},archivePrefix = {arXiv}}```PhysioNet sources (please also cite):- Gow, B., et al. (2023). MIMIC-IV-ECG: Diagnostic Electrocardiogram Matched Subset (version 1.0). PhysioNet. https://doi.org/10.13026/4nqg-sb35- Wagner, P., Strodthoff, N., Bousseljot, R., Samek, W., & Schaeffter, T. (2022). PTB-XL, a large publicly available electrocardiography dataset (version 1.0.3). PhysioNet. https://doi.org/10.13026/kfzx-aw45- Wagner, P., et al. (2020). PTB-XL, a large publicly available electrocardiography dataset. Scientific Data. https://doi.org/10.1038/s41597-020-0495-6- Kemp, B., et al. Sleep-EDF Database Expanded (version 1.0.0). PhysioNet. https://physionet.org/content/sleep-edfx/1.0.0/- Pollard, T., et al. (2026). PhysioNet as a global platform for biomedical research. Nature Health. https://doi.org/10.1038/s44360-026-00096-z## Dataset Card Contact<CONTACT>95 unmodified lines969798991001011021031049 unmodified lines1141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871888 unmodified lines1971981992002012022032042052062079 unmodified lines21721821922022122222322422522622722895 unmodified lines- **Curated by:** <AUTHORS>- **Language(s) (NLP):** English- **License:** per subset (see [Data Sources](#data-sources))### Links- **Repository:** <CODE_URL>- **Paper:** <ARXIV_URL>9 unmodified lineshuggingface-cli download LeoChen085/Lapras-Reasoning-Datasets --repo-type dataset --include "*.jsonl" --local-dir dataset```### Quick start```pythonfrom datasets import load_datasetds = load_dataset("LeoChen085/Lapras-Reasoning-Datasets", "har")print(ds)``````DatasetDict({train: Dataset({features: ['input', 'timeseries', 'output'],num_rows: 68542})test: Dataset({features: ['input', 'timeseries', 'output'],num_rows: 8222})})```Each row is a dict with `input` (str), `timeseries` (list of channels, each a list of floats) and `output` (str).### Processor, collator and DataLoader[`lapras_dataloader.py`](lapras_dataloader.py) holds a standard multimodal processor and collator, as forvision-language models: the processor tokenizes the text and packs the time series into a tensor, and thecollator builds training batches in which only the response is supervised.```pythonfrom huggingface_hub import hf_hub_downloadhf_hub_download("LeoChen085/Lapras-Reasoning-Datasets", "lapras_dataloader.py", repo_type="dataset", local_dir=".")from torch.utils.data import DataLoaderfrom transformers import AutoTokenizerfrom lapras_dataloader import TimeSeriesProcessor, TimeSeriesCollatorprocessor = TimeSeriesProcessor(AutoTokenizer.from_pretrained("Qwen/Qwen3-8B"))loader = DataLoader(ds["train"], batch_size=4, shuffle=True, collate_fn=TimeSeriesCollator(processor))batch = next(iter(loader))``````input_ids (4, 514) torch.int64 # length varies by batchattention_mask (4, 514) torch.int64timeseries (4, 3, 128) torch.float32 # (batch, channels, length), zero-paddedtimeseries_mask (4, 3, 128) torch.bool # True on real sampleslabels (4, 514) torch.int64 # -100 on the prompt and padding```Series of different lengths (TSR) are zero-padded to the longest in the batch and marked in `timeseries_mask`.### Decoding back```pythontok = processor.tokenizerids = batch["input_ids"][0][batch["attention_mask"][0].bool()]tok.decode(ids)# '<|im_start|>user\nYou are given accelerometer data in all three dimensions. ... <|eot|>\nAnswer: sitting<|im_end|>'target = tok.decode(batch["labels"][0][batch["labels"][0] != -100], skip_special_tokens=True)target # the example's `output`, character for charactertarget.rsplit("Answer:", 1)[1].strip() # e.g. 'sitting'n_ch = batch["timeseries_mask"][0].any(-1).sum()batch["timeseries"][0][batch["timeseries_mask"][0]].view(n_ch, -1).tolist() # the example's `timeseries````## Dataset Structure8 unmodified lines| Config | Task | Train | Test | Channels | Length | Answer ||---|---|---:|---:|---:|---:|---|| `ecg` | cardiological diagnosis | 5,800 | 643 | 12 | 1000 | `Yes` / `No` || `sleep` | sleep-stage classification | 7,413 | 923 | 1 | 1500 | `Wake`, `Non-REM stage 1`, `Non-REM stage 2`, `Non-REM stage 3`, `REM sleep` || `har` | human activity recognition | 68,542 | 8,222 | 3 | 128 | `biking`, `lying`, `running`, `sitting`, `standing`, `walking`, `walking_down`, `walking_up` || `tsr` | counterfactual consequence prediction | 22,566 | 4,094 | 1 | 128–1020 | option letter + text (`A`–`D`) || `engine` | aero-engine fault diagnosis | 2,305 | 193 | 33 | 600 | option letter (`a`–`d`) |### Data Fields- `input` (string): the prompt (question, instructions and, for multiple choice, the options).9 unmodified linesThe `*_with_ts_tags` files contain the same rows in the same order; only `input` differs, by theplaceholder lines prepended to the prompt.## Data Sources| Subset | Source ||---|---|| ECG | [ECG-Reasoning-Benchmark](https://huggingface.co/datasets/Jwoo5/ECG-Reasoning-Benchmark) || Sleep | [OpenTSLM SleepEDF-CoT](https://github.com/StanfordBDHG/OpenTSLM) || HAR | [OpenTSLM HAR-CoT](https://github.com/StanfordBDHG/OpenTSLM) || TSR | [Merrill et al. (2024)](https://huggingface.co/datasets/mikeam/time-series-reasoning) || Engine | [EngineMT-QA](https://huggingface.co/datasets/pandalin98/EngineMT-QA) |
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748"""Processor and collator for the Lapras Reasoning Datasets, in the style of a VLM data pipeline."""
import torch
class TimeSeriesProcessor: """Tokenizes text and packs time series into tensors, as a VLM processor does for images."""
def __init__(self, tokenizer): self.tokenizer = tokenizer self.tokenizer.padding_side = "right"
def apply_chat_template(self, prompt, response=None): messages = [{"role": "user", "content": prompt}] text = self.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) return text if response is None else text + response + self.tokenizer.eos_token
def __call__(self, text, timeseries): batch = self.tokenizer(text, padding=True, add_special_tokens=False, return_tensors="pt") n_ch = max(len(x) for x in timeseries) n_t = max(len(ch) for x in timeseries for ch in x) values = torch.zeros(len(timeseries), n_ch, n_t) mask = torch.zeros(len(timeseries), n_ch, n_t, dtype=torch.bool) for i, x in enumerate(timeseries): for c, ch in enumerate(x): values[i, c, : len(ch)] = torch.tensor(ch) mask[i, c, : len(ch)] = True batch["timeseries"] = values batch["timeseries_mask"] = mask return batch
class TimeSeriesCollator: """Builds a training batch in which only the response is supervised (labels are -100 elsewhere)."""
def __init__(self, processor): self.processor = processor
def __call__(self, examples): prompts = [self.processor.apply_chat_template(ex["input"]) for ex in examples] texts = [self.processor.apply_chat_template(ex["input"], ex["output"]) for ex in examples] batch = self.processor(texts, [ex["timeseries"] for ex in examples]) labels = batch["input_ids"].clone() labels[batch["attention_mask"] == 0] = -100 for i, prompt in enumerate(prompts): labels[i, : len(self.processor.tokenizer(prompt, add_special_tokens=False)["input_ids"])] = -100 batch["labels"] = labels return batchREADME.md+75-157
lapras_dataloader.pyAdded+48