Downloads · 30 days
10
9% of all-time downloads
paradoxdan/nano-scGPT
nano-scGPT is a machine learning model from paradoxdan. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
The simplest, fastest repository for scGPT inference, (soon) finetuning and trianing, with minimal dependencies. It reimplements the original scGPT from scratch. nanoscgpt/model.py is pure PyTorch in ~270 lines of cod…
Downloads · 30 days
10
9% of all-time downloads
All-time downloads
109
Public
Parameters
50.3M
202 MB on disk
Likes
2
Trending 1
Click a slice to open those files.
.safetensors201 MB · 99%
From the Hugging Face model README
The simplest, fastest repository for scGPT inference, (soon) finetuning and trianing, with minimal dependencies. It reimplements the original scGPT from scratch. nano_scgpt/model.py is pure PyTorch in ~270 lines of code, and nano_scgpt/scGPT_tokenizer.py turns raw scRNA data into model input. Small enough to read in one sitting and hack on.

Embeddings are numerically equivalent to the original scGPT.
Cell modeling is potentially the most exciting and under-indexed AI/ML area. The hope is to make state-of-the-art cell models more accessible to run, understand, and tinker with.
nano-scGPT produces embeddings numerically equivalent to the original
while running 1.38x faster, mostly from a clean forward pass plus torch.compile.
| Model | Total (65,847 cells) | Per cell | Throughput | Speedup |
|---|---|---|---|---|
| nano-scGPT | 77.7 s | 1.18 ms | 847 cells/s | 1.38× |
| scGPT | 107.0 s | 1.63 ms | 615 cells/s | 1.00× |
benchmarked under: single A100, batch size 256, AMP autocast, 10 batch warmup, Tabula Sapiens lung (65,847 cells).
git clone https://github.com/Danqi7/nano-scGPT.git
cd nano-scGPT
uv sync
source .venv/bin/activate
python -m venv .venv && source .venv/bin/activate
pip install -e .
# scGPT Embedding example
import numpy as np
from nano_scgpt.scGPT_tokenizer import scGPTTokenizer
from nano_scgpt.model import scGPTModel
model = scGPTModel.from_pretrained("scGPT_human") # weights pulled from HF hub
model.eval()
tokenizer = scGPTTokenizer.from_pretrained("scGPT_human")
genes = ['DUX4L30', 'CTB-52I2.4', 'USP17L16P', 'RPL7P23']
exprs = np.array([[1.0, 0.0, 23.0, 6.0], [0.0, 0.0, 3.0, 7.0]])
encoded = tokenizer.encode(exprs, genes)
embeddings = model.encode(encoded["gene_ids"], encoded["exprs"], encoded["padding_mask"]) # [N, D_embd]
# Example: Tabula Sapiens lung data (downloaded automatically)
python tasks/embedding.py
# Or on your own local file
python tasks/embedding.py \
--input <path to local .h5ad file> \
--output <path to save embeddings>
# Or from a remote URL
python tasks/embedding.py \
--input_url <URL to a remote .h5ad file> \
--output <path to save embeddings>
Let me know what tasks or even models you'd like to see next!
MIT. See LICENSE