Eugene Hauptmann Cursor commited on
Commit
f565491
·
1 Parent(s): cded490

Add GlucoFM encoder weights for Hugging Face publishing.

Browse files

Safetensors F32, GGUF F16/Q8, upstream ONNX, model card, and checksums.

Co-authored-by: Cursor <cursoragent@cursor.com>

.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.gguf filter=lfs diff=lfs merge=lfs -text
37
+ *.rlxp filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ .DS_Store
2
+ *.tmp
3
+ *.bak
4
+ .cache/
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 GlucoFM contributors
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.
PUBLISH.md ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Publish this folder as a Hugging Face model repo
2
+
3
+ This directory is a **standalone** git repository. It is ignored by the parent
4
+ `glucofm` code repo (see root `.gitignore`: `/artifacts/`).
5
+
6
+ ## One-time setup
7
+
8
+ ```bash
9
+ cd artifacts
10
+ # already initialized if you used the prep script; otherwise:
11
+ # git init
12
+ # git lfs install
13
+ # git lfs track "*.onnx" "*.safetensors" "*.gguf"
14
+
15
+ huggingface-cli login
16
+ # Create an empty model repo on HF (web UI or):
17
+ # huggingface-cli repo create glucofm-encoder --type model
18
+
19
+ git remote add origin https://huggingface.co/<USER>/glucofm-encoder
20
+ git add -A
21
+ git commit -m "Add GlucoFM encoder weights (safetensors, GGUF, ONNX)"
22
+ git push -u origin main
23
+ ```
24
+
25
+ ## Verify checksums
26
+
27
+ ```bash
28
+ shasum -a 256 -c SHA256SUMS
29
+ ```
30
+
31
+ ## Suggested Hub id
32
+
33
+ `glucofm-encoder` (or `<org>/glucofm-encoder`). After publish, point the
34
+ parent crate README / `OPENCGM_HF_*` docs at that id if you replace the
35
+ upstream OpenCGM download path.
README.md ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: glucofm
4
+ tags:
5
+ - cgm
6
+ - glucose
7
+ - foundation-model
8
+ - jepa
9
+ - onnx
10
+ - safetensors
11
+ - gguf
12
+ - healthcare
13
+ pipeline_tag: feature-extraction
14
+ ---
15
+
16
+ # GlucoFM encoder weights
17
+
18
+ Frozen **encoder-only** checkpoints for
19
+ [GlucoFM](https://arxiv.org/abs/2605.30865) (dual-stream CGM foundation model),
20
+ converted for the Rust [`glucofm`](https://crates.io/crates/glucofm) / RLX stack.
21
+
22
+ > **Not medical advice.** Research reimplementation. Official Google GlucoFM
23
+ > weights are not public. This package redistributes / converts a community
24
+ > OpenCGM reconstruction.
25
+
26
+ ## Files
27
+
28
+ | File | Format | Notes |
29
+ |------|--------|-------|
30
+ | `glucofm_encoder.safetensors` | F32 safetensors | **Preferred** for `glucofm` load / train warm-start |
31
+ | `glucofm_encoder.f16.gguf` | GGUF F16 | Smaller disk; dequantized at load |
32
+ | `glucofm_encoder.q8.gguf` | GGUF Q8_0 | ~4× smaller than F32; dequantized at load |
33
+ | `glucofm_encoder.onnx` | ONNX opset 17 | Upstream OpenCGM export (raw grid → 128-d embedding) |
34
+ | `glucofm_encoder.onnx.meta.json` | JSON | Upstream export metadata |
35
+ | `config.json` | JSON | Geometry + param counts for this package |
36
+ | `SHA256SUMS` | text | Integrity checks |
37
+
38
+ **Encoder params:** 435,633 (includes `online/mask_token` + `online/gaussian.rho`).
39
+ OpenCGM ONNX omits `mask_token`; `glucofm` inference defaults it to zeros.
40
+
41
+ Paper full trainable target (encoder + JEPA heads): **732,593**.
42
+
43
+ ## Geometry
44
+
45
+ | Symbol | Value |
46
+ |--------|------:|
47
+ | Grid `L` | 288 (5 min) |
48
+ | Patches `P` | 24 |
49
+ | Patch len `K` | 12 |
50
+ | Hidden `D` | 128 |
51
+ | Stream `S` | 64 |
52
+
53
+ ## Provenance
54
+
55
+ - Upstream community encoder: [`sfourdrinier/opencgm-stateevent`](https://huggingface.co/sfourdrinier/opencgm-stateevent)
56
+ - OpenCGM project: [sfourdrinier/opencgm](https://github.com/sfourdrinier/opencgm)
57
+ - Paper: [arXiv:2605.30865](https://arxiv.org/abs/2605.30865)
58
+ - Conversion via `glucofm` `convert_weights` example (ONNX → safetensors / GGUF)
59
+
60
+ Upstream ONNX meta (epoch 40 seed 17, raw stats, circadian, learnable σ) is kept in
61
+ `glucofm_encoder.onnx.meta.json`.
62
+
63
+ ## Use with `glucofm`
64
+
65
+ ```bash
66
+ # After cloning this HF repo next to your project, or downloading files:
67
+ cargo run --release --features infer --example infer -- \
68
+ --weights /path/to/glucofm_encoder.safetensors
69
+
70
+ cargo run --release --features hub --example train_from_hub -- \
71
+ --weights /path/to/glucofm_encoder.safetensors --steps 50
72
+ ```
73
+
74
+ ```rust,ignore
75
+ use glucofm::prelude::*;
76
+
77
+ let mut model = GlucoFm::for_inference(GlucoFmConfig::default(), InferOptions::default(), &mut rng)?;
78
+ model.load_weights_path("glucofm_encoder.safetensors")?;
79
+ let emb = model.encode_embedding_day(&day, &mut rng)?; // [128]
80
+ ```
81
+
82
+ ## Formats
83
+
84
+ - Prefer **safetensors** for numeric fidelity with RLX `Param` graphs.
85
+ - **GGUF** is for disk savings; runtime still uses dense F32/F16 params after load
86
+ (no in-graph Q8 matmul).
87
+
88
+ ## License
89
+
90
+ Weights and packaging in this repository: **MIT** (see `LICENSE`).
91
+
92
+ Upstream OpenCGM / paper licenses may impose additional terms on the original
93
+ checkpoints — review those projects before commercial use.
SHA256SUMS ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ glucofm_encoder.f16.gguf 7be81464df67fabb0e25b120a6de173c14aa2a346100c4b49a8a41b230305fcd
2
+ glucofm_encoder.onnx b1349deffd15ab62a5a98d7c7c4a7e143bcf1dee7ad745b1e05533ff54f34768
3
+ glucofm_encoder.onnx.meta.json a84d1870d526ff06a4a5a6fdd403e44b93db2c545e584138b6de0b23fcfe7773
4
+ glucofm_encoder.q8.gguf 999e21cb0fa8ef9e6cf1386de11fcee796af827182353af537d26089b4788ce5
5
+ glucofm_encoder.safetensors 8a9a3c471e09ddfcb35e076f80c0ef86520ab2f56172b1a01fa03c7edae22d3b
config.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "glucofm",
3
+ "architectures": ["GlucoFmEncoder"],
4
+ "library_name": "glucofm",
5
+ "paper": "https://arxiv.org/abs/2605.30865",
6
+ "upstream_hub": "sfourdrinier/opencgm-stateevent",
7
+ "upstream_file": "glucofm_encoder.onnx",
8
+ "geometry": {
9
+ "grid_len": 288,
10
+ "num_patches": 24,
11
+ "patch_len": 12,
12
+ "hidden": 128,
13
+ "stream_dim": 64,
14
+ "num_heads": 4,
15
+ "ffn_dim": 256,
16
+ "num_layers": 3,
17
+ "delta_minutes": 5.0
18
+ },
19
+ "param_counts": {
20
+ "encoder": 435633,
21
+ "paper_trainable_full": 732593,
22
+ "note": "ONNX export omits online/mask_token (128); glucofm infer zeros it by default"
23
+ },
24
+ "files": {
25
+ "safetensors_f32": "glucofm_encoder.safetensors",
26
+ "gguf_f16": "glucofm_encoder.f16.gguf",
27
+ "gguf_q8": "glucofm_encoder.q8.gguf",
28
+ "onnx": "glucofm_encoder.onnx",
29
+ "onnx_meta": "glucofm_encoder.onnx.meta.json"
30
+ },
31
+ "io": {
32
+ "embedding_dim": 128,
33
+ "glucose_units": "mg/dL",
34
+ "mask_convention": "0 = unobserved, 1 = observed"
35
+ }
36
+ }
glucofm_encoder.f16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7be81464df67fabb0e25b120a6de173c14aa2a346100c4b49a8a41b230305fcd
3
+ size 876064
glucofm_encoder.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b1349deffd15ab62a5a98d7c7c4a7e143bcf1dee7ad745b1e05533ff54f34768
3
+ size 1991782
glucofm_encoder.onnx.meta.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "checkpoint": "runs_5090/rawstats120/ckpt_ep040.pt",
3
+ "epoch": 40,
4
+ "seed": 17,
5
+ "architecture": {
6
+ "raw_statistics": true,
7
+ "normalize_targets": false,
8
+ "streams": "both",
9
+ "learnable_sigma": true,
10
+ "use_circadian": true,
11
+ "zero_empty_patches": false
12
+ },
13
+ "opset": 17,
14
+ "input_names": [
15
+ "values",
16
+ "mask",
17
+ "circadian_start"
18
+ ],
19
+ "input_dtypes": [
20
+ "float32",
21
+ "float32",
22
+ "int64"
23
+ ],
24
+ "input_shapes": [
25
+ "[B, 288]",
26
+ "[B, 288]",
27
+ "[B]"
28
+ ],
29
+ "output_names": [
30
+ "embedding"
31
+ ],
32
+ "output_dtype": "float32",
33
+ "output_shape": "[B, 128]",
34
+ "size_bytes": 1991782,
35
+ "sha256": "b1349deffd15ab62a5a98d7c7c4a7e143bcf1dee7ad745b1e05533ff54f34768",
36
+ "mask_convention": "0 = unobserved, 1 = observed; never interpolate before this point",
37
+ "units": "mg/dL"
38
+ }
glucofm_encoder.q8.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:999e21cb0fa8ef9e6cf1386de11fcee796af827182353af537d26089b4788ce5
3
+ size 469360
glucofm_encoder.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a9a3c471e09ddfcb35e076f80c0ef86520ab2f56172b1a01fa03c7edae22d3b
3
+ size 1749540