CellGemma E4B β€” GGUF

License: Apache-2.0 Format: GGUF Runtime: llama.cpp Architecture: gemma4

GGUF conversions of CellGemma E4B (Google DeepMind) for llama.cpp, with the model's 20,256 gene-symbol tokens preserved. CellGemma predicts how a cell's gene expression changes after a perturbation (a CRISPR knockdown or a drug) and returns a ranked list of differentially expressed genes.

Three files are provided: BF16 (15.5 GB, the original weights), Q8_0 and Q6_K. Both quantizations are validated against BF16 (see Quantization quality).

This is a community conversion. It is not an official Google DeepMind release.

Contents

  1. At a glance
  2. Files
  3. Quickstart
  4. Prompt format and output
  5. Quick reference for tooling and AI agents
  6. Why a plain conversion is not enough
  7. Validation against the original
  8. Quantization quality
  9. Quantizing this model yourself
  10. Troubleshooting
  11. Intended use and limitations
  12. Provenance
  13. License
  14. Citation
  15. Acknowledgements and links

At a glance

Original model google/cellgemma-e4b (Google DeepMind)
Lineage google/gemma-4-E4B β†’ google/gemma-4-E4B-it β†’ google/cellgemma-e4b β†’ this repository
Architecture gemma4
Parameters 8B, as reported by the Hub for the GGUF files
Format GGUF: BF16, Q8_0, Q6_K
Task Perturbation-response prediction (raw text completion, not chat)
Runtime llama.cpp (validated with build b9073e5)
What differs from a stock conversion Gene-symbol tokens are marked USER_DEFINED, so llama.cpp tokenizes gene symbols the same way as the Hugging Face tokenizer
License Apache-2.0

Files

File Size Precision Use it when
cellgemma-e4b-Q8_0.gguf 8.6 GB 8-bit Default choice. Indistinguishable from BF16 within its own run-to-run noise.
cellgemma-e4b-Q6_K.gguf 6.8 GB 6-bit Memory is tight. Same measured quality as Q8_0 on the evaluation set.
cellgemma-e4b-BF16.gguf 15.5 GB 16-bit You want the unquantized reference, or you plan to make your own quantization.

File size is a lower bound on the memory needed. Add the KV cache and compute buffers, which grow with context length.

A 4-bit Q4_K_M build (6.0 GB) is intentionally not included: it showed a small but statistically real quality loss (βˆ’0.055 residual Pearson, 95% CI [βˆ’0.088, βˆ’0.023]).

Quickstart

Start a llama.cpp server (any recent llama.cpp build; validated with b9073e5):

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

-c 8192 leaves headroom: a full CellGemma prompt is roughly 4,500 tokens and generation runs up to 1,024.

Query it from Python:

import httpx

SERVER = "http://127.0.0.1:8080"


