Skip to content

feat: release the paper models on the Hugging Face Hub - #4

Merged
aaronwtr merged 2 commits into
mainfrom
feat/hub-checkpoints
Oct 16, 2026
Merged

aaronwtr merged 2 commits into
mainfrom
feat/hub-checkpoints

Conversation

@aaronwtr

Copy link
Copy Markdown
Owner

What changes

Released weights (c512526)

  • varformer/checkpoints.py: new load_released(model, seed, repo_id, revision, local_dir). It downloads <model>/seed<N>.safetensors and <model>/seed<N>.json from the Hub (or reads a local copy of the release), checks the SHA-256 checksum of the weights, and remaps the state dict. seed="best" selects the seed with the highest validation Spearman correlation from index.json.
  • Released models: afr, amr, nfe, sas (gene models of the paper, without geneticConstraint) and sas-gnh (SAS models used for the Genes & Health variant analyses, with geneticConstraint). Five seeds each.
  • Varformer.from_pretrained(model, seed=42, repo_id=None, revision=None, local_dir=None) now loads these released models. It applies the saved training settings, checks that the local input dimensions match the released model, and stops if the weights lack model keys. Models that users train themselves still load with from_checkpoint.
  • New dependencies: huggingface-hub>=0.24, safetensors>=0.4 (lock file updated; no existing versions changed).

predict and score_variants cover every gene

Before this change, predict and score_variants ran only over the benchmark loaders (Pfam, Recently Approved and Pharos test genes) and silently skipped every other gene. They now build a loader for the requested genes from the local input data (ModelPreprocessorInference.create_gene_loader). evaluate keeps the benchmark loaders.

README (bde002b)

  • Hugging Face badge; "Released models" section with the five models and how to load them.
  • "Training without AlphaMissense": step-by-step instructions (score direction, range, file layout, cache files to delete).
  • License section: code MIT; released weights and the variant scores CC BY-NC-SA 4.0, because the models take AlphaMissense scores as input.

Checks

  • pytest: 91 passed, 1 skipped. New tests: tests/test_released.py (seed selection, remapping, checksum, sas-gnh), test_gene_loader_keeps_requested_genes_present_in_all_modalities.
  • ruff check varformer tests passes.
  • End-to-end test on Apocrita with the converted release files (local_dir): NFE seed 23 and SAS seed 13 return all 2,000 sampled genes, and the predictions match the paper's genome scores (maximum absolute difference 1.2e-6). sas-gnh seed 42 loads with geneticConstraint and scores 531 variants in LDLR. seed="best" works.

Before merging

  • The Hub repository aaronw1290/Varformer (HUB_REPO_ID and the README links) must exist and be public.

from_pretrained downloads the weights (or reads a local copy of the
release), checks their SHA-256 checksum, applies the saved training
settings and checks the input dimensions. predict and score_variants now
cover every requested gene in the local input data, not only the
benchmark genes.
@aaronwtr
aaronwtr merged commit 3470d5b into main Oct 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant