Spaces:
Running on Zero
Match Studio preset summaries to the requested perturbation
The Studio picks a preset verdict from predicted gene signatures alone, and it runs the same check on partial and finished responses. I ran the public bfloat16 weights on MPS with the Studio's default 180-token greedy settings on K562 cell 0. Both the GATA1 and TP53 requests produced a completed response that said "muting DNMT1."
The patch matches the request by dataset, perturbation kind, and either the validated gene or the drug name and canonical SMILES. The 5 preset summaries still require their original gene signatures. Other requests get the generic summary. I replayed the two completions and checked that all 90 GATA1 and 89 TP53 gene entries, including their expression values, matched exactly.
I ran the test below from the Space checkout with its requirements installed. It checks partial and final summaries for GATA1 and DNMT1 using the same fixed completion. It exits 1 on upstream and 0 with the patch.
from engine import AutoTokenizer, CellGemmaEngine
class FixedCompletion:
def generate(self, streamer, **kwargs):
streamer.on_finalized_text("+SLC7A8 -NOLC1 ", stream_end=True)
engine = CellGemmaEngine()
engine.device = "cpu"
engine._tokenizer = AutoTokenizer.from_pretrained(engine.model_id)
engine._model = FixedCompletion()
for target in ("GATA1", "DNMT1"):
events = list(engine.stream_predict("k562", 0, "crispr", gene=target))
summaries = [event["state"]["verdict"]["summary"] for event in events if "state" in event]
assert len(summaries) == 2
assert all(("muting DNMT1" in summary) == (target == "DNMT1") for summary in summaries), target
🤖 Generated with Claude Code