def predict(prompt: str, n_predict: int = 1024) -> list[str]:
    """Send a CellGemma prompt and return the ranked gene tokens, e.g. ["+GYPB", "-VIM", ...]."""
    r = httpx.post(
        f"{SERVER}/completion",
        json={
            "prompt": f"<|turn>user\n{prompt}<turn|>\n<|turn>model\n",
            "n_predict": n_predict,
            # The original model'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,
    )
    r.raise_for_status()
    return r.json()["content"].split()


tokens = predict(prompt)  # `prompt` is built as described in the original model card
up = [t[1:] for t in tokens if t.startswith("+")]    # predicted up-regulated, in ranked order
down = [t[1:] for t in tokens if t.startswith("-")]  # predicted down-regulated, in ranked order

To go from the gene list to expression and log-fold-change vectors, use the dataset-specific ExpressionDecoders, control cells and mean_delta_global.json files published with google/cellgemma-e4b, as its model card shows.

Prompt format and output

CellGemma is not a chat model. Build the prompt exactly as the original model card describes (preamble, perturbation, Source:, Mean Global prediction:, Target:), wrap it in the turn markers below, and send it raw to /completion, not to the chat endpoint.

<|turn>user
{prompt}<turn|>
<|turn>model
  • Do not include <bos>. llama.cpp adds it; if it is also in your string, the model sees two.

  • Chat front-ends that wrap your input in a chat template may not reproduce this format. Use an interface that lets you send a raw prompt.

  • Output is a whitespace-separated list of ranked residual differentially expressed genes, each prefixed with + (up) or βˆ’/- (down). Example for a MYC knockdown in K562:

    +GYPB -VIM +BLVRB -WDR43 +HBZ -RRP1B +SLC25A37 -TSR1 +ALAS2 ...
    

    Erythroid genes go up and ribosome-biogenesis genes go down, as expected for this perturbation.

  • Length. Outputs often run to the full 1,024 tokens. A smaller n_predict simply gives a shorter ranked list.

Quick reference for tooling and AI agents

task:             predict transcriptional response to a perturbation (single cell)
endpoint:         POST /completion on llama-server   (NOT /v1/chat/completions)
prompt body:      build exactly as in https://huggingface.co/google/cellgemma-e4b
prompt wrapper:   "<|turn>user\n{prompt}<turn|>\n<|turn>model\n"
bos:              do not include "<bos>" in the prompt string (llama.cpp adds it)
sampling:         temperature 0.7 -> top_k 64 -> top_p 0.95, min_p 0.0
n_predict:        1024 (outputs often use all of it; allow minutes per prediction)
output grammar:   whitespace-separated tokens matching [+-]GENE_SYMBOL, ranked
default file:     cellgemma-e4b-Q8_0.gguf   (lower memory: Q6_K; reference: BF16)
context used:     -c 8192 is sufficient for a full prompt plus 1,024 generated tokens
do not:           re-quantize without keeping the 15 listed tensors in BF16 (NaN output otherwise)
do not:           use for clinical diagnosis, patient care or medical decisions

Why a plain conversion is not enough

CellGemma adds 20,256 human gene symbols (MYC, GAPDH, …) to the Gemma 4 vocabulary as added tokens. Of these, 20,096 cannot be reached by any BPE merge: the Hugging Face tokenizer splits them out of the text before BPE runs.

llama.cpp's convert_hf_to_gguf.py writes them as ordinary tokens. As a result, llama.cpp never produces them and spells every gene in sub-word pieces the model never saw in training. The model still runs, but it reads a different input than the one it was trained on. On a real CellGemma prompt, the stock conversion yields 7,272 tokens where Hugging Face yields 4,484.

These files mark the gene tokens USER_DEFINED, so llama.cpp splits them out first, exactly as Hugging Face does.

Tokenizer parity. Token ids are identical to the Hugging Face tokenizer on 253 of 253 texts. The stock conversion matched none of the 6 texts tried.

Text category Count
Full CellGemma prompts (built from K562 and Tahoe control cells) 56
Knowledge-graph sentences 150
Output-style gene lists 30
Drug SMILES strings 16
Plain sentence 1
Total identical to Hugging Face 253 / 253

You can spot-check parity yourself against a running server:

import httpx
from transformers import AutoTokenizer

text = "your text here"
hf_ids = AutoTokenizer.from_pretrained("google/cellgemma-e4b")(text, add_special_tokens=False)["input_ids"]
gguf_ids = httpx.post("http://127.0.0.1:8080/tokenize", json={"content": text, "add_special": False}).json()["tokens"]
print(hf_ids == gguf_ids)

Validation against the original

All checks ran on a Google Colab T4, using 36 evaluation prompts: 12 CRISPR knockdowns in K562 and 6 drugs in A549 (from the Tahoe controls), two cells each.

Check Result
Same choices as transformers (teacher-forced on 12 prompts Γ— 256 generated tokens) Where 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 92%. Every difference is at a near-tie, where two genes are almost equally likely and bf16 rounding decides.
Well-formed outputs (greedy, 36 Γ— up to 1,024 tokens) 17,555 words, all of the form +GENE / -GENE; 17,554 of them are genes in CellGemma's vocabulary.

Speed on a T4:

Setup Throughput
Single request about 23 tokens/s
4 parallel requests about 7 tokens/s each
Prompt processing 240–370 tokens/s

Quantization quality

Residual Pearson measures agreement between a quantized model's outputs and BF16's outputs, computed on what CellGemma adds on top of the mean-shift baseline. The full log-fold-change correlation is not used, because it is dominated by that shared baseline. Intervals are 95% bootstrap intervals over prompts.

File Size Sampled outputs vs BF16 (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) n/a n/a
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]

