Instructions to use google/cellgemma-e4b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/cellgemma-e4b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="google/cellgemma-e4b")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("google/cellgemma-e4b") model = AutoModelForCausalLM.from_pretrained("google/cellgemma-e4b", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use google/cellgemma-e4b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/cellgemma-e4b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/cellgemma-e4b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/google/cellgemma-e4b
- SGLang
How to use google/cellgemma-e4b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "google/cellgemma-e4b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/cellgemma-e4b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "google/cellgemma-e4b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/cellgemma-e4b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use google/cellgemma-e4b with Docker Model Runner:
docker model run hf.co/google/cellgemma-e4b
Running google/cellgemma-e4b on 8 GB Consumer GPUs + Independent Name-vs-SMILES Audit & Cross-Decoder 4-Bit Benchmark
Hi everyone! Sharing an open-source Apache 2.0 8 GB consumer-GPU loader plus the first independent mechanistic & quantization audit of google/cellgemma-e4b (156 total predictions across RTX 2080 4-bit and Colab L4 native 16-bit bfloat16):
GitHub Repo (loader, Colab notebooks, JSONs, charts): https://github.com/tinhnhatpham/cellgemma-8gb-immunotherapy
Zenodo Permanent DOI: https://doi.org/10.5281/zenodo.24736448
1. Fitting cellgemma-e4b in 3.5 GB Base / 5.6 GB Peak VRAM (zero os error 1455 on Windows)
model.embed_tokens_per_layer.weightis 6.07 GB (282,240 × 10,752BF16). On 16 GB RAM Windows PCs, mapping all 3.safetensorsshards simultaneously triggersOSError: os error 1455/MemoryError, and casting Gemma 4 tofloat16overflows logits toNaN.cellgemma_8gb.pystreams all 664 non-PLE tensors one-by-one intobitsandbytes4-bit NF4 (bfloat16compute,<200 MBloading RAM) and serves the PLE table directly from SSD via a zero-mmapFileSeekScaledEmbedding(reading only the active 21 KB token rows, preserving Gemma 4's exactsqrt(256) = 16.0scale factor).- Tested on Windows 11 + NVIDIA RTX 2080 (8 GB VRAM) + 16 GB RAM at
~4.7–5.1 tok/s(52–60sper cell).
2. Independent Causal Audit: Does CellGemma Read SMILES or Memorize Drug Names? (Exp 7A, n = 3 Tahoe cells)
We ran adversarial Name↔SMILES swap and zero-dose ablations on Panobinostat vs. Ruxolitinib/Ethanol (CCO):
- 100% SMILES-grounded (zero drug-name shortcut!): Hiding the name (
Compound_X+ Panobinostat SMILES:+43.3, Top-30 Jaccard49.8%) or even actively lying with the negative control's name (Ruxolitinib+ Panobinostat SMILES:+44.7, Jaccard49.5%) reproduced 100% of Panobinostat's canonical program (CALR +0.14/+0.16,HSP90B1 +0.16/+0.17,H1-0 +0.10/+0.12,SMAD3 -0.16/-0.15), matching the true pair (+44.3). Conversely, keeping"Panobinostat"with ethanol (CCO) or Ruxolitinib SMILES collapsed identically to null (+2.3/+6.4, Jaccard2.6–6.3%). - Calibration warning —
0.0 uMzero-dose leakage: Prompting withConcentration: 0.0 uMclearedCALR,H1-0, andSMAD3, but leakedHSP90B1 +0.10and21.8%residual overlap (COMP +11.5), behaving like an ultra-low positive dose (~0.05 uM). Avoid0.0 uMas a vehicle baseline; use an explicit inert SMILES control instead.
3. Cross-Decoder 4-Bit vs. Native 16-Bit bfloat16 Benchmark (tahoe + k562)
- Chemical (
tahoe,n = 10paired Panobinostat vs. Ruxolitinib): 4-bit RTX 2080 (3.5 GB) matched Native 16-bit Colab L4 (15.4 GB) 10-for-10 (t-test p = 9.72e-06vs6.61e-08), matching marker means closely (HSP90AA1: +0.1817 vs +0.1814,SMAD3: -0.1800 vs -0.1755,CALR: +0.1300 vs +0.1478,B2M: +0.0577 vs +0.0577). - Genetic CRISPRi (
k562, 18 knockdowns × 11 markers = 66 pairs, Exp 7B): 4-bit achievedPearson r = 0.9669(p = 1.07e-39,MAE = 0.0089Δ log1p) against Native 16-bit BF16, preserving on-targetHDAC1 KD(-0.192vs-0.222),HDAC6 -> SLC3A2/DDIT4/PHGDH/MAP1B, andHDAC2 -> HBZ/HBG2/HBA1(withMYCon-target attenuated in 4-bit while downstream erythroid markers remained intact).
(All scripts, Colab notebooks, and 156 raw JSON predictions are Apache 2.0 — feedback and replication tests on other decoders very welcome!)
Thanks for the detailed field report. The 8 GB loader numbers are the useful part: 3.5 GB base and 5.6 GB peak on an RTX 2080, with the per-layer embedding table served from SSD instead of mapped in RAM. The name-versus-SMILES audit is equally valuable: the response follows the SMILES rather than the drug name, and the 0.0 uM leakage warning (HSP90B1 still moving, 21.8 percent residual overlap) is a calibration point worth heeding, an explicit inert control beats a zero-dose prompt as a baseline. The 4-bit versus native 16-bit parity on the CRISPRi set (Pearson r = 0.9669) makes the small-hardware route credible. We appreciate the open loader, notebooks and data.

