CellGemma E4B — GGUF (google/cellgemma-e4b)

GGUF conversions and quantizations of Google DeepMind's google/cellgemma-e4b for llama.cpp.

Note: CellGemma is a non-conversational model that takes a structured baseline gene-expression prompt and outputs ranked residual differentially expressed genes (+GENE / -GENE). For continuous expression and log-fold change (LFC) reconstruction, pair these GGUFs with the dataset-specific ExpressionDecoder checkpoints and helper assets (decoders/, controls_sample.json, kg_sentences.json) from google/cellgemma-e4b.


Available Files

File Quantization File Size Notes
cellgemma-e4b-bf16.gguf BF16 14.4 GB Exact lossless unscaled bf16 conversion. Recommended GGUF
cellgemma-e4b-scaled-q8_0.gguf Q8_0 7.7 GB Highest fidelity among quantized variants.
cellgemma-e4b-scaled-q4_k_m.gguf Q4_K_M 5.1 GB Smallest variant; suitable for rapid coarse screening or constrained hardware.

Important Fixes Included in These GGUFs

  1. Gene-Native Tokenizer Fix (token_type = USER_DEFINED): google/cellgemma-e4b extends the Gemma 4 vocabulary with 20,256 human protein-coding gene symbols. Standard convert_hf_to_gguf.py exports these added tokens with token_type = NORMAL (1) and score = -1000.0, causing llama.cpp to split gene symbols into subword pieces. In all GGUFs here, the 20,256 added gene tokens have been patched to token_type = USER_DEFINED (4), achieving exact token-for-token parity with Hugging Face AutoTokenizer on plain text prompts.

  2. RMSNorm-Absorbed Power-of-2 Rescaling (for Q8_0 / Q4_K_M): Early Gemma 4 MLP and Per-Layer Embedding (PLE) projections produce large intermediate activations (peaking >100M in layer 1 MLP) before normalization, which causes fp16 overflow (NaN → <pad> token 0) in quantized ggml-cuda kernels on Turing (sm_75) and similar GPUs. Because Gemma 4 places scale-invariant RMSNorms (post_ffw_norm, post_norm) immediately after these projections, the quantized GGUFs were produced from a power-of-2 rescaled bf16 intermediate (ffn_up, ffn_down, and proj weights across the high-magnitude layers). As shown below, this rescaling is virtually lossless (0.992 Residual r, 1.00 / 1.00 Top-20 DEG overlap vs. unscaled bf16) while eliminating <pad> / NaN overflows completely.


Quantization Fidelity Evaluation

Evaluated across 10 diverse perturbations (5 small-molecule drugs across 5 tahoe control cells: Panobinostat, Vorinostat, Trametinib, Sirolimus, Dexamethasone; plus 4 single and 1 dual combinatorial CRISPR knockdowns across 5 k562 control cells: MYC, TP53, EGFR, BCL2, CEBPE+KLF1), using greedy decoding (temperature=0.0, repeat_penalty=1.0, 512 generated tokens per prompt = up to 256 DEGs/prompt) and Stage 2 ExpressionDecoder reconstruction.

Metric note: Because Total LFC includes the dataset mean-shift baseline (mean_delta_global), Residual r (Pearson correlation of predicted_expr - baseline against the unscaled bf16 GGUF reference, where a collapsed model scores 0.00) and Top-20 Up/Down DEG overlap are the primary measures of quantization fidelity.

Variant File Size <pad> / NaN Tokens (across 10 prompts) Residual r (mean ± std) Total LFC r Top-20 Up / Down Overlap All-256 DEG Jaccard Up / Down
bf16 (unscaled reference) 14.4 GB 0 1.0000 ± 0.000 1.0000 1.00 / 1.00 1.00 / 1.00
bf16_scaled (rescaling verification) 14.4 GB 0 0.9919 ± 0.022 0.9979 1.00 / 1.00 0.97 / 0.97
cellgemma-e4b-scaled-q8_0.gguf 7.7 GB 0 0.7701 ± 0.168 0.9371 0.89 / 0.83 0.58 / 0.70
cellgemma-e4b-scaled-q4_k_m.gguf 5.1 GB 0 0.6632 ± 0.258 0.9203 0.71 / 0.69 0.51 / 0.58

Usage with llama.cpp

Critical setting: Always pass repeat_penalty = 1.0 (--repeat-penalty 1.0 in CLI or "repeat_penalty": 1.0 in /completion). llama.cpp's default 1.1 penalizes the repeated +, -, and space tokens that separate every predicted gene.

Start llama-server

llama-server \
  -m cellgemma-e4b-scaled-q8_0.gguf \
  -c 8192 \
  -ngl 99 \
  --flash-attn on \
  --port 8080

(Optional: to keep the 282K-vocab Per-Layer Embeddings table in host RAM and save GPU memory, add -ot "per_layer_token_embd.*=CPU".)

Query /completion (Python)

import json, urllib.request

# Build `prompt` using the exact template from google/cellgemma-e4b
formatted = f"<|turn>user\n{prompt}<turn|>\n<|turn>model\n"

payload = json.dumps({
    "prompt": formatted,
    "n_predict": 1024,          # Official eval uses up to 8192
    "temperature": 0.7,         # Official eval uses 0.7 (or 0.0 for greedy)
    "repeat_penalty": 1.0,      # Required! Do not leave at 1.1
    "stop": ["<turn|>", "<eos>"],
}).encode("utf-8")

req = urllib.request.Request(
    "http://127.0.0.1:8080/completion",
    data=payload,
    headers={"Content-Type": "application/json"},
)
res = json.loads(urllib.request.urlopen(req).read())
print(res["content"])

License & Attribution

Original model by Google DeepMind (google/cellgemma-e4b), released under the Apache 2.0 license. Intended strictly for research use; not for clinical diagnosis or medical decision-making.

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

4-bit

8-bit

16-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Akkermansia/cellgemma-e4b-gguf

Quantized
(11)
this model