gaur3009 commited on
Commit
6c54217
1 Parent(s): 86f6872

Upload save_model.py

Browse files
Files changed (1) hide show
  1. save_model.py +32 -0
save_model.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ # In[1]:
5
+
6
+
7
+ import torch
8
+ from transformers import BertTokenizer, BertModel, GPT2LMHeadModel, GPT2Tokenizer
9
+
10
+ # Load pre-trained models and tokenizers
11
+ bert_model_name = 'bert-base-uncased'
12
+ bert_tokenizer = BertTokenizer.from_pretrained(bert_model_name)
13
+ bert_model = BertModel.from_pretrained(bert_model_name)
14
+
15
+ gpt2_model_name = 'gpt2'
16
+ gpt2_tokenizer = GPT2Tokenizer.from_pretrained(gpt2_model_name)
17
+ gpt2_model = GPT2LMHeadModel.from_pretrained(gpt2_model_name)
18
+
19
+ # Save BERT model and tokenizer
20
+ bert_model.save_pretrained("bert_model")
21
+ bert_tokenizer.save_pretrained("bert_model")
22
+
23
+ # Save GPT-2 model and tokenizer
24
+ gpt2_model.save_pretrained("gpt2_model")
25
+ gpt2_tokenizer.save_pretrained("gpt2_model")
26
+
27
+
28
+ # In[ ]:
29
+
30
+
31
+
32
+