yujiepan commited on
Commit
23061d7
1 Parent(s): 9a17f05

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 [bigscience/bloom-560m](https://huggingface.co/bigscience/bloom-560m) 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 = 'bigscience/bloom-560m'
22
+ save_path = '/tmp/yujiepan/bloom-tiny-random'
23
+ repo_id = 'yujiepan/bloom-tiny-random'
24
+
25
+ config = transformers.AutoConfig.from_pretrained(model_id)
26
+ config.hidden_size = 8
27
+ config.num_attention_heads = 2
28
+ config.n_head = 2
29
+ config.n_layer = 2
30
+ config.pretraining_tp = 1
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
+ ```