johnrachwanpruna
commited on
Commit
•
2a0f3e2
1
Parent(s):
25aed7e
Update README.md
Browse files
README.md
CHANGED
@@ -31,61 +31,36 @@ metrics:
|
|
31 |
- Read the documentations to know more [here](https://pruna-ai-pruna.readthedocs-hosted.com/en/latest/)
|
32 |
- Join Pruna AI community on Discord [here](https://discord.gg/CP4VSgck) to share feedback/suggestions or get help.
|
33 |
|
34 |
-
## Results
|
35 |
-
|
36 |
-
![image info](./plots.png)
|
37 |
-
|
38 |
**Frequently Asked Questions**
|
39 |
-
- ***How does the compression work?*** The model is compressed by
|
40 |
-
- ***How does the model quality change?*** The quality of the model output
|
41 |
-
- ***
|
42 |
-
- ***What is the model format?*** We used a custom Pruna model format based on pickle to make models compatible with the compression methods. We provide a tutorial to run models in dockers in the documentation [here](https://pruna-ai-pruna.readthedocs-hosted.com/en/latest/) if needed.
|
43 |
-
- ***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.
|
44 |
- ***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).
|
45 |
-
- ***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.
|
46 |
-
- ***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.
|
47 |
|
48 |
-
##
|
49 |
|
50 |
-
|
|
|
|
|
|
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
pip install pruna-engine[gpu]==0.7.1 --extra-index-url https://pypi.nvidia.com --extra-index-url https://pypi.ngc.nvidia.com --extra-index-url https://prunaai.pythonanywhere.com/
|
56 |
-
```
|
57 |
-
2. Download the model files using one of these three options.
|
58 |
-
- Option 1 - Use command line interface (CLI):
|
59 |
-
```bash
|
60 |
-
mkdir mattshumer-Hermes-2-Pro-11B-smashed
|
61 |
-
huggingface-cli download PrunaAI/mattshumer-Hermes-2-Pro-11B-smashed --local-dir mattshumer-Hermes-2-Pro-11B-smashed --local-dir-use-symlinks False
|
62 |
-
```
|
63 |
-
- Option 2 - Use Python:
|
64 |
-
```python
|
65 |
-
import subprocess
|
66 |
-
repo_name = "mattshumer-Hermes-2-Pro-11B-smashed"
|
67 |
-
subprocess.run(["mkdir", repo_name])
|
68 |
-
subprocess.run(["huggingface-cli", "download", 'PrunaAI/'+ repo_name, "--local-dir", repo_name, "--local-dir-use-symlinks", "False"])
|
69 |
-
```
|
70 |
-
- Option 3 - Download them manually on the HuggingFace model page.
|
71 |
-
3. Load & run the model.
|
72 |
-
```python
|
73 |
-
from pruna_engine.PrunaModel import PrunaModel
|
74 |
-
|
75 |
-
model_path = "mattshumer-Hermes-2-Pro-11B-smashed/model" # Specify the downloaded model path.
|
76 |
-
smashed_model = PrunaModel.load_model(model_path) # Load the model.
|
77 |
-
|
78 |
-
smashed_model.to("cuda")
|
79 |
-
prompt = 'What is the color of a prune?'
|
80 |
-
from transformers import AutoTokenizer
|
81 |
-
tokenizer = AutoTokenizer.from_pretrained("mattshumer/Hermes-2-Pro-11B")
|
82 |
-
tokens = tokenizer(prompt, return_tensors="pt").to('cuda')
|
83 |
-
smashed_model(**tokens)
|
84 |
-
```
|
85 |
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
-
|
|
|
|
|
89 |
|
90 |
## Credits & License
|
91 |
|
|
|
31 |
- Read the documentations to know more [here](https://pruna-ai-pruna.readthedocs-hosted.com/en/latest/)
|
32 |
- Join Pruna AI community on Discord [here](https://discord.gg/CP4VSgck) to share feedback/suggestions or get help.
|
33 |
|
|
|
|
|
|
|
|
|
34 |
**Frequently Asked Questions**
|
35 |
+
- ***How does the compression work?*** The model is compressed by using bitsandbytes.
|
36 |
+
- ***How does the model quality change?*** The quality of the model output will slightly degrade.
|
37 |
+
- ***What is the model format?*** We the standard safetensors format.
|
|
|
|
|
38 |
- ***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).
|
|
|
|
|
39 |
|
40 |
+
## Usage
|
41 |
|
42 |
+
``` python
|
43 |
+
from transformers import AutoTokenizer
|
44 |
+
import transformers
|
45 |
+
import torch
|
46 |
|
47 |
+
model = "PrunaAI/mattshumer-Hermes-2-Pro-11B-GPTQ-4bit"
|
48 |
+
tokenizer = "mattshumer/Hermes-2-Pro-11B"
|
49 |
+
messages = [{"role": "user", "content": "What is a large language model?"}]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
+
tokenizer = AutoTokenizer.from_pretrained(tokenizer)
|
52 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
53 |
+
pipeline = transformers.pipeline(
|
54 |
+
"text-generation",
|
55 |
+
tokenizer=tokenizer,
|
56 |
+
model=model,
|
57 |
+
torch_dtype=torch.float16,
|
58 |
+
device_map="auto",
|
59 |
+
)
|
60 |
|
61 |
+
outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
|
62 |
+
print(outputs[0]["generated_text"])
|
63 |
+
```
|
64 |
|
65 |
## Credits & License
|
66 |
|