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
Two silent inference pitfalls (PubChem/EmeraldBay Kekulé SMILES & 8,192-token Stage-2 tail flips) + 772-run benchmark
Sharing three reproducible inference findings across 772 bfloat16 runs at max_new_tokens = 8,192 that may be useful to document in the model card's Best Practices:
- PubChem /
EmeraldBayKekulé SMILES vs. RDKit Aromatic SMILES (p = 0.0078): Passing uppercase Kekulé SMILES (C1=CC=CC=C1— the default in PubChem andtahoebio/EmeraldBay'sdrug_metadata.parquet) instead of RDKit canonical aromatic SMILES (c1ccccc1) silently rotates or collapses Stage-1 predictions for the exact same molecule across 8/8 tested aromatic drugs (mean within-format cosine = +0.726vs.cross-format = +0.276; e.g.,Panobinostat +0.297,NVP-BHG712 +0.239,Sotorasib +0.065,Menadione +0.006). Canonicalizing viaChem.MolToSmiles(Chem.MolFromSmiles(s), isomericSmiles=True, canonical=True)restores expected behavior (lifting matched A549 HederageninGSE186218to#1 / 29against decoys andtahoe_mean_delta_global). 8,192-Token Cap Without EOS & Stage-2 Tail Sign Flips (Norman 2019,n = 131pairs):15.1%(tahoe),21.8%(norman), and29.3%(emeraldbay2-drug combos) reach8,192tokens without<eos>/<turn|>. At ~4,000 emitted genes,ExpressionDecoderextrapolates past its training rank range and assigns positive deltas up to+0.601to downregulated-GENEtokens; enforcing a 1-line sign clamp (+GENE >= 0,-GENE <= 0) lifts Norman 2019 (k = 3,S = 12,441) all-genePearson Δfrom+0.5016to+0.5560(+0.5811when capped at<= 256tokens).- Drug-Pair Prompt Order (
EmeraldBay,n = 20clinical 2-drug regimens): AtT = 0.7, reversing[Drug A, Drug B]to[Drug B, Drug A]drops residual cosine from+0.594to+0.408(p = 2.67e-5, e.g.,Trifluridine + Tipiracil:+0.647vs.+0.166), while post-hoc0.5 * (AB + BA)averaging improves Norman wet-labPearson Δ(+0.5016 -> +0.5325).
All 772 raw outputs and a <1s zero-dependency Python 3 stdlib verifier (Apache-2.0): https://github.com/dsugurtuna/cellgemma-chemistry-bench
Thanks for the 772-run benchmark, and for isolating the format issue so cleanly. The Kekulé versus aromatic SMILES result is the one that stays with us: the same molecule, a within-format cosine of +0.726 against +0.276 cross-format, with canonicalizing restoring the expected behaviour. Silent input-format effects like that are exactly what field reports catch and model cards rarely do. The 8,192-token tail sign flips matter for the same reason, and the sign clamp lifting Norman 2019 Pearson Δ from +0.5016 to +0.5560 gives a concrete check others can rerun. We also noted the drug-pair order effect. Useful data, clearly reported.