Retrosynthesis Qwen3-4B

Qwen3-4B fine-tuned for retrosynthetic route prediction via GRPO on Prime Intellect.

Given a target molecule SMILES, predicts reactant molecules that can synthesize it.

Training: GRPO with 6-component RDKit reward rubric (validity, SA score, stock match, atom conservation) Dataset: USPTO-50K via rhoahndur/retrosyn-targets

Usage

from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("rhoahndur/retrosynthesis-qwen3-4b")
tokenizer = AutoTokenizer.from_pretrained("rhoahndur/retrosynthesis-qwen3-4b")

messages = [
    {"role": "system", "content": "You are a retrosynthesis expert. Given a target molecule SMILES, predict reactant SMILES separated by dots. Output ONLY SMILES, no explanation."},
    {"role": "user", "content": "Predict the reactants for: CC(=O)Oc1ccccc1C(=O)O"}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=128, temperature=0.7, do_sample=True)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))

Demo

Retrosynthesis AI on HuggingFace Spaces

Downloads last month
4
Safetensors
Model size
4B params
Tensor type
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for rhoahndur/retrosynthesis-qwen3-4b

Finetuned
(1940)
this model
Quantizations
2 models