Instructions to use henrichyusef/chemdfm-odor-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use henrichyusef/chemdfm-odor-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("OpenDFM/ChemDFM-v1.5-8B") model = PeftModel.from_pretrained(base_model, "henrichyusef/chemdfm-odor-lora") - Notebooks
- Google Colab
- Kaggle
ChemDFM odor predictor (LoRA)
QLoRA adapter for OpenDFM/ChemDFM-v1.5-8B that predicts the odor descriptors of a molecule from its SMILES. Output groups: Primary, Sub.
Usage
The SMILES must be RDKit-canonical, and the prompt must match the training template exactly.
import torch
from rdkit import Chem
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
bnb = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=torch.bfloat16)
base = AutoModelForCausalLM.from_pretrained("OpenDFM/ChemDFM-v1.5-8B", quantization_config=bnb, device_map="auto")
model = PeftModel.from_pretrained(base, "henrichyusef/chemdfm-odor-lora").eval()
tok = AutoTokenizer.from_pretrained("henrichyusef/chemdfm-odor-lora")
smiles = Chem.MolToSmiles(Chem.MolFromSmiles("CC(=O)OCC(C)C"))
prompt = "[Round 0]\nHuman: List the primary odors and sub-odors of the molecule CC(=O)OCC(C)C. Answer only with the odor labels.\nAssistant:".replace("CC(=O)OCC(C)C", smiles)
inputs = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=200, do_sample=False)
print(tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
odor_pipeline/vocab.json lists the label vocabulary (and merged aliases) used for parsing and scoring.
- Downloads last month
- 1
Model tree for henrichyusef/chemdfm-odor-lora
Base model
OpenDFM/ChemDFM-v1.5-8B