Download examples/deepseek_7b.py from Angshul/LayerInteractions: direct link, hf CLI and curl.
- Browser
- Download file 632 Bytes
-
https://huggingface.co/Angshul/LayerInteractions/resolve/main/examples/deepseek_7b.py
- Command line
-
hf download hf://Angshul/LayerInteractions/examples/deepseek_7b.py
-
curl -L -o deepseek_7b.py https://huggingface.co/Angshul/LayerInteractions/resolve/main/examples/deepseek_7b.py
632 Bytes
| from datasets import load_dataset | |
| from layer_interactions import Order2Pruner | |
| MODEL = "deepseek-ai/deepseek-llm-7b-base" | |
| texts = [ | |
| row["text"] | |
| for row in load_dataset( | |
| "Salesforce/wikitext", "wikitext-2-raw-v1", split="train" | |
| ) | |
| if row["text"].strip() | |
| ] | |
| with Order2Pruner(MODEL, dtype="bfloat16") as pruner: | |
| result = pruner.fit( | |
| texts=texts, | |
| n_sequences=32, | |
| sequence_length=128, | |
| seed=42, | |
| checkpoint_path="deepseek_order2.json", | |
| max_delete=23, # enough for 30 -> 7 | |
| ) | |
| print("30 -> 15:", result.select(15)) | |
| print("30 -> 7:", result.select(7)) | |