Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 [tiiuae/falcon-40b](https://huggingface.co/tiiuae/falcon-40b) but with smaller size.
|
12 |
+
Note:
|
13 |
+
- The model uses "new architecture" in Falcon-40b.
|
14 |
+
- The model is in float16.
|
15 |
+
|
16 |
+
Codes:
|
17 |
+
```python
|
18 |
+
import transformers
|
19 |
+
from optimum.intel.openvino import OVModelForCausalLM
|
20 |
+
import torch
|
21 |
+
import os
|
22 |
+
from huggingface_hub import create_repo, upload_folder
|
23 |
+
|
24 |
+
source_model_id = 'tiiuae/falcon-40b'
|
25 |
+
save_path = '/tmp/yujiepan/falcon-new-tiny-random'
|
26 |
+
repo_id = 'yujiepan/falcon-new-tiny-random'
|
27 |
+
|
28 |
+
config = transformers.AutoConfig.from_pretrained(
|
29 |
+
source_model_id, trust_remote_code=True)
|
30 |
+
config.hidden_size = 8
|
31 |
+
config.num_attention_heads = 2
|
32 |
+
config.num_hidden_layers = 2
|
33 |
+
config.torch_dtype = torch.float16
|
34 |
+
|
35 |
+
model = transformers.AutoModelForCausalLM.from_config(
|
36 |
+
config, trust_remote_code=True)
|
37 |
+
model = model.half()
|
38 |
+
model.save_pretrained(save_path)
|
39 |
+
|
40 |
+
tokenizer = transformers.AutoTokenizer.from_pretrained(
|
41 |
+
source_model_id, trust_remote_code=True)
|
42 |
+
tokenizer.save_pretrained(save_path)
|
43 |
+
|
44 |
+
# current not supported, might add this later
|
45 |
+
# ovmodel = OVModelForCausalLM.from_pretrained(
|
46 |
+
# save_path, export=True, trust_remote_code=True)
|
47 |
+
# ovmodel.save_pretrained(save_path)
|
48 |
+
|
49 |
+
os.system(f'ls -alh {save_path}')
|
50 |
+
create_repo(repo_id, exist_ok=True)
|
51 |
+
upload_folder(repo_id=repo_id, folder_path=save_path)
|
52 |
+
```
|