Views
No views yet
1from transformers import BertForMaskedLM, PreTrainedTokenizerFast
2
3# Load the tokenizer and model
4tokenizer = PreTrainedTokenizerFast.from_pretrained('thaonguyen217/farm_molecular_representation')
5model = BertForMaskedLM.from_pretrained('thaonguyen217/farm_molecular_representation')
6
7# Example usage
8input_text = "N_primary_amine N_secondary_amine c_6-6 1 n_6-6 n_6-6 c_6-6 c_6-6 2 c_6-6 c_6-6 c_6-6 c_6-6 c_6-6 1 2" # FG-enhanced representation of NNc1nncc2ccccc12
9inputs = tokenizer(input_text, return_tensors='pt')
10outputs = model(**inputs, output_hidden_states=True)
11
12# Extract atom embeddings from last hidden states
13last_hidden_states = outputs.hidden_states[-1][0] # last_hidden_states: (N, 768) with N is input length
model.safetensors: The main model weights.config.json: Contains configuration parameters for the model architecture.generation_config.json: Configuration for text generation settings.special_tokens_map.json: Mapping of special tokens used by the tokenizer.tokenizer.json: Tokenizer configuration file.tokenizer_config.json: Additional settings for the tokenizer..gitattributes: Git attributes file specifying LFS for large files.pip install transformers torch