yujiepan commited on
Commit
2d5dd51
1 Parent(s): 553f3a6

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -0
README.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 [neuralmagic/mpt-7b-gsm8k-pt](https://huggingface.co/neuralmagic/mpt-7b-gsm8k-pt) but with smaller size.
12
+ Note the model is in float16.
13
+
14
+ Codes:
15
+ ```python
16
+ from transformers import pipeline
17
+ from huggingface_hub import create_repo, upload_folder
18
+ import torch
19
+ import transformers
20
+ import os
21
+
22
+ model_id = 'neuralmagic/mpt-7b-gsm8k-pt'
23
+ save_path = '/tmp/yujiepan/mpt-tiny-random'
24
+ repo_id = 'yujiepan/mpt-tiny-random'
25
+
26
+ config = transformers.AutoConfig.from_pretrained(model_id)
27
+ config.hidden_size = 8
28
+ config.n_embd_model = 8
29
+ config.num_attention_heads = 2
30
+ config.n_heads = 2
31
+ config.num_hidden_layers = 2
32
+ config.n_layers = 2
33
+ print(config)
34
+
35
+ model = transformers.AutoModelForCausalLM.from_config(config, torch_dtype=torch.float16)
36
+ model = model.half()
37
+ model.save_pretrained(save_path)
38
+
39
+ tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
40
+ tokenizer.save_pretrained(save_path)
41
+
42
+ # from optimum.intel.openvino import OVModelForCausalLM
43
+ # ovmodel = OVModelForCausalLM.from_pretrained(save_path, export=True)
44
+ # ovmodel.save_pretrained(save_path)
45
+
46
+ os.system(f'ls -alh {save_path}')
47
+ create_repo(repo_id, exist_ok=True)
48
+ upload_folder(repo_id=repo_id, folder_path=save_path)
49
+ ```