Downloads · 30 days
0
suku9/smiles-tokenizer
smiles-tokenizer is a machine learning model from suku9. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This is a custom tokenizer for SMILES (Simplified Molecular Input Line Entry System) strings.
Downloads · 30 days
0
Access
Public
Updated Apr 12, 2025
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py15.2 KB · 79%
From the Hugging Face model README
This is a custom tokenizer for SMILES (Simplified Molecular Input Line Entry System) strings.
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained('suku9/smiles-tokenizer')
# Tokenize a SMILES string
tokens = tokenizer.tokenize('CC(=O)OC1=CC=CC=C1C(=O)O')
print(tokens)
# Encode a SMILES string
encoded = tokenizer('CC(=O)OC1=CC=CC=C1C(=O)O', return_tensors='pt')
print(encoded)
# Use with a GPT-2 model
from transformers import GPT2LMHeadModel
model = GPT2LMHeadModel.from_pretrained('gpt2')
# Resize model embeddings to match tokenizer vocabulary size
model.resize_token_embeddings(len(tokenizer))