Reading the table. The BF16 row is the noise ceiling: two sampled runs of the same model agree at 0.543. Q8_0 and Q6_K fall within that run-to-run variation (the paired difference intervals include zero), so they are indistinguishable from BF16 on this evaluation. The greedy column compares each quantization's greedy output with BF16's greedy output.

Method. The 36 evaluation prompts; outputs of 512 tokens at the original model's sampling settings; outputs converted to expression changes with the K562 and Tahoe ExpressionDecoders.

Quantizing this model yourself

15 tensors stay in BF16 in every quantized file. Inputs to the early MLP down-projections (layers 0–13) and to two per-layer projections reach 3 Γ— 10⁷, far beyond fp16 range. llama.cpp converts 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 the following tensors in BF16 fixes this, at a cost of about 0.4 GB:

blk.{0-9,11,12,13}.ffn_down
blk.{16,23}.proj

Use the files in this repository rather than a quantization of your own, unless you keep exactly these tensors in BF16 (see llama-quantize --help for the per-tensor type options in your build).

Troubleshooting

Symptom Likely cause Fix
Output is NaN or empty A self-made quantization that did not keep the 15 listed tensors in BF16 Use the files in this repository, or keep those tensors in BF16
Prompts tokenize to about 60% more tokens than expected (7,272 vs 4,484 in our test) A stock convert_hf_to_gguf.py conversion Use the files in this repository
Output looks unrelated to the task or conversational Prompt sent to the chat endpoint or wrapped by a chat template Send the raw wrapped prompt to /completion
Slightly degraded results; a duplicate BOS in the log <bos> included in the prompt string Remove <bos>; llama.cpp adds it
Very slow responses Outputs run to 1,024 tokens, and parallel requests share throughput Reduce n_predict, run fewer parallel requests, or use a faster GPU
Out of memory Not enough VRAM for the file plus KV cache Switch to Q6_K, lower -c, or lower -ngl

Intended use and limitations

Intended use. As with the original model: research on predicting transcriptional responses to perturbations.

Out of scope.

  • Clinical diagnosis, patient care or medical decisions.
  • General-purpose chat or instruction following.
  • Treating predictions as measurements. Predictions need laboratory validation.

Limitations.

  • The checks above measure fidelity to the original model, not biological accuracy. For biological performance, see the original model card.
  • Evaluation covers 36 prompts (K562 CRISPR knockdowns and A549 drug perturbations). Other cell types and perturbations were not tested here.
  • Quantized greedy outputs agree with BF16 greedy outputs at 0.77–0.80, not 1.0. Sampled outputs also vary from run to run, including for BF16 itself.
  • Differences from transformers occur at near-ties, where bf16 rounding decides between almost equally likely genes.
  • Validation ran on CUDA (Colab T4) with llama.cpp b9073e5. Other backends and builds were not separately validated.
  • Generation is long (up to 1,024 tokens), so allow minutes per prediction on modest hardware.

Provenance

Source model google/cellgemma-e4b
Conversion tool llama.cpp convert_hf_to_gguf.py
Modification Non-special added tokens (the gene symbols) marked USER_DEFINED in the GGUF vocabulary
Weights BF16 file: unchanged. Q8_0 / Q6_K: quantized, with the 15 tensors above kept in BF16
Validated with llama.cpp b9073e5

License

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.

Citation

If you use this conversion, please cite the original CellGemma work as described on the original model card, and optionally this repository:

@misc{cellgemma_e4b_gguf,
  title        = {CellGemma E4B in GGUF},
  author       = {galinilin},
  year         = {2026},
  howpublished = {\url{https://huggingface.co/Sandeep4235/cellgemma-e4b-GGUF}},
  note         = {GGUF conversion of google/cellgemma-e4b with gene-symbol tokens preserved}
}

Acknowledgements and links

Downloads last month
748
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 Sandeep4235/cellgemma-e4b-GGUF

Quantized
(11)
this model