Yin Fang
commited on
Commit
·
17d47f2
1
Parent(s):
936e738
Update README.md
Browse files
README.md
CHANGED
|
@@ -13,9 +13,23 @@ With a training corpus of over 100 million molecules in SELFIES representation,
|
|
| 13 |
Specifically, MolGen employs a bidirectional Transformer as its encoder and an autoregressive Transformer as its decoder.
|
| 14 |
Through its carefully designed multi-task molecular prefix tuning (MPT), MolGen can generate molecules with desired properties, making it a valuable tool for molecular optimization.
|
| 15 |
|
| 16 |
-
## Intended uses
|
| 17 |
You can use the raw model for molecular generation or fine-tune it to a downstream task. See the [repository](https://github.com/zjunlp/MolGen) to look for fine-tune details on a task that interests you.
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
### BibTeX entry and citation info
|
| 20 |
```bibtex
|
| 21 |
@article{fang2023molecular,
|
|
|
|
| 13 |
Specifically, MolGen employs a bidirectional Transformer as its encoder and an autoregressive Transformer as its decoder.
|
| 14 |
Through its carefully designed multi-task molecular prefix tuning (MPT), MolGen can generate molecules with desired properties, making it a valuable tool for molecular optimization.
|
| 15 |
|
| 16 |
+
## Intended uses
|
| 17 |
You can use the raw model for molecular generation or fine-tune it to a downstream task. See the [repository](https://github.com/zjunlp/MolGen) to look for fine-tune details on a task that interests you.
|
| 18 |
|
| 19 |
+
### How to use
|
| 20 |
+
Molecule generation example:
|
| 21 |
+
```python
|
| 22 |
+
from transformers import AutoTokenizer, BartForConditionalGeneration
|
| 23 |
+
|
| 24 |
+
tokenizer = AutoTokenizer.from_pretrained("zjunlp/MolGen")
|
| 25 |
+
model = BartForConditionalGeneration.from_pretrained("zjunlp/MolGen", use_auth_token=True)
|
| 26 |
+
|
| 27 |
+
sf_input = tokenizer("[C][=C][C][=C][C][=C][Ring1][=Branch1]", return_tensors="pt")
|
| 28 |
+
molecules = model.generate(input_ids=sf_input["input_ids"],attention_mask=sf_input["attention_mask"],max_length=20,min_length=5,num_return_sequences=5,num_beams=5,past_prompt=None)
|
| 29 |
+
sf_output = [tokenizer.decode(g, skip_special_tokens=True, clean_up_tokenization_spaces=True).replace(" ","") for g in molecules]
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
|
| 33 |
### BibTeX entry and citation info
|
| 34 |
```bibtex
|
| 35 |
@article{fang2023molecular,
|