KuanP commited on
Commit
b44782e
·
verified ·
1 Parent(s): 66ddb4d

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +75 -0
README.md ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ library_name: transformers
4
+ tags: [single-cell, cell-embedding, uce, transcriptomics, scrna-seq]
5
+ ---
6
+
7
+ # counts_flash_hog_4gpu_a6_long_u2_lowilr_bot75
8
+
9
+ Counts DataRater (a6_long_u2_lowilr), **bottom** 75% of cells by score.
10
+
11
+ UCE (Universal Cell Embedding) model trained on CELLxGENE 2025-01-30. This is the
12
+ **final** model at 131,072 steps. One of a set of runs that share an identical
13
+ training recipe and differ **only** in which training cells were selected, so their
14
+ representations can be compared against each other.
15
+
16
+ ## Training recipe
17
+
18
+ | | |
19
+ |---|---|
20
+ | Steps | 131,072 |
21
+ | Global batch size | 512 |
22
+ | Learning rate | 5e-05 (cosine, 500 warmup) |
23
+ | Weight decay | 0.0001 |
24
+ | Precision | bf16 |
25
+ | Architecture | 8L / d512 / 4-head, frozen 5120-d gene embeddings |
26
+ | Parameters | 773.7M total, 28.9M trainable |
27
+ | Sequence length | 2048 tokens |
28
+ | Data selection | `ExcludeDatasetSelector(dataset_id=53d208b0-2cfd-4366-9866-c3c6114081bc) + PrecomputedScoreSelector(scores_path=/scratch/m000137-pm06/kuan/data_rater_infer_output/counts_datarater_flash_hog_4gpu_a6_long_u2_lowilr/final/all_scores.npy, bottom_percentile=75)` |
29
+ | Source dataset | cellxgene_2025_bot75_counts_flash_hog_4gpu_a6_long_u2_lowilr_exclude_ts_sparse_marlowe (62,634,100 cells / 61,888 genes) |
30
+
31
+ The gene embedding table is a frozen `nn.Parameter`, so it lives in the state dict --
32
+ hence the ~3 GB `model.safetensors`. You do not need `all_tokens.torch` at inference.
33
+
34
+ ## Usage
35
+
36
+ Requires [uce-training-suite](https://github.com/) (`uce_suite`).
37
+
38
+ ```python
39
+ from huggingface_hub import snapshot_download
40
+ from uce_suite.inference import (
41
+ load_uce_checkpoint, load_cell_sentence_params, load_gene_artifacts, embed_dataset,
42
+ )
43
+
44
+ local = snapshot_download("KuanP/counts_flash_hog_4gpu_a6_long_u2_lowilr_bot75") # private repo: needs auth
45
+
46
+ model = load_uce_checkpoint(local, device="cuda")
47
+ params = load_cell_sentence_params(local) # reads config.yaml in this repo
48
+ gene_names, gene_mapping = load_gene_artifacts(
49
+ f"{local}/gene_names.txt", f"{local}/all_species_gene_dict.json", species="human",
50
+ )
51
+
52
+ emb = embed_dataset(
53
+ model, dataset_path="/path/to/cells.dataset",
54
+ gene_names=gene_names, gene_mapping=gene_mapping, **params.as_kwargs(),
55
+ )
56
+ ```
57
+
58
+ Use `load_uce_checkpoint` rather than a bare `from_pretrained`: on transformers >=5
59
+ `from_pretrained` re-runs `_init_weights` after loading and overwrites the trained
60
+ `nn.Linear` weights. The loader force-reloads the state dict to undo that. The symptom
61
+ if it is skipped is a per-cell loss pinned at log(2) = 0.693 and noise-like embeddings.
62
+
63
+ ## Tokenisation
64
+
65
+ `config.yaml` ships in this repo and is what `load_cell_sentence_params` reads. These
66
+ values must match at inference or the embeddings are silently wrong:
67
+
68
+ | | |
69
+ |---|---|
70
+ | `pad_length` | 2048 |
71
+ | `cls_token_idx` | 1 |
72
+ | `chrom_token_offset` | 143574 |
73
+ | `chrom_token_right_idx` | 2 |
74
+ | `pad_token_idx` | 0 |
75
+ | `vocab_size` | 145469 |