Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
https://huggingface.co/HuggingFaceM4/tiny-random-LlamaForCausalLM
|
2 |
+
|
3 |
+
```python
|
4 |
+
from sparseml.transformers import SparseAutoModelForCausalLM, SparseAutoTokenizer, oneshot
|
5 |
+
from sparseml.modifiers import SparseGPTModifier
|
6 |
+
|
7 |
+
model_id = "HuggingFaceM4/tiny-random-LlamaForCausalLM"
|
8 |
+
compressed_model_id = "mgoin/tiny-random-LlamaForCausalLM-pruned95-compressed"
|
9 |
+
|
10 |
+
# Apply SparseGPT to the model
|
11 |
+
oneshot(
|
12 |
+
model=model_id,
|
13 |
+
dataset="open_platypus",
|
14 |
+
recipe=SparseGPTModifier(sparsity=0.95),
|
15 |
+
output_dir="temp-output",
|
16 |
+
)
|
17 |
+
|
18 |
+
model = SparseAutoModelForCausalLM.from_pretrained("temp-output", torch_dtype="auto")
|
19 |
+
tokenizer = SparseAutoTokenizer.from_pretrained(model_id)
|
20 |
+
|
21 |
+
model.save_pretrained(compressed_model_id.split("/")[-1], save_compressed=True)
|
22 |
+
tokenizer.save_pretrained(compressed_model_id.split("/")[-1])
|
23 |
+
|
24 |
+
# Upload the checkpoint to Hugging Face
|
25 |
+
from huggingface_hub import HfApi
|
26 |
+
HfApi().upload_folder(
|
27 |
+
folder_path=compressed_model_id.split("/")[-1],
|
28 |
+
repo_id=compressed_model_id,
|
29 |
+
)
|
30 |
+
```
|