|
|
|
|
|
|
|
|
|
|
|
|
|
import torch |
|
from transformers import BertTokenizer, BertModel, GPT2LMHeadModel, GPT2Tokenizer |
|
|
|
|
|
bert_model_name = 'bert-base-uncased' |
|
bert_tokenizer = BertTokenizer.from_pretrained(bert_model_name) |
|
bert_model = BertModel.from_pretrained(bert_model_name) |
|
|
|
gpt2_model_name = 'gpt2' |
|
gpt2_tokenizer = GPT2Tokenizer.from_pretrained(gpt2_model_name) |
|
gpt2_model = GPT2LMHeadModel.from_pretrained(gpt2_model_name) |
|
|
|
|
|
bert_model.save_pretrained("bert_model") |
|
bert_tokenizer.save_pretrained("bert_model") |
|
|
|
|
|
gpt2_model.save_pretrained("gpt2_model") |
|
gpt2_tokenizer.save_pretrained("gpt2_model") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|