Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This model is randomly initialized, using the config from [https://huggingface.co/tiiuae/falcon-7b] but with smaller size.
|
| 2 |
+
Note the model is in float16.
|
| 3 |
+
|
| 4 |
+
Codes:
|
| 5 |
+
```python
|
| 6 |
+
import transformers
|
| 7 |
+
from optimum.intel.openvino import OVModelForCausalLM
|
| 8 |
+
import torch
|
| 9 |
+
import os
|
| 10 |
+
|
| 11 |
+
source_model_id = 'tiiuae/falcon-7b'
|
| 12 |
+
save_path = '/tmp/yujiepan/falcon-tiny-random'
|
| 13 |
+
repo_id = 'yujiepan/falcon-tiny-random'
|
| 14 |
+
|
| 15 |
+
config = transformers.AutoConfig.from_pretrained(source_model_id, trust_remote_code=True)
|
| 16 |
+
config.hidden_size = 8
|
| 17 |
+
config.n_head = 2
|
| 18 |
+
config.n_layer = 2
|
| 19 |
+
config.torch_dtype = 'float16'
|
| 20 |
+
|
| 21 |
+
model = transformers.AutoModelForCausalLM.from_config(config,trust_remote_code=True)
|
| 22 |
+
model.save_pretrained(save_path)
|
| 23 |
+
|
| 24 |
+
tokenizer = transformers.AutoTokenizer.from_pretrained(source_model_id, trust_remote_code=True)
|
| 25 |
+
tokenizer.save_pretrained(save_path)
|
| 26 |
+
|
| 27 |
+
# current not supported, might add this later
|
| 28 |
+
# ovmodel = OVModelForCausalLM.from_pretrained(save_path, export=True, trust_remote_code=True)
|
| 29 |
+
# ovmodel.save_pretrained(save_path)
|
| 30 |
+
|
| 31 |
+
os.system(f'ls -alh {save_path}')
|
| 32 |
+
from huggingface_hub import create_repo, upload_folder
|
| 33 |
+
create_repo(repo_id, exist_ok=True)
|
| 34 |
+
upload_folder(repo_id=repo_id, folder_path=save_path)
|
| 35 |
+
```
|