Instructions to use Hamdan003/inventmol-r1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Hamdan003/inventmol-r1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Hamdan003/inventmol-r1")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Hamdan003/inventmol-r1", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Hamdan003/inventmol-r1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Hamdan003/inventmol-r1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Hamdan003/inventmol-r1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Hamdan003/inventmol-r1
- SGLang
How to use Hamdan003/inventmol-r1 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Hamdan003/inventmol-r1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Hamdan003/inventmol-r1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Hamdan003/inventmol-r1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Hamdan003/inventmol-r1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Hamdan003/inventmol-r1 with Docker Model Runner:
docker model run hf.co/Hamdan003/inventmol-r1
InventMol-R1
Target-Conditioned Molecular Ideation Model for Drug Discovery Research
Research prototype. Not for clinical use. No experimental validation.
Model Description
InventMol-R1 is a fine-tuned version of Qwen2.5-0.5B that generates novel drug-like molecules conditioned on biological context. Given a protein target, disease, mutation, and mechanism of action, the model outputs molecular structures in SELFIES format.
This model demonstrates the concept of reasoning-guided molecular ideation aligned with modern AI-driven drug discovery pipelines.
Intended Use
- Research prototype for computational drug discovery
- Molecular ideation and scaffold hopping
- Educational demonstration of LLMs in cheminformatics
- Target-conditioned molecular generation
Training Data
Trained on tyrosine kinase inhibitors with bioactivity data from ChEMBL, filtered for drug-likeness and converted to SELFIES representation. The dataset includes:
- 7+ protein targets (EGFR, BRAF, ALK, KIT, VEGFR, BTK, FGFR, MET, RET)
- Multiple disease contexts (NSCLC, melanoma, GIST, AML, etc.)
- Clinically relevant mutations (T790M, V600E, D816V, etc.)
- Mechanism of action annotations
- Potency labels (active, intermediate, inactive)
Quick Start
from unsloth import FastLanguageModel
from selfies import decoder
from rdkit import Chem
from rdkit.Chem import Descriptors
import re
model, tokenizer = FastLanguageModel.from_pretrained("Hamdan003/InventMol-R1")
def extract_selfies(text):
matches = re.findall(r'\[[^\]]*\]', text)
if len(matches) >= 5:
first = text.find(matches[0])
count = 0
for i in range(first, len(text)):
if text[i] == '[': count += 1
elif text[i] == ']':
count -= 1
if count == 0: return text[first:i+1]
return ""
def generate_molecule(target, disease, mutation, mechanism):
prompt = f"[Target]: {target}\n[Disease]: {disease}\n[Mutation]: {mutation}\n[Mechanism]: {mechanism}\n[Potency]: High\n"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=300, temperature=0.7, do_sample=True, top_p=0.95)
generated = tokenizer.decode(outputs[0], skip_special_tokens=True)
selfies_str = extract_selfies(generated)
if selfies_str:
smiles = decoder(selfies_str)
mol = Chem.MolFromSmiles(smiles)
if mol:
return smiles, Descriptors.MolWt(mol), Descriptors.MolLogP(mol)
return None, 0, 0
smiles, mw, logp = generate_molecule("EGFR", "NSCLC", "T790M", "Irreversible covalent inhibition")
print(f"SMILES: {smiles}\nMW: {mw:.0f}\nLogP: {logp:.1f}")
Model tree for Hamdan003/inventmol-r1
Base model
Qwen/Qwen2.5-0.5B