1import sys
2import torch
3sys.path.append('./desformers/src')
4from torch.utils.checkpoint import checkpoint
5from transformers2 import BertConfig, BertTokenizer
6from transformers2.models.bert import BertForMaskedLM
7
8preload_path = 'cabrooks/character-level-logion'
9char_tokenizer = BertTokenizer.from_pretrained(preload_path)
10wordpiece_tokenizer = BertTokenizer.from_pretrained("cabrooks/LOGION-50k_wordpiece")
11config = BertConfig()
12config.word_piece_vocab_size = 50000
13config.vocab_size = char_tokenizer.vocab_size
14config.char_tokenizer = char_tokenizer
15config.wordpiece_tokenizer = wordpiece_tokenizer
16config.max_position_embeddings = 1024
17config.device2 = device
18model = BertForMaskedLM(config).to(device)
Download the weights from "my_custom_model.pth".
Load these weights into the model:
You are now ready to use the model.
This model was developed by Desmond DeVaul for his senior thesis at Princeton University.
It was built on the work of the Logion team at Princeton:
https://www.logionproject.princeton.edu.