Instructions to use zjunlp/MolGen-large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zjunlp/MolGen-large with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("zjunlp/MolGen-large") model = AutoModelForSeq2SeqLM.from_pretrained("zjunlp/MolGen-large", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Yin Fang commited on
Commit ·
dbfa68a
1
Parent(s): e613244
Update README.md
Browse files
README.md
CHANGED
|
@@ -27,12 +27,12 @@ Molecule generation example:
|
|
| 27 |
>>> sf_input = tokenizer("[C][=C][C][=C][C][=C][Ring1][=Branch1]", return_tensors="pt")
|
| 28 |
>>> # beam search
|
| 29 |
>>> molecules = model.generate(input_ids=sf_input["input_ids"],
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
>>> sf_output = [tokenizer.decode(g, skip_special_tokens=True, clean_up_tokenization_spaces=True).replace(" ","") for g in molecules]
|
| 37 |
['[C][=C][C][=C][C][=C][Ring1][=Branch1]', '[C][=C][C][=C][C][=C][C][=C][Ring1][=Branch1]', '[C][=C][C][=C][C][=C][Ring1][=Branch1][C@H1][C][=C][C][=C][C][=C][Ring1][=Branch1]', '[C][=C][C][=C][C][=C][Ring1][=Branch1][C][=C][C][=C][C][=C][Ring1][=Branch1]', '[C][=C][C][=C][C][=C][Ring1][=Branch1][C@H1][=C][C][=C][Ring1][=Branch1]']
|
| 38 |
```
|
|
|
|
| 27 |
>>> sf_input = tokenizer("[C][=C][C][=C][C][=C][Ring1][=Branch1]", return_tensors="pt")
|
| 28 |
>>> # beam search
|
| 29 |
>>> molecules = model.generate(input_ids=sf_input["input_ids"],
|
| 30 |
+
attention_mask=sf_input["attention_mask"],
|
| 31 |
+
max_length=20,
|
| 32 |
+
min_length=5,
|
| 33 |
+
num_return_sequences=5,
|
| 34 |
+
num_beams=5,
|
| 35 |
+
past_prompt=None)
|
| 36 |
>>> sf_output = [tokenizer.decode(g, skip_special_tokens=True, clean_up_tokenization_spaces=True).replace(" ","") for g in molecules]
|
| 37 |
['[C][=C][C][=C][C][=C][Ring1][=Branch1]', '[C][=C][C][=C][C][=C][C][=C][Ring1][=Branch1]', '[C][=C][C][=C][C][=C][Ring1][=Branch1][C@H1][C][=C][C][=C][C][=C][Ring1][=Branch1]', '[C][=C][C][=C][C][=C][Ring1][=Branch1][C][=C][C][=C][C][=C][Ring1][=Branch1]', '[C][=C][C][=C][C][=C][Ring1][=Branch1][C@H1][=C][C][=C][Ring1][=Branch1]']
|
| 38 |
```
|