Update README.md
Browse files
README.md
CHANGED
@@ -19,11 +19,14 @@ import transformers
|
|
19 |
import torch
|
20 |
import os
|
21 |
from huggingface_hub import create_repo, upload_folder
|
|
|
22 |
|
23 |
source_model_id = 'meta-llama/Meta-Llama-3-8B-Instruct'
|
24 |
save_path = '/tmp/yujiepan/meta-llama-3-tiny-random'
|
25 |
repo_id = 'yujiepan/meta-llama-3-tiny-random'
|
26 |
|
|
|
|
|
27 |
config = transformers.AutoConfig.from_pretrained(
|
28 |
source_model_id,
|
29 |
trust_remote_code=True,
|
@@ -40,6 +43,10 @@ model = transformers.AutoModelForCausalLM.from_config(
|
|
40 |
config,
|
41 |
trust_remote_code=True,
|
42 |
)
|
|
|
|
|
|
|
|
|
43 |
model = model.to(torch.bfloat16)
|
44 |
model.save_pretrained(save_path)
|
45 |
|
@@ -52,6 +59,8 @@ tokenizer.save_pretrained(save_path)
|
|
52 |
model.float().generate(torch.tensor([[1, 2, 3]]).long(), max_length=16)
|
53 |
|
54 |
os.system(f'ls -alh {save_path}')
|
|
|
55 |
create_repo(repo_id, exist_ok=True)
|
56 |
-
upload_folder(repo_id=
|
|
|
57 |
```
|
|
|
19 |
import torch
|
20 |
import os
|
21 |
from huggingface_hub import create_repo, upload_folder
|
22 |
+
import accelerate
|
23 |
|
24 |
source_model_id = 'meta-llama/Meta-Llama-3-8B-Instruct'
|
25 |
save_path = '/tmp/yujiepan/meta-llama-3-tiny-random'
|
26 |
repo_id = 'yujiepan/meta-llama-3-tiny-random'
|
27 |
|
28 |
+
os.system(f'rm -rf {save_path}')
|
29 |
+
|
30 |
config = transformers.AutoConfig.from_pretrained(
|
31 |
source_model_id,
|
32 |
trust_remote_code=True,
|
|
|
43 |
config,
|
44 |
trust_remote_code=True,
|
45 |
)
|
46 |
+
|
47 |
+
with accelerate.init_empty_weights():
|
48 |
+
model.generation_config = transformers.AutoModelForCausalLM.from_pretrained(source_model_id).generation_config
|
49 |
+
|
50 |
model = model.to(torch.bfloat16)
|
51 |
model.save_pretrained(save_path)
|
52 |
|
|
|
59 |
model.float().generate(torch.tensor([[1, 2, 3]]).long(), max_length=16)
|
60 |
|
61 |
os.system(f'ls -alh {save_path}')
|
62 |
+
# os.system(f'rm -rf {save_path}/model.safetensors')
|
63 |
create_repo(repo_id, exist_ok=True)
|
64 |
+
upload_folder(repo_id='yujiepan/meta-llama-3-tiny-random', folder_path=save_path)
|
65 |
+
upload_folder(repo_id='yujiepan/llama-3-tiny-random', folder_path=save_path)
|
66 |
```
|