dtransposed
commited on
Commit
•
97e3530
1
Parent(s):
5ca0b98
Upload 8 files
Browse files- README.md +74 -0
- config.json +33 -0
- model.safetensors +3 -0
- recipe.yaml +6 -0
- special_tokens_map.json +24 -0
- tokenizer.json +0 -0
- tokenizer.model +3 -0
- tokenizer_config.json +38 -0
README.md
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
base_model: Xenova/llama2.c-stories110M
|
3 |
+
inference: true
|
4 |
+
model_type: llama
|
5 |
+
quantized_by: mgoin
|
6 |
+
tags:
|
7 |
+
- nm-vllm
|
8 |
+
- sparse
|
9 |
+
---
|
10 |
+
|
11 |
+
## llama2.c-stories110M-pruned50
|
12 |
+
This repo contains model files for [llama2.c 110M tinystories](https://huggingface.co/Xenova/llama2.c-stories110M) optimized for [NM-vLLM](https://github.com/neuralmagic/nm-vllm), a high-throughput serving engine for compressed LLMs.
|
13 |
+
|
14 |
+
This model was pruned with [SparseGPT](https://arxiv.org/abs/2301.00774), using [SparseML](https://github.com/neuralmagic/sparseml).
|
15 |
+
|
16 |
+
## Inference
|
17 |
+
Install [NM-vLLM](https://github.com/neuralmagic/nm-vllm) for fast inference and low memory-usage:
|
18 |
+
```bash
|
19 |
+
pip install nm-vllm[sparse]
|
20 |
+
```
|
21 |
+
Run in a Python pipeline for local inference:
|
22 |
+
```python
|
23 |
+
from vllm import LLM, SamplingParams
|
24 |
+
|
25 |
+
model = LLM("nm-testing/llama2.c-stories110M-pruned50", sparsity="sparse_w16a16")
|
26 |
+
prompt = "Hello my name is"
|
27 |
+
|
28 |
+
sampling_params = SamplingParams(max_tokens=100, temperature=0)
|
29 |
+
outputs = model.generate(prompt, sampling_params=sampling_params)
|
30 |
+
print(outputs[0].outputs[0].text)
|
31 |
+
```
|
32 |
+
|
33 |
+
## Prompt template
|
34 |
+
|
35 |
+
N/A
|
36 |
+
|
37 |
+
## Sparsification
|
38 |
+
For details on how this model was sparsified, see the `recipe.yaml` in this repo and follow the instructions below.
|
39 |
+
|
40 |
+
Install [SparseML](https://github.com/neuralmagic/sparseml):
|
41 |
+
```bash
|
42 |
+
git clone https://github.com/neuralmagic/sparseml
|
43 |
+
pip install -e "sparseml[transformers]"
|
44 |
+
```
|
45 |
+
|
46 |
+
Replace the recipe as you like and run this one-shot compression script to apply SparseGPT:
|
47 |
+
```python
|
48 |
+
import sparseml.transformers
|
49 |
+
|
50 |
+
original_model_name = "Xenova/llama2.c-stories110M"
|
51 |
+
calibration_dataset = "open_platypus"
|
52 |
+
output_directory = "output/"
|
53 |
+
|
54 |
+
recipe = """
|
55 |
+
test_stage:
|
56 |
+
obcq_modifiers:
|
57 |
+
SparseGPTModifier:
|
58 |
+
sparsity: 0.5
|
59 |
+
sequential_update: true
|
60 |
+
targets: ['re:model.layers.\d*$']
|
61 |
+
"""
|
62 |
+
|
63 |
+
# Apply SparseGPT to the model
|
64 |
+
sparseml.transformers.oneshot(
|
65 |
+
model=original_model_name,
|
66 |
+
dataset=calibration_dataset,
|
67 |
+
recipe=recipe,
|
68 |
+
output_dir=output_directory,
|
69 |
+
)
|
70 |
+
```
|
71 |
+
|
72 |
+
## Slack
|
73 |
+
|
74 |
+
For further support, and discussions on these models and AI in general, join [Neural Magic's Slack Community](https://join.slack.com/t/discuss-neuralmagic/shared_invite/zt-q1a1cnvo-YBoICSIw3L1dmQpjBeDurQ)
|
config.json
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "/home/damian/.cache/huggingface/hub/models--neuralmagic--llama2.c-stories110M-pruned50/snapshots/ae99c0a865dc99a60311e3fd3fc145eb339cff77",
|
3 |
+
"architectures": [
|
4 |
+
"LlamaForCausalLM"
|
5 |
+
],
|
6 |
+
"attention_bias": false,
|
7 |
+
"attention_dropout": 0.0,
|
8 |
+
"bos_token_id": 1,
|
9 |
+
"eos_token_id": 2,
|
10 |
+
"hidden_act": "silu",
|
11 |
+
"hidden_size": 768,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 2048,
|
14 |
+
"max_position_embeddings": 1024,
|
15 |
+
"model_type": "llama",
|
16 |
+
"num_attention_heads": 12,
|
17 |
+
"num_hidden_layers": 12,
|
18 |
+
"num_key_value_heads": 12,
|
19 |
+
"pretraining_tp": 1,
|
20 |
+
"rms_norm_eps": 1e-05,
|
21 |
+
"rope_scaling": null,
|
22 |
+
"rope_theta": 10000.0,
|
23 |
+
"sparsity_config": {
|
24 |
+
"format": "sparse_bitmask",
|
25 |
+
"global_sparsity": 38.77294698534069,
|
26 |
+
"sparsity_structure": "0:0"
|
27 |
+
},
|
28 |
+
"tie_word_embeddings": true,
|
29 |
+
"torch_dtype": "float32",
|
30 |
+
"transformers_version": "4.39.3",
|
31 |
+
"use_cache": true,
|
32 |
+
"vocab_size": 32000
|
33 |
+
}
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eeefac9ec1d09c9d64dc87cc943a67c1ac2fbba888c7f7c94d12714e28e9cde3
|
3 |
+
size 384641204
|
recipe.yaml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
test_stage:
|
2 |
+
obcq_modifiers:
|
3 |
+
SparseGPTModifier:
|
4 |
+
sparsity: 0.5
|
5 |
+
sequential_update: true
|
6 |
+
targets: ['re:model.layers.\d*$']
|
special_tokens_map.json
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<s>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": true,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"eos_token": {
|
10 |
+
"content": "</s>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": true,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"pad_token": "</s>",
|
17 |
+
"unk_token": {
|
18 |
+
"content": "<unk>",
|
19 |
+
"lstrip": false,
|
20 |
+
"normalized": true,
|
21 |
+
"rstrip": false,
|
22 |
+
"single_word": false
|
23 |
+
}
|
24 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9e556afd44213b6bd1be2b850ebbbd98f5481437a8021afaf58ee7fb1818d347
|
3 |
+
size 499723
|
tokenizer_config.json
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"added_tokens_decoder": {
|
3 |
+
"0": {
|
4 |
+
"content": "<unk>",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": true,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false,
|
9 |
+
"special": true
|
10 |
+
},
|
11 |
+
"1": {
|
12 |
+
"content": "<s>",
|
13 |
+
"lstrip": false,
|
14 |
+
"normalized": true,
|
15 |
+
"rstrip": false,
|
16 |
+
"single_word": false,
|
17 |
+
"special": true
|
18 |
+
},
|
19 |
+
"2": {
|
20 |
+
"content": "</s>",
|
21 |
+
"lstrip": false,
|
22 |
+
"normalized": true,
|
23 |
+
"rstrip": false,
|
24 |
+
"single_word": false,
|
25 |
+
"special": true
|
26 |
+
}
|
27 |
+
},
|
28 |
+
"additional_special_tokens": [],
|
29 |
+
"bos_token": "<s>",
|
30 |
+
"clean_up_tokenization_spaces": false,
|
31 |
+
"eos_token": "</s>",
|
32 |
+
"model_max_length": 2048,
|
33 |
+
"pad_token": "</s>",
|
34 |
+
"sp_model_kwargs": {},
|
35 |
+
"tokenizer_class": "LlamaTokenizer",
|
36 |
+
"unk_token": "<unk>",
|
37 |
+
"use_default_system_prompt": true
|
38 |
+
}
|