Add ZipNN stuff
Browse files
README.md
CHANGED
@@ -12,8 +12,67 @@ widget:
|
|
12 |
- role: user
|
13 |
content: Can you provide ways to eat combinations of bananas and dragonfruits?
|
14 |
library_name: transformers
|
|
|
|
|
15 |
---
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
## Model Summary
|
18 |
|
19 |
Phi-3.5-mini is a lightweight, state-of-the-art open model built upon datasets used for Phi-3 - synthetic data and filtered publicly available websites - with a focus on very high-quality, reasoning dense data. The model belongs to the Phi-3 model family and supports 128K token context length. The model underwent a rigorous enhancement process, incorporating both supervised fine-tuning, proximal policy optimization, and direct preference optimization to ensure precise instruction adherence and robust safety measures.
|
@@ -141,16 +200,19 @@ After obtaining the Phi-3.5-mini-instruct model checkpoint, users can use this s
|
|
141 |
```python
|
142 |
import torch
|
143 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
|
|
|
|
|
|
144 |
|
145 |
torch.random.manual_seed(0)
|
146 |
|
147 |
model = AutoModelForCausalLM.from_pretrained(
|
148 |
-
"
|
149 |
device_map="cuda",
|
150 |
torch_dtype="auto",
|
151 |
trust_remote_code=True,
|
152 |
)
|
153 |
-
tokenizer = AutoTokenizer.from_pretrained("
|
154 |
|
155 |
messages = [
|
156 |
{"role": "system", "content": "You are a helpful AI assistant."},
|
|
|
12 |
- role: user
|
13 |
content: Can you provide ways to eat combinations of bananas and dragonfruits?
|
14 |
library_name: transformers
|
15 |
+
base_model:
|
16 |
+
- microsoft/Phi-3.5-mini-instruct
|
17 |
---
|
18 |
|
19 |
+
# Disclaimer and Requirements
|
20 |
+
|
21 |
+
This model is a clone of [**microsoft/Phi-3.5-mini-instruct**](https://huggingface.co/microsoft/Phi-3.5-mini-instruct) compressed using ZipNN. Compressed losslessly to 67% its original size, ZipNN saved ~3GB in storage and potentially ~1PB in data transfer **monthly**.
|
22 |
+
|
23 |
+
### Requirement
|
24 |
+
|
25 |
+
In order to use the model, ZipNN is necessary:
|
26 |
+
```bash
|
27 |
+
pip install zipnn
|
28 |
+
```
|
29 |
+
### Use This Model
|
30 |
+
```python
|
31 |
+
# Use a pipeline as a high-level helper
|
32 |
+
from transformers import pipeline
|
33 |
+
from zipnn import zipnn_hf
|
34 |
+
|
35 |
+
zipnn_hf()
|
36 |
+
|
37 |
+
messages = [
|
38 |
+
{"role": "user", "content": "Who are you?"},
|
39 |
+
]
|
40 |
+
pipe = pipeline("text-generation", model="royleibov/Phi-3.5-mini-instruct-ZipNN-Compressed")
|
41 |
+
pipe(messages)
|
42 |
+
```
|
43 |
+
```python
|
44 |
+
# Load model directly
|
45 |
+
import torch
|
46 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
47 |
+
from zipnn import zipnn_hf
|
48 |
+
|
49 |
+
zipnn_hf()
|
50 |
+
|
51 |
+
torch.random.manual_seed(0)
|
52 |
+
|
53 |
+
model = AutoModelForCausalLM.from_pretrained(
|
54 |
+
"royleibov/Phi-3.5-mini-instruct-ZipNN-Compressed",
|
55 |
+
device_map="cuda",
|
56 |
+
torch_dtype="auto",
|
57 |
+
trust_remote_code=True,
|
58 |
+
)
|
59 |
+
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3.5-mini-instruct")
|
60 |
+
```
|
61 |
+
### ZipNN
|
62 |
+
ZipNN also allows you to seemlessly save local disk space in your cache after the model is downloaded.
|
63 |
+
|
64 |
+
To compress the cached model, simply run:
|
65 |
+
```bash
|
66 |
+
python zipnn_compress_path.py safetensors --model royleibov/Phi-3.5-mini-instruct-ZipNN-Compressed --hf_cache
|
67 |
+
```
|
68 |
+
|
69 |
+
The model will be decompressed automatically and safely as long as `zipnn_hf()` is added at the top of the file like in the [example above](#use-this-model).
|
70 |
+
|
71 |
+
To decompress manualy, simply run:
|
72 |
+
```bash
|
73 |
+
python zipnn_decompress_path.py --model royleibov/Phi-3.5-mini-instruct-ZipNN-Compressed --hf_cache
|
74 |
+
```
|
75 |
+
|
76 |
## Model Summary
|
77 |
|
78 |
Phi-3.5-mini is a lightweight, state-of-the-art open model built upon datasets used for Phi-3 - synthetic data and filtered publicly available websites - with a focus on very high-quality, reasoning dense data. The model belongs to the Phi-3 model family and supports 128K token context length. The model underwent a rigorous enhancement process, incorporating both supervised fine-tuning, proximal policy optimization, and direct preference optimization to ensure precise instruction adherence and robust safety measures.
|
|
|
200 |
```python
|
201 |
import torch
|
202 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
203 |
+
from zipnn import zipnn_hf
|
204 |
+
|
205 |
+
zipnn_hf()
|
206 |
|
207 |
torch.random.manual_seed(0)
|
208 |
|
209 |
model = AutoModelForCausalLM.from_pretrained(
|
210 |
+
"royleibov/Phi-3.5-mini-instruct-ZipNN-Compressed",
|
211 |
device_map="cuda",
|
212 |
torch_dtype="auto",
|
213 |
trust_remote_code=True,
|
214 |
)
|
215 |
+
tokenizer = AutoTokenizer.from_pretrained("royleibov/Phi-3.5-mini-instruct-ZipNN-Compressed")
|
216 |
|
217 |
messages = [
|
218 |
{"role": "system", "content": "You are a helpful AI assistant."},
|