πŸ“‹ Model Description


thumbnail: "https://assets-global.website-files.com/646b351987a8d8ce158d1940/64ec9e96b4334c0e1ac41504_Logo%20with%20white%20text.svg" metrics:
  • memorydisk
  • memoryinference
  • inferencelatency
  • inferencethroughput
  • inferenceCO2emissions
  • inferenceenergyconsumption
tags:
  • pruna-ai

Twitter</a>
GitHub</a>
LinkedIn</a>
Discord</a>

This repo contains GGUF versions of the microsoft/Phi-3-mini-128k-instruct model.

Simply make AI models cheaper, smaller, faster, and greener!

Frequently Asked Questions

  • How does the compression work? The model is compressed with GGUF.
  • How does the model quality change? The quality of the model output might vary compared to the base model.
  • What is the model format? We use GGUF format.
  • What calibration data has been used? If needed by the compression method, we used WikiText as the calibration data.
  • How to compress my own models? You can request premium access to more compression methods and tech support for your specific use-cases here.

Downloading and running the models

You can download the individual files from the Files & versions section. Here is a list of the different versions we provide. For more info checkout this chart and this guide:

Quant typeDescription
Q5KMHigh quality, recommended.
Q5KSHigh quality, recommended.
Q4KMGood quality, uses about 4.83 bits per weight, recommended.
Q4KSSlightly lower quality with more space savings, recommended.
IQ4NLDecent quality, slightly smaller than Q4K_S with similar performance, recommended.
IQ4XSDecent quality, smaller than Q4K_S with similar performance, recommended.
Q3KLLower quality but usable, good for low RAM availability.
Q3KMEven lower quality.
IQ3MMedium-low quality, new method with decent performance comparable to Q3K_M.
IQ3SLower quality, new method with decent performance, recommended over Q3K_S quant, same size with better performance.
Q3KSLow quality, not recommended.
IQ3XSLower quality, new method with decent performance, slightly better than Q3K_S.
Q2_KVery low quality but surprisingly usable.

How to download GGUF files ?

Note for manual downloaders: You almost never want to clone the entire repo! Multiple different quantisation formats are provided, and most users only want to pick and download a single file.

The following clients/libraries will automatically download models for you, providing a list of available models to choose from:

  • LM Studio
  • LoLLMS Web UI
  • Faraday.dev
  • Option A - Downloading in text-generation-webui:
  • Step 1: Under Download Model, you can enter the model repo: PrunaAI/Phi-3-mini-128k-instruct-GGUF-Imatrix-smashed and below it, a specific filename to download, such as: phi-2.IQ3_M.gguf.
  • Step 2: Then click Download.
  • Option B - Downloading on the command line (including multiple files at once):
  • Step 1: We recommend using the huggingface-hub Python library:
pip3 install huggingface-hub
  • Step 2: Then you can download any individual model file to the current directory, at high speed, with a command like this:
huggingface-cli download PrunaAI/Phi-3-mini-128k-instruct-GGUF-Imatrix-smashed Phi-3-mini-128k-instruct.IQ3_M.gguf --local-dir . --local-dir-use-symlinks False
More advanced huggingface-cli download usage (click to read) Alternatively, you can also download multiple files at once with a pattern:
huggingface-cli download PrunaAI/Phi-3-mini-128k-instruct-GGUF-Imatrix-smashed --local-dir . --local-dir-use-symlinks False --include='Q4_Kgguf'

For more documentation on downloading with huggingface-cli, please see: HF -> Hub Python Library -> Download files -> Download from the CLI.

To accelerate downloads on fast connections (1Gbit/s or higher), install hf_transfer:

pip3 install hf_transfer

And set environment variable HFHUBENABLEHFTRANSFER to 1:

HFHUBENABLEHFTRANSFER=1 huggingface-cli download PrunaAI/Phi-3-mini-128k-instruct-GGUF-Imatrix-smashed Phi-3-mini-128k-instruct.IQ3_M.gguf --local-dir . --local-dir-use-symlinks False

Windows Command Line users: You can set the environment variable by running set HFHUBENABLEHFTRANSFER=1 before the download command.


How to run model in GGUF format?

  • Option A - Introductory example with llama.cpp command

Make sure you are using llama.cpp from commit d0cee0d or later.

./main -ngl 35 -m Phi-3-mini-128k-instruct.IQ3M.gguf --color -c 32768 --temp 0.7 --repeatpenalty 1.1 -n -1 -p "<s>[INST] {prompt\} [/INST]"

Change -ngl 32 to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.

Change -c 32768 to the desired sequence length. For extended sequence models - eg 8K, 16K, 32K - the necessary RoPE scaling parameters are read from the GGUF file and set by llama.cpp automatically. Note that longer sequence lengths require much more resources, so you may need to reduce this value.

If you want to have a chat-style conversation, replace the -p argument with -i -ins

For other parameters and how to use them, please refer to the llama.cpp documentation

  • Option B - Running in text-generation-webui

Further instructions can be found in the text-generation-webui documentation, here: text-generation-webui/docs/04 ‐ Model Tab.md.

  • Option C - Running from Python code

You can use GGUF models from Python using the llama-cpp-python or ctransformers libraries. Note that at the time of writing (Nov 27th 2023), ctransformers has not been updated for some time and is not compatible with some recent models. Therefore I recommend you use llama-cpp-python.

