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.

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
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for henrichyusef/chemdfm-odor-lora

Adapter
(8)
this model