yujiepan commited on
Commit
8d4d59f
1 Parent(s): 8867538

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +48 -0
README.md ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: text-generation
3
+ inference: true
4
+ widget:
5
+ - text: 'Hello!'
6
+ example_title: Hello world
7
+ group: Python
8
+ library_name: transformers
9
+ ---
10
+
11
+ This model is randomly initialized, using the config from [EleutherAI/gpt-j-6b](https://huggingface.co/EleutherAI/gpt-j-6b) but with smaller size.
12
+ Note the model is in float16.
13
+
14
+ Codes:
15
+ ```python
16
+ from huggingface_hub import create_repo, upload_folder
17
+ import torch
18
+ import transformers
19
+ import os
20
+
21
+ model_id = 'EleutherAI/gpt-j-6b'
22
+ save_path = '/tmp/yujiepan/gptj-tiny-random'
23
+ repo_id = 'yujiepan/gptj-tiny-random'
24
+
25
+ config = transformers.AutoConfig.from_pretrained(model_id)
26
+ config.hidden_size = 8
27
+ config.n_embd = 8
28
+ config.num_attention_heads = 2
29
+ config.n_head = 2
30
+ config.n_layer = 2
31
+ print(config)
32
+
33
+ model = transformers.AutoModelForCausalLM.from_config(config, torch_dtype=torch.float16)
34
+ model.save_pretrained(save_path)
35
+
36
+ tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
37
+ tokenizer.save_pretrained(save_path)
38
+
39
+ # from optimum.intel.openvino import OVModelForCausalLM
40
+ # ovmodel = OVModelForCausalLM.from_pretrained(save_path, export=True)
41
+ # ovmodel = ovmodel.half()
42
+ # ovmodel.save_pretrained(save_path)
43
+
44
+ os.system(f'ls -alh {save_path}')
45
+
46
+ create_repo(repo_id, exist_ok=True)
47
+ upload_folder(repo_id=repo_id, folder_path=save_path)
48
+ ```