File size: 8,563 Bytes
b8bb5ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2ac1404
b8bb5ac
 
 
 
 
8e0b084
e540ea0
237f2f0
 
1bb0cd9
b8bb5ac
 
 
 
 
6657ecb
b8bb5ac
8e0b084
e540ea0
422ec48
50c802d
237f2f0
9c3d3de
2ffe157
b8bb5ac
237f2f0
687cc65
a227875
b8bb5ac
 
 
 
1bb0cd9
83c959c
b8bb5ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
---
base_model: microsoft/Phi-3-mini-4k-instruct
inference: false
language:
- en
library_name: gguf
license: mit
license_link: https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/resolve/main/LICENSE
pipeline_tag: text-generation
quantized_by: legraphista
tags:
- nlp
- code
- quantized
- GGUF
- quantization
- imat
- imatrix
- static
- 16bit
- 8bit
- 6bit
- 5bit
- 4bit
- 3bit
- 2bit
- 1bit
---

# Phi-3-mini-4k-instruct-IMat-GGUF
_Llama.cpp imatrix quantization of microsoft/Phi-3-mini-4k-instruct_

Original Model: [microsoft/Phi-3-mini-4k-instruct](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct)    
Original dtype: `BF16` (`bfloat16`)  
Quantized by:  llama.cpp [b3286](https://github.com/ggerganov/llama.cpp/releases/tag/b3286)  
IMatrix dataset: [here](https://gist.githubusercontent.com/bartowski1182/eb213dccb3571f863da82e99418f81e8/raw/b2869d80f5c16fd7082594248e80144677736635/calibration_datav3.txt)  

- [Files](#files)
    - [IMatrix](#imatrix)
    - [Common Quants](#common-quants)
    - [All Quants](#all-quants)
- [Downloading using huggingface-cli](#downloading-using-huggingface-cli)
- [Inference](#inference)
    - [Simple chat template](#simple-chat-template)
    - [Chat template with system prompt](#chat-template-with-system-prompt)
    - [Llama.cpp](#llama-cpp)
- [FAQ](#faq)
    - [Why is the IMatrix not applied everywhere?](#why-is-the-imatrix-not-applied-everywhere)
    - [How do I merge a split GGUF?](#how-do-i-merge-a-split-gguf)

---

## Files

### IMatrix
Status: βœ… Available  
Link: [here](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/imatrix.dat)

### Common Quants
| Filename | Quant type | File Size | Status | Uses IMatrix | Is Split |
| -------- | ---------- | --------- | ------ | ------------ | -------- |
| [Phi-3-mini-4k-instruct.Q8_0.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q8_0.gguf) | Q8_0 | 4.06GB | βœ… Available | βšͺ Static | πŸ“¦ No
| [Phi-3-mini-4k-instruct.Q6_K.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q6_K.gguf) | Q6_K | 3.14GB | βœ… Available | βšͺ Static | πŸ“¦ No
| [Phi-3-mini-4k-instruct.Q4_K.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q4_K.gguf) | Q4_K | 2.39GB | βœ… Available | 🟒 IMatrix | πŸ“¦ No
| [Phi-3-mini-4k-instruct.Q3_K.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q3_K.gguf) | Q3_K | 1.96GB | βœ… Available | 🟒 IMatrix | πŸ“¦ No
| [Phi-3-mini-4k-instruct.Q2_K.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q2_K.gguf) | Q2_K | 1.42GB | βœ… Available | 🟒 IMatrix | πŸ“¦ No


### All Quants
| Filename | Quant type | File Size | Status | Uses IMatrix | Is Split |
| -------- | ---------- | --------- | ------ | ------------ | -------- |
| [Phi-3-mini-4k-instruct.BF16.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.BF16.gguf) | BF16 | 7.64GB | βœ… Available | βšͺ Static | πŸ“¦ No
| Phi-3-mini-4k-instruct.FP16 | F16 | - | ⏳ Processing | βšͺ Static | -
| [Phi-3-mini-4k-instruct.Q8_0.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q8_0.gguf) | Q8_0 | 4.06GB | βœ… Available | βšͺ Static | πŸ“¦ No
| [Phi-3-mini-4k-instruct.Q6_K.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q6_K.gguf) | Q6_K | 3.14GB | βœ… Available | βšͺ Static | πŸ“¦ No
| [Phi-3-mini-4k-instruct.Q5_K.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q5_K.gguf) | Q5_K | 2.82GB | βœ… Available | βšͺ Static | πŸ“¦ No
| [Phi-3-mini-4k-instruct.Q5_K_S.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q5_K_S.gguf) | Q5_K_S | 2.64GB | βœ… Available | βšͺ Static | πŸ“¦ No
| [Phi-3-mini-4k-instruct.Q4_K.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q4_K.gguf) | Q4_K | 2.39GB | βœ… Available | 🟒 IMatrix | πŸ“¦ No
| [Phi-3-mini-4k-instruct.Q4_K_S.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q4_K_S.gguf) | Q4_K_S | 2.19GB | βœ… Available | 🟒 IMatrix | πŸ“¦ No
| [Phi-3-mini-4k-instruct.IQ4_NL.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.IQ4_NL.gguf) | IQ4_NL | 2.18GB | βœ… Available | 🟒 IMatrix | πŸ“¦ No
| Phi-3-mini-4k-instruct.IQ4_XS | IQ4_XS | - | ⏳ Processing | 🟒 IMatrix | -
| [Phi-3-mini-4k-instruct.Q3_K.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q3_K.gguf) | Q3_K | 1.96GB | βœ… Available | 🟒 IMatrix | πŸ“¦ No
| [Phi-3-mini-4k-instruct.Q3_K_L.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q3_K_L.gguf) | Q3_K_L | 2.09GB | βœ… Available | 🟒 IMatrix | πŸ“¦ No
| [Phi-3-mini-4k-instruct.Q3_K_S.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q3_K_S.gguf) | Q3_K_S | 1.68GB | βœ… Available | 🟒 IMatrix | πŸ“¦ No
| Phi-3-mini-4k-instruct.IQ3_M | IQ3_M | - | ⏳ Processing | 🟒 IMatrix | -
| Phi-3-mini-4k-instruct.IQ3_S | IQ3_S | - | ⏳ Processing | 🟒 IMatrix | -
| Phi-3-mini-4k-instruct.IQ3_XS | IQ3_XS | - | ⏳ Processing | 🟒 IMatrix | -
| Phi-3-mini-4k-instruct.IQ3_XXS | IQ3_XXS | - | ⏳ Processing | 🟒 IMatrix | -
| [Phi-3-mini-4k-instruct.Q2_K.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q2_K.gguf) | Q2_K | 1.42GB | βœ… Available | 🟒 IMatrix | πŸ“¦ No
| [Phi-3-mini-4k-instruct.Q2_K_S.gguf](https://huggingface.co/legraphista/Phi-3.1-mini-4k-instruct/blob/main/Phi-3-mini-4k-instruct.Q2_K_S.gguf) | Q2_K_S | 1.33GB | βœ… Available | 🟒 IMatrix | πŸ“¦ No
| Phi-3-mini-4k-instruct.IQ2_M | IQ2_M | - | ⏳ Processing | 🟒 IMatrix | -
| Phi-3-mini-4k-instruct.IQ2_S | IQ2_S | - | ⏳ Processing | 🟒 IMatrix | -
| Phi-3-mini-4k-instruct.IQ2_XS | IQ2_XS | - | ⏳ Processing | 🟒 IMatrix | -
| Phi-3-mini-4k-instruct.IQ2_XXS | IQ2_XXS | - | ⏳ Processing | 🟒 IMatrix | -
| Phi-3-mini-4k-instruct.IQ1_M | IQ1_M | - | ⏳ Processing | 🟒 IMatrix | -
| Phi-3-mini-4k-instruct.IQ1_S | IQ1_S | - | ⏳ Processing | 🟒 IMatrix | -


## Downloading using huggingface-cli
If you do not have hugginface-cli installed:
```
pip install -U "huggingface_hub[cli]"
```
Download the specific file you want:
```
huggingface-cli download legraphista/Phi-3.1-mini-4k-instruct --include "Phi-3-mini-4k-instruct.Q8_0.gguf" --local-dir ./
```
If the model file is big, it has been split into multiple files. In order to download them all to a local folder, run:
```
huggingface-cli download legraphista/Phi-3.1-mini-4k-instruct --include "Phi-3-mini-4k-instruct.Q8_0/*" --local-dir ./
# see FAQ for merging GGUF's
```

---

## Inference

### Simple chat template
```
<|user|>
{user_prompt}<|end|>
<|assistant|>
{assistant_response}<|end|>
<|user|>
{next_user_prompt}<|end|>
<|endoftext|>
```

### Chat template with system prompt
```
<|system|>
{system_prompt}<|end|>
<|user|>
{user_prompt}<|end|>
<|assistant|>
{assistant_response}<|end|>
<|user|>
{next_user_prompt}<|end|>
<|endoftext|>
```

### Llama.cpp
```
llama.cpp/main -m Phi-3-mini-4k-instruct.Q8_0.gguf --color -i -p "prompt here (according to the chat template)"
```

---

## FAQ

### Why is the IMatrix not applied everywhere?
According to [this investigation](https://www.reddit.com/r/LocalLLaMA/comments/1993iro/ggufs_quants_can_punch_above_their_weights_now/), it appears that lower quantizations are the only ones that benefit from the imatrix input (as per hellaswag results). 

### How do I merge a split GGUF?
1. Make sure you have `gguf-split` available
    - To get hold of `gguf-split`, navigate to https://github.com/ggerganov/llama.cpp/releases
    - Download the appropriate zip for your system from the latest release
    - Unzip the archive and you should be able to find `gguf-split`
2. Locate your GGUF chunks folder (ex: `Phi-3-mini-4k-instruct.Q8_0`)
3. Run `gguf-split --merge Phi-3-mini-4k-instruct.Q8_0/Phi-3-mini-4k-instruct.Q8_0-00001-of-XXXXX.gguf Phi-3-mini-4k-instruct.Q8_0.gguf`
    - Make sure to point `gguf-split` to the first chunk of the split.

---

Got a suggestion? Ping me [@legraphista](https://x.com/legraphista)!