Inoob commited on
Commit
d39f1b0
·
verified ·
1 Parent(s): 6692a04

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +46 -3
README.md CHANGED
@@ -1,3 +1,46 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model: openai-community/gpt2-large
4
+ ---
5
+ # GPT2-LARGE ARCHITECTURE MODEL
6
+
7
+ ## Description
8
+
9
+ This is a GPT2-LARGE Model, but only with the architecture, no pre-trained weights, biases, attention, etc.
10
+
11
+ This is useful for researchers who want to play with training the model (not tuning).
12
+
13
+ Generated via the github repo [Model Architecture Generator](https://github.com/ivanhe123/Model-Architecture-Generator)
14
+
15
+ ## Use
16
+ First go into the directory of the model and then:
17
+ ```
18
+ from transformers import AutoModel, AutoTokenizer
19
+ import torch
20
+ import os
21
+ import argparse
22
+
23
+ # Use the provided paths for input and output
24
+ model_name = "./gpt2-large-architecture"
25
+ output_dir = "./gpt2-large-reset"
26
+
27
+ model = AutoModel.from_pretrained(model_name)
28
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
29
+
30
+ for name, param in model.named_parameters():
31
+ if param.dim() > 1:
32
+ torch.nn.init.xavier_uniform_(param)
33
+ else:
34
+ torch.nn.init.zeros_(param)
35
+
36
+ if not os.path.exists(output_dir):
37
+ os.makedirs(output_dir)
38
+
39
+ model.save_pretrained(output_dir)
40
+ tokenizer.save_pretrained(output_dir)
41
+
42
+ print(f"Model with randomized parameters saved to: {output_dir}")
43
+
44
+ ```
45
+
46
+