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
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))
model-00003-of-00005.safetensors 2.0 GBmodel-00002-of-00005.safetensors 2.0 GBmodel-00001-of-00005.safetensors 2.0 GBmodel-00004-of-00005.safetensors 2.0 GBadapter_model.safetensors 132 MBmodel-00005-of-00005.safetensors 102 MBQwen/Qwen3-4B-Instruct-2507