How to use from the
Use from the
PEFT library
# Gated model: Login with a HF token with gated access permission
hf auth login
from peft import PeftModel
from transformers import AutoModelForCausalLM

base_model = AutoModelForCausalLM.from_pretrained("google/txgemma-9b-predict")
model = PeftModel.from_pretrained(base_model, "PlanesLab/Gemma4EC-9B-Predict")

You need to agree to share your Hugging Face information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

Gemma4EC-9B-Predict

LoRA adapter for google/txgemma-9b-predict that predicts the Enzyme Commission (EC) number of a biochemical reaction from its SMILES, down to the sub-subclass level.

  • Input: a reaction SMILES, e.g. CCO.O=O>>CC=O.OO
  • Output: an EC number, e.g. 1.01.03
  • Code, preprocessing and benchmarks: github.com/PlanesLab/Gemma4EC

Usage

The base model is gated: request access to google/txgemma-9b-predict, then huggingface-cli login.

from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch

base = "google/txgemma-9b-predict"
tokenizer = AutoTokenizer.from_pretrained(base)
model = AutoModelForCausalLM.from_pretrained(base, torch_dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(model, "PlanesLab/Gemma4EC-9B-Predict").eval()

PROMPT = (
    "Instructions: Given a reaction SMILES, predict the first three parts of its "
    "Enzyme Commission (EC) number (class.subclass.sub-subclass).\n"
    "EC numbers are four-part hierarchical codes (e.g., 1.3.2.4) describing the type "
    "of enzyme and its reaction mechanism.\n"
    "Only output the first three digits (e.g., 1.03.02) representing the enzyme's "
    "general class, subclass, and sub-subclass.\n"
    "Reaction SMILES: {reaction_smiles}\nAnswer:"
)

inputs = tokenizer(PROMPT.format(reaction_smiles="CCO.O=O>>CC=O.OO"), return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=8, do_sample=False)
print(tokenizer.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True).strip())

Use this exact prompt. Preprocess SMILES with preprocess_smiles.py from the repository first; batch prediction and chat explanations are also there.

Training

LoRA (r = 16, alpha = 16) on q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj, fine-tuned on ECReact.

Citation

Please cite Gemma4EC (see the repository) and TxGemma.

License

Adapter weights: Apache-2.0. TxGemma weights: Health AI Developer Foundations terms.

Downloads last month
8
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for PlanesLab/Gemma4EC-9B-Predict

Adapter
(1)
this model