CellGemma E4B in GGUF

CellGemma (Google DeepMind, Apache-2.0) converted to GGUF for llama.cpp, with its gene-symbol tokens intact. BF16 (15.5 GB, the original weights), Q8_0 and Q6_K (checked against BF16, below).

Why a plain conversion is not enough

CellGemma adds 20,256 human gene symbols to the Gemma 4 vocabulary as added tokens (MYC, GAPDH, ...). 20,096 of them cannot be reached by any BPE merge: the Hugging Face tokenizer splits them out of the text before BPE. llama.cpp's convert_hf_to_gguf.py writes them as normal tokens, so llama.cpp never produces them and spells every gene in sub-word pieces the model never saw in training. The model still runs, it just reads a different input. On a real CellGemma prompt the stock conversion gives 7,272 tokens where Hugging Face gives 4,484.

These files mark those tokens USER_DEFINED, so llama.cpp splits them out first, as Hugging Face does. Checked against the Hugging Face tokenizer: identical token ids on 253 of 253 texts (56 full CellGemma prompts built from the K562 and Tahoe control cells, 150 knowledge-graph sentences, 30 output-style gene lists, 16 drug SMILES, one plain sentence). The stock conversion matched none of the 6 texts tried.

Usage

llama-server -hf galinilin/cellgemma-e4b-GGUF:Q8_0 -ngl 99 -c 8192   # or :Q6_K, :BF16

CellGemma is not conversational: build the prompt exactly as in the original card (preamble, perturbation, Source:, Mean Global prediction:, Target:) and send it raw to /completion, not to the chat endpoint. Leave out <bos>: llama.cpp adds it (with it in the string you get two).

import httpx

r = httpx.post("http://127.0.0.1:8080/completion", json={
    "prompt": f"<|turn>user\n{prompt}<turn|>\n<|turn>model\n",
    "n_predict": 1024,
    # the original's sampling: temperature 0.7 applied before top-k 64 and top-p 0.95
    "temperature": 0.7, "top_k": 64, "top_p": 0.95, "min_p": 0.0,
    "samplers": ["temperature", "top_k", "top_p"],
}, timeout=600).json()
print(r["content"])  # "+GENE -GENE ...": ranked residual differentially expressed genes

Turn the gene list into expression and log-fold-change vectors with the dataset-specific ExpressionDecoders, control cells and mean_delta_global.json files from google/cellgemma-e4b, as its card shows. Tested with llama.cpp b9073e5.

Checked against the original

On a Colab T4, with the 36 evaluation prompts (12 CRISPR knockdowns in K562 and 6 drugs in A549 from the Tahoe controls, two cells each):

  • Same choices as transformers. Teacher-forced on 12 of these prompts (256 generated tokens each), wherever the transformers bf16 model is confident (top-1 logit at least 1 above top-2: about 1,600 positions), this GGUF picks the same next token every time. Overall top-1 agreement is 92%; every difference is at a near-tie, where two genes are almost equally likely and bf16 rounding decides.
  • Well-formed outputs. Greedy outputs (36 x up to 1,024 tokens): 17,555 words, all +GENE/-GENE, and 17,554 of them genes in CellGemma's vocabulary. Example, MYC knockdown in K562: +GYPB -VIM +BLVRB -WDR43 +HBZ -RRP1B +SLC25A37 -TSR1 +ALAS2 ...: erythroid genes up, ribosome biogenesis genes down.
  • Speed on a T4: about 23 tokens/s for one request; with 4 parallel requests 7 tokens/s each, prompt processing 240-370 tokens/s. Outputs often run to the full 1,024 tokens, so allow minutes per prediction.

Quantized files

file size outputs vs BF16 (sampled): residual Pearson minus BF16's own sampling noise (paired) greedy vs BF16 greedy
cellgemma-e4b-BF16.gguf 15.5 GB 0.543 [0.465, 0.622] (BF16 vs itself, two seeds)
cellgemma-e4b-Q8_0.gguf 8.6 GB 0.527 [0.451, 0.606] -0.016 [-0.044, +0.013] 0.80 [0.75, 0.84]
cellgemma-e4b-Q6_K.gguf 6.8 GB 0.528 [0.453, 0.606] -0.015 [-0.041, +0.012] 0.77 [0.72, 0.82]

Q8_0 and Q6_K are indistinguishable from BF16's own run-to-run variation. Q4_K_M (6.0 GB) costs a small but real amount (-0.055 [-0.088, -0.023]) and is not included. Method: the 36 evaluation prompts, outputs of 512 tokens at the original's sampling settings, turned into expression changes with the K562 and Tahoe ExpressionDecoders; residual Pearson compares what CellGemma adds on top of the mean-shift baseline (the full log-fold-change correlation is dominated by that shared baseline). 95% bootstrap intervals over prompts.

15 layers stay BF16 in every quantized file. Inputs to the early MLP down-projections (layers 0-13) and two per-layer projections reach 3 x 10^7, far beyond fp16; llama.cpp turns the inputs of quantized matrix products into 8-bit blocks with fp16 scales, so plain quantizations of this model output NaN (Q8_0 on CPU and CUDA, everything on CUDA). Keeping those 15 tensors in BF16 fixes it (about 0.4 GB). Use these files, not a quantization of your own, unless you keep the same tensors in BF16: blk.{0-9,11,12,13}.ffn_down and blk.{16,23}.proj.

Intended use

As the original: research on predicting transcriptional responses to perturbations. Not for clinical diagnosis, patient care or medical decisions; predictions need laboratory validation.

Licence

Apache-2.0, as the original. Model by Google DeepMind. Changes: converted to GGUF with llama.cpp's convert_hf_to_gguf.py, with the non-special added tokens marked USER_DEFINED; weights unchanged (BF16). Conversion and card by galinilin.

Downloads last month
-
GGUF
Model size
8B params
Architecture
gemma4
Hardware compatibility
Log In to add your hardware

6-bit

8-bit

16-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for galinilin/cellgemma-e4b-GGUF

Quantized
(8)
this model