zjunlp / MolGen-7b

huggingface.co
Total runs: 1.1K
24-hour runs: 0
7-day runs: 7
30-day runs: 363
Model's Last Updated: March 04 2024
text-generation

Introduction of MolGen-7b

Model Details of MolGen-7b

💡 Model description

This repo contains a large molecular generative model built with molecular language SELFIES.

🔍 Intended uses

You can use the model to generate molecules from scratch (i.e., inputting the bos_token), or input a partial structure for the model to complete.

🛠️ How to use

We have provided two types of examples. You can modify the input, generation parameters, etc., according to your needs.

  • Denovo molecule generation example:
>>> from transformers import AutoTokenizer, LlamaForCausalLM
>>> import torch

>>> tokenizer = AutoTokenizer.from_pretrained("zjunlp/MolGen-7b")
>>> model = LlamaForCausalLM.from_pretrained(
                              "zjunlp/MolGen-7b",
                              load_in_8bit=True,
                              torch_dtype=torch.float16,
                              device_map="auto",
                              )
>>> device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
>>> sf_input = tokenizer(tokenizer.bos_token, return_tensors="pt").to(device)

>>> molecules = model.generate(input_ids=sf_input["input_ids"],
                              attention_mask=sf_input["attention_mask"],
                              do_sample=True,
                              max_new_tokens=10,
                              top_p=0.75,
                              top_k=30,
                              return_dict_in_generate=False,
                              num_return_sequences=5,
                              )
>>> sf_output = [tokenizer.decode(g, skip_special_tokens=True, clean_up_tokenization_spaces=True).replace(" ","") for g in molecules]
['[C][C][=C][C][=C][Branch2][Ring1][=Branch2][C][=Branch1]',
'[C][N][C][C][C][Branch2][Ring2][Ring2][N][C]',
'[C][O][C][=C][C][=C][C][Branch2][Ring1][Branch1]',
'[C][N][C][C][C@H1][Branch2][Ring1][Branch2][N][Branch1]',
'[C][=C][C][Branch2][Ring1][#C][C][=Branch1][C][=O]']
  • Molecular completion example:
>>> from transformers import AutoTokenizer, LlamaForCausalLM
>>> import torch

>>> tokenizer = AutoTokenizer.from_pretrained("zjunlp/MolGen-7b")
>>> model = LlamaForCausalLM.from_pretrained(
                              "zjunlp/MolGen-7b",
                              load_in_8bit=True,
                              torch_dtype=torch.float16,
                              device_map="auto",
                              )
>>> device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
>>> sf_input = tokenizer("[C][N][O]", return_tensors="pt").to(device)

>>> molecules = model.generate(input_ids=sf_input["input_ids"],
                              attention_mask=sf_input["attention_mask"],
                              do_sample=True,
                              max_new_tokens=10,
                              top_p=0.75,
                              top_k=30,
                              return_dict_in_generate=False,
                              num_return_sequences=5,
                              )
>>> sf_output = [tokenizer.decode(g, skip_special_tokens=True, clean_up_tokenization_spaces=True).replace(" ","") for g in molecules]
['[C][N][O][C][=Branch1][C][=O][/C][Ring1][=Branch1][=C][/C][=C]',
'[C][N][O][/C][=Branch1][#Branch1][=C][/N][Branch1][C][C][C][C]',
'[C][N][O][/C][=C][/C][=C][C][=Branch1][C][=O][C][=C]',
'[C][N][O][C][=Branch1][C][=O][N][Branch1][C][C][C][=Branch1]',
'[C][N][O][Ring1][Branch1][C][C][C][C][C][C][C][C]']
📚 Citation

If you use our repository, please cite:

@inproceedings{fang2023domain,
  author       = {Yin Fang and
                  Ningyu Zhang and
                  Zhuo Chen and
                  Xiaohui Fan and
                  Huajun Chen},
  title        = {Domain-Agnostic Molecular Generation with Chemical Feedback},
  booktitle    = {{ICLR}},
  publisher    = {OpenReview.net},
  year         = {2024},
  url          = {https://openreview.net/pdf?id=9rPyHyjfwP}
}

Runs of zjunlp MolGen-7b on huggingface.co

1.1K
Total runs
0
24-hour runs
-24
3-day runs
7
7-day runs
363
30-day runs

More Information About MolGen-7b huggingface.co Model

More MolGen-7b license Visit here:

https://choosealicense.com/licenses/apache-2.0

MolGen-7b huggingface.co

MolGen-7b huggingface.co is an AI model on huggingface.co that provides MolGen-7b's model effect (), which can be used instantly with this zjunlp MolGen-7b model. huggingface.co supports a free trial of the MolGen-7b model, and also provides paid use of the MolGen-7b. Support call MolGen-7b model through api, including Node.js, Python, http.

MolGen-7b huggingface.co Url

https://huggingface.co/zjunlp/MolGen-7b

zjunlp MolGen-7b online free

MolGen-7b huggingface.co is an online trial and call api platform, which integrates MolGen-7b's modeling effects, including api services, and provides a free online trial of MolGen-7b, you can try MolGen-7b online for free by clicking the link below.

zjunlp MolGen-7b online free url in huggingface.co:

https://huggingface.co/zjunlp/MolGen-7b

MolGen-7b install

MolGen-7b is an open source model from GitHub that offers a free installation service, and any user can find MolGen-7b on GitHub to install. At the same time, huggingface.co provides the effect of MolGen-7b install, users can directly use MolGen-7b installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

MolGen-7b install url in huggingface.co:

https://huggingface.co/zjunlp/MolGen-7b

Url of MolGen-7b

MolGen-7b huggingface.co Url

Provider of MolGen-7b huggingface.co

zjunlp
ORGANIZATIONS

Other API from zjunlp

huggingface.co

Total runs: 589
Run Growth: -601
Growth Rate: -102.04%
Updated:March 04 2024
huggingface.co

Total runs: 36
Run Growth: -50
Growth Rate: -138.89%
Updated:May 06 2024
huggingface.co

Total runs: 16
Run Growth: -14
Growth Rate: -87.50%
Updated:March 21 2023
huggingface.co

Total runs: 11
Run Growth: 0
Growth Rate: 0.00%
Updated:October 01 2025
huggingface.co

Total runs: 10
Run Growth: 3
Growth Rate: 30.00%
Updated:October 01 2025
huggingface.co

Total runs: 3
Run Growth: 0
Growth Rate: 0.00%
Updated:July 28 2023
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:December 22 2022
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:December 07 2024
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:June 09 2025
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:May 10 2026
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:February 17 2023