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
Keep first gene mentions in the CellGemma model card example
The model card's parse_genes passes repeated mentions to the expression decoder. Repeats change the directional ranks and list lengths. A gene mentioned in both directions receives two deltas at the same output index. This patch keeps the first valid mention, matching the hosted demo.
I replayed one saved 8-bit Panobinostat example with the released Tahoe decoder. The response contained 4,096 valid signed mentions for 3,356 distinct genes. The patch changed 2,871 of 19,720 reconstructed expression values by more than 0.00001, with a maximum absolute change of 0.500 in log-normalized expression. A separate NumPy replay reproduced the count.
I ran the following regression test from the repository root. It exits 1 on the published README and 0 with the patch. It needs only the Python standard library.
python - README.md <<'PY'
import ast
from pathlib import Path
import sys
readme = Path(sys.argv[1]).read_text()
example = readme.split("```python\n")[2].split("\n```", 1)[0]
parser = next(node for node in ast.parse(example).body
if isinstance(node, ast.FunctionDef) and node.name == "parse_genes")
namespace = {}
exec(compile(ast.Module(body=[parser], type_ignores=[]), "<example>", "exec"), namespace)
parse_genes = namespace["parse_genes"]
genes = {"A": 0, "B-2": 1, "C": 2, "D": 3}
assert parse_genes("-a +B-2 +unknown +A +b-2 -C +D -c", genes) == (["B-2", "D"], ["A", "C"])
assert parse_genes("A + - +unknown", genes) == ([], [])
assert parse_genes("+A -C +B-2", genes) == (["A", "B-2"], ["C"])
PY
🤖 Generated with Claude Code