41ae017120ec3093574a43b8a6143b01a63780e87ed79add9ddde670e639ff17
Browse files- README.md +88 -0
- config.json +33 -0
- plots.png +0 -0
- qmodel.pt +3 -0
- smash_config.json +31 -0
README.md
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
thumbnail: "https://assets-global.website-files.com/646b351987a8d8ce158d1940/64ec9e96b4334c0e1ac41504_Logo%20with%20white%20text.svg"
|
3 |
+
metrics:
|
4 |
+
- memory_disk
|
5 |
+
- memory_inference
|
6 |
+
- inference_latency
|
7 |
+
- inference_throughput
|
8 |
+
- inference_CO2_emissions
|
9 |
+
- inference_energy_consumption
|
10 |
+
tags:
|
11 |
+
- pruna-ai
|
12 |
+
---
|
13 |
+
<!-- header start -->
|
14 |
+
<!-- 200823 -->
|
15 |
+
<div style="width: auto; margin-left: auto; margin-right: auto">
|
16 |
+
<a href="https://www.pruna.ai/" target="_blank" rel="noopener noreferrer">
|
17 |
+
<img src="https://i.imgur.com/eDAlcgk.png" alt="PrunaAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
|
18 |
+
</a>
|
19 |
+
</div>
|
20 |
+
<!-- header end -->
|
21 |
+
|
22 |
+
[![Twitter](https://img.shields.io/twitter/follow/PrunaAI?style=social)](https://twitter.com/PrunaAI)
|
23 |
+
[![GitHub](https://img.shields.io/github/followers/PrunaAI?label=Follow%20%40PrunaAI&style=social)](https://github.com/PrunaAI)
|
24 |
+
[![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue)](https://www.linkedin.com/company/93832878/admin/feed/posts/?feedType=following)
|
25 |
+
[![Discord](https://img.shields.io/badge/Discord-Join%20Us-blue?style=social&logo=discord)](https://discord.gg/CP4VSgck)
|
26 |
+
|
27 |
+
# Simply make AI models cheaper, smaller, faster, and greener!
|
28 |
+
|
29 |
+
- Give a thumbs up if you like this model!
|
30 |
+
- Contact us and tell us which model to compress next [here](https://www.pruna.ai/contact).
|
31 |
+
- Request access to easily compress your *own* AI models [here](https://z0halsaff74.typeform.com/pruna-access?typeform-source=www.pruna.ai).
|
32 |
+
- Read the documentations to know more [here](https://pruna-ai-pruna.readthedocs-hosted.com/en/latest/)
|
33 |
+
- Join Pruna AI community on Discord [here](https://discord.gg/CP4VSgck) to share feedback/suggestions or get help.
|
34 |
+
|
35 |
+
## Results
|
36 |
+
|
37 |
+
![image info](./plots.png)
|
38 |
+
|
39 |
+
**Frequently Asked Questions**
|
40 |
+
- ***How does the compression work?*** The model is compressed with hqq.
|
41 |
+
- ***How does the model quality change?*** The quality of the model output might vary compared to the base model.
|
42 |
+
- ***How is the model efficiency evaluated?*** These results were obtained on NVIDIA A100-PCIE-40GB with configuration described in `model/smash_config.json` and are obtained after a hardware warmup. The smashed model is directly compared to the original base model. Efficiency results may vary in other settings (e.g. other hardware, image size, batch size, ...). We recommend to directly run them in the use-case conditions to know if the smashed model can benefit you.
|
43 |
+
- ***What is the model format?*** We use safetensors.
|
44 |
+
- ***What calibration data has been used?*** If needed by the compression method, we used WikiText as the calibration data.
|
45 |
+
- ***What is the naming convention for Pruna Huggingface models?*** We take the original model name and append "turbo", "tiny", or "green" if the smashed model has a measured inference speed, inference memory, or inference energy consumption which is less than 90% of the original base model.
|
46 |
+
- ***How to compress my own models?*** You can request premium access to more compression methods and tech support for your specific use-cases [here](https://z0halsaff74.typeform.com/pruna-access?typeform-source=www.pruna.ai).
|
47 |
+
- ***What are "first" metrics?*** Results mentioning "first" are obtained after the first run of the model. The first run might take more memory or be slower than the subsequent runs due cuda overheads.
|
48 |
+
- ***What are "Sync" and "Async" metrics?*** "Sync" metrics are obtained by syncing all GPU processes and stop measurement when all of them are executed. "Async" metrics are obtained without syncing all GPU processes and stop when the model output can be used by the CPU. We provide both metrics since both could be relevant depending on the use-case. We recommend to test the efficiency gains directly in your use-cases.
|
49 |
+
|
50 |
+
## Setup
|
51 |
+
|
52 |
+
You can run the smashed model with these steps:
|
53 |
+
|
54 |
+
0. Check requirements from the original repo KoboldAI/OPT-2.7B-Erebus installed. In particular, check python, cuda, and transformers versions.
|
55 |
+
1. Make sure that you have installed quantization related packages.
|
56 |
+
```bash
|
57 |
+
pip install hqq
|
58 |
+
```
|
59 |
+
2. Load & run the model.
|
60 |
+
```python
|
61 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
62 |
+
from hqq.engine.hf import HQQModelForCausalLM
|
63 |
+
from hqq.models.hf.base import AutoHQQHFModel
|
64 |
+
|
65 |
+
try:
|
66 |
+
model = HQQModelForCausalLM.from_quantized("PrunaAI/KoboldAI-OPT-2.7B-Erebus-HQQ-2bit-smashed", device_map='auto')
|
67 |
+
except:
|
68 |
+
model = AutoHQQHFModel.from_quantized("PrunaAI/KoboldAI-OPT-2.7B-Erebus-HQQ-2bit-smashed")
|
69 |
+
tokenizer = AutoTokenizer.from_pretrained("KoboldAI/OPT-2.7B-Erebus")
|
70 |
+
|
71 |
+
input_ids = tokenizer("What is the color of prunes?,", return_tensors='pt').to(model.device)["input_ids"]
|
72 |
+
|
73 |
+
outputs = model.generate(input_ids, max_new_tokens=216)
|
74 |
+
tokenizer.decode(outputs[0])
|
75 |
+
```
|
76 |
+
|
77 |
+
## Configurations
|
78 |
+
|
79 |
+
The configuration info are in `smash_config.json`.
|
80 |
+
|
81 |
+
## Credits & License
|
82 |
+
|
83 |
+
The license of the smashed model follows the license of the original model. Please check the license of the original model KoboldAI/OPT-2.7B-Erebus before using this model which provided the base model. The license of the `pruna-engine` is [here](https://pypi.org/project/pruna-engine/) on Pypi.
|
84 |
+
|
85 |
+
## Want to compress other models?
|
86 |
+
|
87 |
+
- Contact us and tell us which model to compress next [here](https://www.pruna.ai/contact).
|
88 |
+
- Request access to easily compress your own AI models [here](https://z0halsaff74.typeform.com/pruna-access?typeform-source=www.pruna.ai).
|
config.json
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "KoboldAI/OPT-2.7B-Erebus",
|
3 |
+
"_remove_final_layer_norm": false,
|
4 |
+
"activation_dropout": 0.0,
|
5 |
+
"activation_function": "relu",
|
6 |
+
"antemplate": "[Genre: <|>]",
|
7 |
+
"architectures": [
|
8 |
+
"OPTForCausalLM"
|
9 |
+
],
|
10 |
+
"attention_dropout": 0.0,
|
11 |
+
"bos_token_id": 2,
|
12 |
+
"do_layer_norm_before": true,
|
13 |
+
"dropout": 0.1,
|
14 |
+
"enable_bias": true,
|
15 |
+
"eos_token_id": 2,
|
16 |
+
"ffn_dim": 10240,
|
17 |
+
"hidden_size": 2560,
|
18 |
+
"init_std": 0.02,
|
19 |
+
"layer_norm_elementwise_affine": true,
|
20 |
+
"layerdrop": 0.0,
|
21 |
+
"max_position_embeddings": 2048,
|
22 |
+
"model_type": "opt",
|
23 |
+
"num_attention_heads": 32,
|
24 |
+
"num_hidden_layers": 32,
|
25 |
+
"pad_token_id": 1,
|
26 |
+
"prefix": "</s>",
|
27 |
+
"torch_dtype": "float16",
|
28 |
+
"transformers_version": "4.37.1",
|
29 |
+
"use_cache": false,
|
30 |
+
"vocab_size": 50265,
|
31 |
+
"welcome": "## Warning: This model has a very heavy NSFW bias and is not suitable for use by minors!\n\nYou are currently running story-writing model `Erebus, version 1 (2.7B).`\n\n This model is made by [Mr. Seeker](https://www.patreon.com/mrseeker) with help of ProudNoob and the KoboldAI team.\n\n### How to use this model\n\nErebus is designed to generate short stories and novels. Use the author's note to give it a certain genre to follow, use memory to give an overview of the story and use World Information to give specific details about the characters. To start off, give the AI an idea of what you are writing about by setting the scene. Give the AI around 10 sentences that make your story interesting to read. Introduce your character, describe the world, blow something up, or let the AI use its creative mind.",
|
32 |
+
"word_embed_proj_dim": 2560
|
33 |
+
}
|
plots.png
ADDED
![]() |
qmodel.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:946ae7d049cba6dabe501fa62ed4ee4fd3c00d504767568ac657893dfd24f76d
|
3 |
+
size 958524414
|
smash_config.json
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"api_key": null,
|
3 |
+
"verify_url": "http://johnrachwan.pythonanywhere.com",
|
4 |
+
"smash_config": {
|
5 |
+
"pruners": "None",
|
6 |
+
"pruning_ratio": 0.0,
|
7 |
+
"factorizers": "None",
|
8 |
+
"quantizers": "['hqq']",
|
9 |
+
"weight_quantization_bits": 2,
|
10 |
+
"output_deviation": 0.005,
|
11 |
+
"compilers": "None",
|
12 |
+
"static_batch": true,
|
13 |
+
"static_shape": true,
|
14 |
+
"controlnet": "None",
|
15 |
+
"unet_dim": 4,
|
16 |
+
"device": "cuda",
|
17 |
+
"cache_dir": "/ceph/hdd/staff/charpent/.cache/modelspn8gs7s6",
|
18 |
+
"batch_size": 1,
|
19 |
+
"model_name": "KoboldAI/OPT-2.7B-Erebus",
|
20 |
+
"task": "text_text_generation",
|
21 |
+
"max_batch_size": 1,
|
22 |
+
"qtype_weight": "torch.qint8",
|
23 |
+
"qtype_activation": "torch.quint8",
|
24 |
+
"qobserver": "<class 'torch.ao.quantization.observer.MinMaxObserver'>",
|
25 |
+
"qscheme": "torch.per_tensor_symmetric",
|
26 |
+
"qconfig": "x86",
|
27 |
+
"group_size": 128,
|
28 |
+
"damp_percent": 0.1,
|
29 |
+
"save_load_fn": "hqq"
|
30 |
+
}
|
31 |
+
}
|