Downloads · 30 days
9
11% of all-time downloads
jonghyunlee/MoLLaMA
MoLLaMA is a machine learning model from jonghyunlee. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers, DeepChem.
MoLLaMA-Small is a lightweight LLaMA-based causal language model (57.2M parameters) trained from scratch to generate valid chemical molecules using SMILES strings.
Downloads · 30 days
9
11% of all-time downloads
All-time downloads
81
Public
Parameters
57.5M
115 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors115 MB · 100%
From the Hugging Face model README
MoLLaMA-Small is a lightweight LLaMA-based causal language model (57.2M parameters) trained from scratch to generate valid chemical molecules using SMILES strings.
This model uses DeepChem's SmilesTokenizer and was trained on a combined dataset of ZINC15 and MuMOInstruct. It is designed for unconditional molecule generation.
The model was evaluated on 30 randomly generated samples from the test set. It demonstrates perfect validity and high diversity in generating chemical structures.
| Metric | Score |
|---|---|
| Parameters | 57.2 M |
| Validity | 100.0% |
| Average QED | 0.6400 |
| Diversity | 0.8363 |
A custom, scaled-down LLaMA architecture was used to optimize for chemical language modeling:
You can easily load this model using the standard transformers library. The model generates SMILES strings by prompting it with the [bos] (Beginning of Sequence) token.
Make sure you have the required libraries installed:
pip install transformers torch deepchem
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
# 1. Load Model and Tokenizer
model_id = "jonghyunlee/MoLLaMA"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto"
)
# 2. Prepare Prompt for Unconditional Generation
prompt = "[bos]"
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to(model.device)
# 3. Generate SMILES
model.eval()
with torch.no_grad():
outputs = model.generate(
input_ids=inputs.input_ids,
attention_mask=inputs.attention_mask,
max_new_tokens=256,
do_sample=True,
temperature=0.7,
top_p=0.9,
)
# 4. Decode the output
generated_smiles = tokenizer.decode(outputs[0], skip_special_tokens=True).replace(" ", "")
print(f"Generated SMILES: {generated_smiles}")
ZINC15 + MuMOInstruct (Parquet format)