### How to load this model in Python code, using llama-cpp-python

For full documentation, please see: llama-cpp-python docs.

#### First install the package

Run one of the following commands, according to your system:

# Base ctransformers with no GPU acceleration
    pip install llama-cpp-python
    # With NVidia CUDA acceleration
    CMAKEARGS="-DLLAMACUBLAS=on" pip install llama-cpp-python
    # Or with OpenBLAS acceleration
    CMAKEARGS="-DLLAMABLAS=ON -DLLAMABLASVENDOR=OpenBLAS" pip install llama-cpp-python
    # Or with CLBLast acceleration
    CMAKEARGS="-DLLAMACLBLAST=on" pip install llama-cpp-python
    # Or with AMD ROCm GPU acceleration (Linux only)
    CMAKEARGS="-DLLAMAHIPBLAS=on" pip install llama-cpp-python
    # Or with Metal GPU acceleration for macOS systems only
    CMAKEARGS="-DLLAMAMETAL=on" pip install llama-cpp-python

# In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
$env:CMAKEARGS = "-DLLAMAOPENBLAS=on"
pip install llama-cpp-python

#### Simple llama-cpp-python example code

from llama_cpp import Llama

# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
llm = Llama(
modelpath="./Phi-3-mini-128k-instruct.IQ3M.gguf", # Download the model file first
n_ctx=32768, # The max sequence length to use - note that longer sequence lengths require much more resources
n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
ngpulayers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
)

# Simple inference example
output = llm(
"<s>[INST] {prompt} [/INST]", # Prompt
max_tokens=512, # Generate up to 512 tokens
stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
echo=True # Whether to echo the prompt
)

# Chat Completion API

llm = Llama(modelpath="./Phi-3-mini-128k-instruct.IQ3M.gguf", chatformat="llama-2") # Set chatformat according to the model you are using
llm.createchatcompletion(
messages = [
{"role": "system", "content": "You are a story writing assistant."},
{
"role": "user",
"content": "Write a story about llamas."
}
]
)

  • Option D - Running with LangChain

Here are guides on using llama-cpp-python and ctransformers with LangChain:

Configurations

The configuration info are in smash_config.json.

Credits & License

The license of the smashed model follows the license of the original model. Please check the license of the original model before using this model which provided the base model. The license of the pruna-engine is here on Pypi.

Want to compress other models?

  • Contact us and tell us which model to compress next here.
  • Request access to easily compress your own AI models here.

πŸ“‚ GGUF File List

πŸ“ Filename πŸ“¦ Size ⚑ Download
Phi-3-mini-128k-instruct.IQ1_M.gguf
LFS
874.62 MB Download
Phi-3-mini-128k-instruct.IQ1_S.gguf
LFS
802.62 MB Download
Phi-3-mini-128k-instruct.IQ2_M.gguf
LFS Q2
1.23 GB Download
Phi-3-mini-128k-instruct.IQ2_S.gguf
LFS Q2
1.13 GB Download
Phi-3-mini-128k-instruct.IQ2_XS.gguf
LFS Q2
1.07 GB Download
Phi-3-mini-128k-instruct.IQ2_XXS.gguf
LFS Q2
994.62 MB Download
Phi-3-mini-128k-instruct.IQ3_M.gguf
LFS Q3
1.73 GB Download
Phi-3-mini-128k-instruct.IQ3_S.gguf
LFS Q3
1.57 GB Download
Phi-3-mini-128k-instruct.IQ3_XS.gguf
LFS Q3
1.51 GB Download
Phi-3-mini-128k-instruct.IQ3_XXS.gguf
LFS Q3
1.41 GB Download
Phi-3-mini-128k-instruct.IQ4_NL.gguf
LFS Q4
2.03 GB Download
Phi-3-mini-128k-instruct.IQ4_XS.gguf
LFS Q4
1.92 GB Download
Phi-3-mini-128k-instruct.Q2_K.gguf
LFS Q2
1.32 GB Download
Phi-3-mini-128k-instruct.Q3_K_L.gguf
LFS Q3
1.94 GB Download
Phi-3-mini-128k-instruct.Q3_K_M.gguf
LFS Q3
1.82 GB Download
Phi-3-mini-128k-instruct.Q3_K_S.gguf
LFS Q3
1.57 GB Download
Phi-3-mini-128k-instruct.Q4_0.gguf
Recommended LFS Q4
2.03 GB Download
Phi-3-mini-128k-instruct.Q4_1.gguf
LFS Q4
2.24 GB Download
Phi-3-mini-128k-instruct.Q4_K_M.gguf
LFS Q4
2.23 GB Download
Phi-3-mini-128k-instruct.Q4_K_S.gguf
LFS Q4
2.04 GB Download
Phi-3-mini-128k-instruct.Q5_0.gguf
LFS Q5
2.47 GB Download
Phi-3-mini-128k-instruct.Q5_1.gguf
LFS Q5
2.68 GB Download
Phi-3-mini-128k-instruct.Q5_K_M.gguf
LFS Q5
2.62 GB Download
Phi-3-mini-128k-instruct.Q5_K_S.gguf
LFS Q5
2.46 GB Download
Phi-3-mini-128k-instruct.Q6_K.gguf
LFS Q6
2.92 GB Download
Phi-3-mini-128k-instruct.Q8_0.gguf
LFS Q8
3.78 GB Download