meds-algorithm-curiosity 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- curiosity_meds/__init__.py +6 -0
- curiosity_meds/__main__.py +65 -0
- curiosity_meds/_model.py +236 -0
- curiosity_meds/_tokenizer.py +684 -0
- curiosity_meds/config.py +163 -0
- curiosity_meds/curiosity_meds.py +378 -0
- curiosity_meds/datasets/MIMIC-IV.yaml +54 -0
- curiosity_meds/resources/algorithms/zero_shot_materialized/model.yaml +28 -0
- curiosity_meds/resources/runs/run.yaml +26 -0
- meds_algorithm_curiosity-0.1.0.dist-info/METADATA +192 -0
- meds_algorithm_curiosity-0.1.0.dist-info/RECORD +14 -0
- meds_algorithm_curiosity-0.1.0.dist-info/WHEEL +4 -0
- meds_algorithm_curiosity-0.1.0.dist-info/entry_points.txt +2 -0
- meds_algorithm_curiosity-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: meds-algorithm-curiosity
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Curiosity-0826 generative medical event model: Qwen2 decoder pretrained on tokenized MEDS timelines, zero-shot task prediction by Monte Carlo generation of future timelines.
|
|
5
|
+
Project-URL: Repository, https://github.com/florian6973/meds-algo-curiosity
|
|
6
|
+
Author-email: Florent Pollet <flo1.raymond@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Python: >=3.12
|
|
10
|
+
Requires-Dist: aces-relaxations==0.1.0
|
|
11
|
+
Requires-Dist: meds-algorithm[data]==0.4.0a6
|
|
12
|
+
Requires-Dist: numpy>=1.26
|
|
13
|
+
Requires-Dist: pyyaml>=6
|
|
14
|
+
Requires-Dist: torch>=2.6
|
|
15
|
+
Requires-Dist: transformers>=4.51
|
|
16
|
+
Provides-Extra: orchestration
|
|
17
|
+
Requires-Dist: meds-algorithm[orchestration]==0.4.0a6; extra == 'orchestration'
|
|
18
|
+
Provides-Extra: test
|
|
19
|
+
Requires-Dist: meds-algorithm[conformance]==0.4.0a6; extra == 'test'
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# Curiosity
|
|
23
|
+
|
|
24
|
+
## Python API and named command
|
|
25
|
+
|
|
26
|
+
The implementation is `src/curiosity_meds/curiosity_meds.py`, with configuration in `config.py`.
|
|
27
|
+
Both concrete classes are public package exports:
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from curiosity_meds import Curiosity, CuriosityConfig
|
|
31
|
+
|
|
32
|
+
algorithm = Curiosity(CuriosityConfig())
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Run typed requests through `meds_algorithm.StepRunner.run(...)` so validation, measurements and
|
|
36
|
+
publication apply. Calling an implementation method directly bypasses that execution contract.
|
|
37
|
+
After installation, the algorithm's own `curiosity-meds` command runs the CLI:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
curiosity-meds commands --profile zero_shot_materialized
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Curiosity-0826 generative medical event model: Qwen2 decoder pretrained on tokenized MEDS timelines, zero-shot task prediction by Monte Carlo generation of future timelines.
|
|
44
|
+
|
|
45
|
+
This repository declares the **`zero_shot_materialized`** profiles under version 4 of the minimal MEDS algorithm
|
|
46
|
+
contract. The contract standardizes MEDS input, command meanings and arguments, artifact envelopes,
|
|
47
|
+
final predictions, measurements, MEDS-DEV packaging, and operational interfaces. The algorithm owns every
|
|
48
|
+
computational choice and every intermediate payload.
|
|
49
|
+
|
|
50
|
+
## Algorithm profile commands
|
|
51
|
+
|
|
52
|
+
- `zero_shot_materialized`: `preprocess_data → pretrain → infer_trajectories → predict_zero_shot_materialized`
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
curiosity-meds profiles
|
|
56
|
+
curiosity-meds commands --profile zero_shot_materialized
|
|
57
|
+
curiosity-meds <step> --profile <profile> key=value ...
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Each profile has `algorithms/<profile>/model.yaml`. Multiple profiles share one Python package and one
|
|
61
|
+
registry; select one explicitly for each run. `STUB_PROFILES` tracks implementation status separately.
|
|
62
|
+
Read [Software contract](SPEC.md) for exact class responsibilities and step inputs.
|
|
63
|
+
|
|
64
|
+
Intermediate artifacts may be tensors, files, databases, external-system references, or any other
|
|
65
|
+
implementation-owned representation. Generic tests inspect only their `manifest.yaml` envelopes. They
|
|
66
|
+
must not assume batches, Lightning, PyTorch, Parquet intermediate data, or iteration order.
|
|
67
|
+
|
|
68
|
+
## Profile runner (prototype)
|
|
69
|
+
|
|
70
|
+
Install `uv sync --extra orchestration --extra test`, then fill the input paths and new output directory
|
|
71
|
+
in `configs/runs/run.yaml`. Algorithm settings belong under `algorithm`; core validates them using
|
|
72
|
+
this repository's concrete Config class.
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
uv run curiosity-meds run --dry-run
|
|
76
|
+
uv run curiosity-meds run execution=local
|
|
77
|
+
# Use a NEW output_dir and configure your cluster's resources before submission:
|
|
78
|
+
uv run curiosity-meds run execution=slurm output_dir=/runs/new-cluster-run
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
A dry run prints all resolved arguments, paths, configuration and resources without writing files or
|
|
82
|
+
submitting jobs. Local execution uses fresh subprocesses; Submitit submits separate dependent SLURM
|
|
83
|
+
jobs. See the [shared runner guide](https://meds-algorithm.readthedocs.io/en/latest/running/#profile-runner-prototype)
|
|
84
|
+
for stage subsets, artifact reuse, resource configuration and prototype limitations. The existing
|
|
85
|
+
per-step CLI and shell launcher remain available for comparison. This prototype does not implement
|
|
86
|
+
Hydra multirun, multi-node training or checkpoint/resume.
|
|
87
|
+
|
|
88
|
+
## Publishing this algorithm
|
|
89
|
+
|
|
90
|
+
Follow [the release guide](RELEASING.md) for package metadata, one-time PyPI Trusted Publisher setup,
|
|
91
|
+
installed-wheel checks, and version-tag publication. All profiles ship in the `meds-algorithm-curiosity`
|
|
92
|
+
distribution. Tests run in CI; publishing is an explicit workflow dispatch after implementation.
|
|
93
|
+
|
|
94
|
+
## Inputs and predicates
|
|
95
|
+
|
|
96
|
+
- `external_meds_dir` is the standard MEDS dataset boundary.
|
|
97
|
+
- `external_index_dir` supplies only `(subject_id, prediction_time)` to inference and scoring.
|
|
98
|
+
- `external_labels_dir` supplies permitted training targets or explicit in-context examples.
|
|
99
|
+
- `external_evaluation_labels_dir`, when supplied, is used only to attach truth after scores are fixed.
|
|
100
|
+
- `external_predicates_file` supplies dataset-specific predicates when useful. For MIMIC-IV, reuse the
|
|
101
|
+
predicates from MEDS-DEV. This repository decides whether and how to interpret them.
|
|
102
|
+
|
|
103
|
+
A command that consumes predicates records their absolute path and SHA-256 digest in its manifest.
|
|
104
|
+
Predicates do not imply a standard feature representation.
|
|
105
|
+
|
|
106
|
+
## Implementing the algorithm
|
|
107
|
+
|
|
108
|
+
Read [AGENTS.md](AGENTS.md), [SPEC.md](SPEC.md), and
|
|
109
|
+
[docs/IMPLEMENTATION_GUIDE.md](docs/IMPLEMENTATION_GUIDE.md) completely before changing implementation
|
|
110
|
+
files. The implementation source recorded when this repository was generated is:
|
|
111
|
+
|
|
112
|
+
```text
|
|
113
|
+
https://arxiv.org/abs/2611.15710v1, building on https://arxiv.org/abs/2508.12104v3 (papers only; no code released)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The algorithm-owned surface is `src/curiosity_meds/curiosity_meds.py` (the typed algorithm), `src/curiosity_meds/config.py`
|
|
117
|
+
(its immutable configuration), `algorithms/<profile>/model.yaml`, and
|
|
118
|
+
`tests/e2e.py`. Implement the selected profile methods, define exact intermediate compatibility checks in
|
|
119
|
+
`validate_inputs`,
|
|
120
|
+
finalize MEDS-DEV command strings, and complete the report. Remove a profile from `STUB_PROFILES` only after it runs end to end. Complete every declared profile.
|
|
121
|
+
|
|
122
|
+
For each generated test and its purpose, read [the test guide](docs/TESTING.md).
|
|
123
|
+
|
|
124
|
+
## Configuration and execution ownership
|
|
125
|
+
|
|
126
|
+
Declare typed fields/defaults in `CuriosityConfig`, with `validate()` for constraints. Pass
|
|
127
|
+
`config_file=/path/config.yaml` to a step for a JSON/YAML values mapping; unknown fields fail. Core saves
|
|
128
|
+
the complete resolved config and original typed request as `config.json` and `request.json` in each
|
|
129
|
+
published artifact. These JSON envelopes can be reloaded with the corresponding explicit classes.
|
|
130
|
+
|
|
131
|
+
Algorithm methods receive typed requests, write payloads into `request.output.directory` (staging), and
|
|
132
|
+
return `PayloadMetadata`. `create_repository().run(...)` constructs a fresh algorithm and delegates to
|
|
133
|
+
core's runner. It owns measurements, prediction validation, optional post-score truth attachment,
|
|
134
|
+
metadata and publication. Never publish from inside algorithm methods or write the reserved metadata files.
|
|
135
|
+
Reopen fitted artifacts on each step. Test config/request round trips and execution in a fresh process.
|
|
136
|
+
|
|
137
|
+
## Verification
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
uv run pytest -rs
|
|
141
|
+
uv run pytest -m meds_dev -rs
|
|
142
|
+
uv run pytest -m real_data -rs
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
- The default suite runs the local end-to-end adapter and contract tests.
|
|
146
|
+
- `meds_dev` registers `algorithms/<profile>/model.yaml`, installs this repository from `requirements.txt` in an isolated
|
|
147
|
+
environment, and executes MEDS-DEV's real command slots.
|
|
148
|
+
- `real_data` runs the full selected algorithm profile on the MEDS-DEV MIMIC-IV demo, the pinned
|
|
149
|
+
`mortality/in_icu/first_24h` task, and MEDS-DEV's
|
|
150
|
+
MIMIC predicates. Set `MEDS_DEMO_DIR` to reuse an existing demo and `MEDS_DEV_DIR` to reuse a checkout.
|
|
151
|
+
|
|
152
|
+
Automatic provisioning pins MEDS-DEV PR #330's tested commit, which has the `{predicates_path}`
|
|
153
|
+
passthrough (PR #325) and the
|
|
154
|
+
`{task_criteria_path}` passthrough this zero-shot algorithm needs. Set `MEDS_DEV_REF` to use another
|
|
155
|
+
revision containing those capabilities. A checkout supplied through `MEDS_DEV_DIR` is checked and fails
|
|
156
|
+
clearly if it cannot populate them.
|
|
157
|
+
|
|
158
|
+
Both integration tiers explicitly `algorithm_stub`-skip until implementation is complete. A completed port
|
|
159
|
+
must have zero `algorithm_stub` skips and must account for every other skip using `-rs` output.
|
|
160
|
+
|
|
161
|
+
These commands are gates, not an unordered checklist. Follow the canonical staged workflow in
|
|
162
|
+
[docs/IMPLEMENTATION_GUIDE.md](docs/IMPLEMENTATION_GUIDE.md): local, MEDS-DEV, pre-demo report and human
|
|
163
|
+
review, MIMIC-IV demo, demo report and human review, authorized full-data run, then final report and GitHub
|
|
164
|
+
synchronization. Full-data cluster jobs run only from a clean, pushed commit and use the reviewed shared
|
|
165
|
+
task bundle for the selected dataset (for example, MIMIC-IV or NWICU in MEDS format), built upstream from
|
|
166
|
+
clinical ACES tasks or randomly sampled code-by-horizon tasks. The provided `real_data` test remains the MIMIC-IV demo regardless of that choice.
|
|
167
|
+
|
|
168
|
+
Final predictions must conform to MEDS evaluation, contain unique `(subject_id, prediction_time)` keys,
|
|
169
|
+
and exactly cover the requested evaluation index. Tests compare the actual key sets; self-reported manifest
|
|
170
|
+
counts are not accepted as evidence. Row order is never an association mechanism.
|
|
171
|
+
|
|
172
|
+
## Measurements
|
|
173
|
+
|
|
174
|
+
Every command manifest records monotonic wall time and sampled live process-tree memory. On Linux, peak
|
|
175
|
+
PSS from `/proc/*/smaps_rollup` is the primary comparison metric; aggregate RSS is retained as a
|
|
176
|
+
diagnostic. The measurement method and sampling interval are explicit. GPU measurements and SLURM
|
|
177
|
+
`MaxRSS`, when available, are separate metrics. Missing measurements are `null`; observed zero is `0`.
|
|
178
|
+
Time and memory are evidence, not portable test thresholds.
|
|
179
|
+
|
|
180
|
+
## Cluster execution and GitHub communication
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
$EDITOR slurm/config.sh
|
|
184
|
+
PROFILE=zero_shot_materialized ./slurm/submit.sh --dry-run
|
|
185
|
+
PROFILE=zero_shot_materialized ./slurm/submit.sh
|
|
186
|
+
scripts/github-sync.sh <run-id>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
SLURM follows the selected algorithm profile and chains stages by successful dependencies. Structured evidence belongs
|
|
190
|
+
under `runs/<run-id>/`; raw logs, datasets, checkpoints, and credentials do not. GitHub synchronization
|
|
191
|
+
pushes a `runs/curiosity_meds/<run-id>` branch and optionally opens a draft PR. A failed push leaves the
|
|
192
|
+
result committed and recoverable locally.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
curiosity_meds/__init__.py,sha256=QGG-gzh8BP5VNUzx59QIlog7Io3N1KyQXTkhlR5TuJU,136
|
|
2
|
+
curiosity_meds/__main__.py,sha256=wmuRqZG5dYZBaqCwE5aFI2Ap2nso-fo6_pOpXV5SeBM,2768
|
|
3
|
+
curiosity_meds/_model.py,sha256=ufsqPcplDFBER8VDw-OpChcEtG1QXHSLnBGCo_5s6yw,11295
|
|
4
|
+
curiosity_meds/_tokenizer.py,sha256=sVsEYfEO67bqyEjenRQcVjFjvyBaxKDj5N_xiIJTWVg,38583
|
|
5
|
+
curiosity_meds/config.py,sha256=bcp4itgJr8te7zyEeGlXKtggtFpjZ0AnCJUrsKjHYwE,8308
|
|
6
|
+
curiosity_meds/curiosity_meds.py,sha256=hyfxFXdC7BJV07mKSGeaIlIFvln8gJHG6opvju4POOg,23273
|
|
7
|
+
curiosity_meds/datasets/MIMIC-IV.yaml,sha256=sPvNzvluRdgwE-cvMj0cWUnofPxE_Oa8Yg7padgcd5o,3655
|
|
8
|
+
curiosity_meds/resources/algorithms/zero_shot_materialized/model.yaml,sha256=srXrBpBiINRGhB4BOm3tuk5AI6A0t4K9yrdhPiaqtsU,2046
|
|
9
|
+
curiosity_meds/resources/runs/run.yaml,sha256=_3jI_LNJf-iFYw6iLAy5lmIZZ6Si-U8FahKa-vHHIEM,1032
|
|
10
|
+
meds_algorithm_curiosity-0.1.0.dist-info/METADATA,sha256=tfc8t7JefZMgitH03z0Uqmp4Ys_neakPpE6KWlydgeg,10273
|
|
11
|
+
meds_algorithm_curiosity-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
12
|
+
meds_algorithm_curiosity-0.1.0.dist-info/entry_points.txt,sha256=jp6vmQnhYpDaGL3OG58xk3sYS70kqfVR0-yIUBpw4ag,64
|
|
13
|
+
meds_algorithm_curiosity-0.1.0.dist-info/licenses/LICENSE,sha256=FAUMbnQf4z0hgnQETTcoeY5gGXRb6MHYPg-4AmgGtMw,1071
|
|
14
|
+
meds_algorithm_curiosity-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Florent Pollet
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|