laituan245
commited on
Commit
•
5c4d1d5
1
Parent(s):
97af73d
Update README.md
Browse files
README.md
CHANGED
@@ -8,10 +8,13 @@ This model can be used to generate a SMILES string from an input caption.
|
|
8 |
## Example Usage
|
9 |
```python
|
10 |
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
|
|
11 |
tokenizer = T5Tokenizer.from_pretrained("laituan245/molt5-small-caption2smiles", model_max_length=512)
|
12 |
model = T5ForConditionalGeneration.from_pretrained('laituan245/molt5-small-caption2smiles')
|
|
|
13 |
input_text = 'The molecule is a monomethoxybenzene that is 2-methoxyphenol substituted by a hydroxymethyl group at position 4. It has a role as a plant metabolite. It is a member of guaiacols and a member of benzyl alcohols.'
|
14 |
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
|
|
15 |
outputs = model.generate(input_ids, num_beams=5, max_length=512)
|
16 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
17 |
# The model will generate "COC1=C(C=CC(=C1)CCCO)O". The ground-truth is "COC1=C(C=CC(=C1)CO)O".
|
|
|
8 |
## Example Usage
|
9 |
```python
|
10 |
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
11 |
+
|
12 |
tokenizer = T5Tokenizer.from_pretrained("laituan245/molt5-small-caption2smiles", model_max_length=512)
|
13 |
model = T5ForConditionalGeneration.from_pretrained('laituan245/molt5-small-caption2smiles')
|
14 |
+
|
15 |
input_text = 'The molecule is a monomethoxybenzene that is 2-methoxyphenol substituted by a hydroxymethyl group at position 4. It has a role as a plant metabolite. It is a member of guaiacols and a member of benzyl alcohols.'
|
16 |
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
17 |
+
|
18 |
outputs = model.generate(input_ids, num_beams=5, max_length=512)
|
19 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
20 |
# The model will generate "COC1=C(C=CC(=C1)CCCO)O". The ground-truth is "COC1=C(C=CC(=C1)CO)O".
|