Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
# yujiepan/opt-tiny-2layers-random
|
12 |
+
|
13 |
+
This model is **randomly initialized**, using the config from [https://huggingface.co/facebook/opt-30b], but with following changes:
|
14 |
+
```python
|
15 |
+
config.ffn_dim = 32
|
16 |
+
config.hidden_size = 8
|
17 |
+
config.num_attention_heads = 2
|
18 |
+
config.num_hidden_layers = 2
|
19 |
+
config.word_embed_proj_dim = 8
|
20 |
+
```
|
21 |
+
|
22 |
+
Codes for this model:
|
23 |
+
```python
|
24 |
+
import torch
|
25 |
+
import transformers
|
26 |
+
import os
|
27 |
+
from optimum.intel.openvino import OVModelForCausalLM
|
28 |
+
|
29 |
+
save_path = '/tmp/yujiepan/opt-tiny-2layers-random'
|
30 |
+
repo_id = 'yujiepan/opt-tiny-2layer-random'
|
31 |
+
|
32 |
+
config = transformers.AutoConfig.from_pretrained('facebook/opt-30b')
|
33 |
+
config.ffn_dim = 32
|
34 |
+
config.hidden_size = 8
|
35 |
+
config.num_attention_heads = 2
|
36 |
+
config.num_hidden_layers = 2
|
37 |
+
config.word_embed_proj_dim = 8
|
38 |
+
|
39 |
+
model = transformers.AutoModelForCausalLM.from_config(config, torch_dtype=torch.float16)
|
40 |
+
model.save_pretrained(save_path)
|
41 |
+
|
42 |
+
tokenizer = transformers.AutoTokenizer.from_pretrained('facebook/opt-30b')
|
43 |
+
tokenizer.save_pretrained(save_path)
|
44 |
+
|
45 |
+
ovmodel = OVModelForCausalLM.from_pretrained(save_path, export=True)
|
46 |
+
ovmodel = ovmodel.half()
|
47 |
+
ovmodel.save_pretrained(save_path)
|
48 |
+
|
49 |
+
os.system(f'ls -alh {save_path}')
|
50 |
+
|
51 |
+
from huggingface_hub import create_repo, upload_folder
|
52 |
+
create_repo(repo_id, exist_ok=True)
|
53 |
+
upload_folder(repo_id=repo_id, folder_path=save_path)
|
54 |
+
```
|