Views
No views yet
dnagpt/OmniGene-4-SFT-v5-merged
and then patch it with the artefacts here. A merged BF16 release is forthcoming
as dnagpt/OmniGene-4-MM-merged.| Capability | Stage 3 v3 | v5 (text-only) |
|---|---|---|
| BioPAWS standard homology | 85.0 % | 99.4 % |
| BioPAWS remote homology | 69.5 % | 82.6 % |
Vis-CheBI20 struct_recog | 1.00 | — |
Vis-CheBI20 struct_cap | 0.96 | — |
| Cell-marker → cell-type ID (kw-overlap) | 0.95 | — |
| SMILES → physicochem descriptor (kw-overlap) | 0.91 | — |
| Protein-pair homology generation (kw-overlap) | 1.00 | — |
| Total compute | ~1.5 GPU-days (single H20) | 1.5 GPU-days |
| File | Size | What it is |
|---|---|---|
lora_weights.pt | 160 MB | LoRA adapter state-dict (r=64, α=128, on q/k/v/o, gate/up/down, router.proj) |
embedding_weights.pt | 1.6 GB | Extended embedding table (290,172 × 2,816, BF16) |
tokenizer.json + tokenizer_config.json | 37 MB | Tokenizer with 28,028 biological tokens |
processor_config.json | 2 KB | Multimodal processor configuration |
chat_template.jinja | 16 KB | Chat template |
meta.json | 0.3 KB | Training hyperparameters |
1import torch
2from transformers import AutoTokenizer, AutoProcessor, AutoModelForCausalLM
3from peft import LoraConfig, inject_adapter_in_model
4from huggingface_hub import hf_hub_download
5
6# 1. Load base
7BASE = "dnagpt/OmniGene-4-SFT-v5-merged"
8ADAPTER = "dnagpt/OmniGene-4-MM-LoRA"
9
10tok = AutoTokenizer.from_pretrained(ADAPTER)
11proc = AutoProcessor.from_pretrained(ADAPTER)
12model = AutoModelForCausalLM.from_pretrained(
13 BASE, torch_dtype=torch.bfloat16, device_map="auto",
14)
15
16# 2. Inject empty LoRA at the same target modules used during training
17lora_cfg = LoraConfig(
18 r=64, lora_alpha=128, lora_dropout=0.05, bias="none",
19 target_modules=['q_proj','k_proj','v_proj','o_proj',
20 'gate_proj','up_proj','down_proj','router.proj'],
21)
22inject_adapter_in_model(lora_cfg, model.model.language_model, adapter_name="stage2")
23
24# 3. Patch in trained weights
25sd = model.state_dict()
26for k, v in torch.load(hf_hub_download(ADAPTER, "lora_weights.pt"), map_location="cpu").items():
27 if k in sd: sd[k].copy_(v)
28emb = torch.load(hf_hub_download(ADAPTER, "embedding_weights.pt"), map_location="cpu")
29model.get_input_embeddings().weight.data.copy_(emb)
30model.eval()1from PIL import Image
2
3img = Image.open("molecule.png").convert("RGB")
4msgs = [{"role": "user", "content": [
5 {"type": "image"},
6 {"type": "text", "text": "Please list the functional groups of the molecule."},
7]}]
8text = proc.apply_chat_template(msgs, add_generation_prompt=True, tokenize=False)
9inp = proc(text=text, images=[img], return_tensors="pt").to(model.device)
10
11out = model.generate(**inp, max_new_tokens=160, do_sample=False)
12print(tok.decode(out[0][inp.input_ids.shape[1]:], skip_special_tokens=True))1@article{wang2026omnigene4,
2 title = {OmniGene-4: A Unified Bio-Language MoE Model with Router-Level
3 Interpretability and Modality-Invariant Transfer},
4 author = {Wang, Liang},
5 year = {2026},
6 note = {Manuscript at Patterns (Cell Press). Preprint:
7 bioRxiv 10.1101/2026.01.03.697478. Code:
8 https://github.com/maris205/omnigene4}
9}