CoolFace
Modelpublic

ogiwrghs/Phi-3-medium-128k-instruct-GGUF

sourceHugging Facemitupdated 9mo agoView on Hugging Face
0likes32downloads
Model Card

Phi-3 Medium 128k Instruct (GGUF)

GGUF License Quantized by

This repository provides GGUF quantized models for Microsoft Phi-3 Medium 128k Instruct.

Quantization was performed using llama.cpp with Importance Matrix (IQ) techniques to optimize VRAM usage, inference speed, and model quality.


๐Ÿ“Š Benchmarks (NVIDIA T4)

Benchmarks were collected on Google Colab (Tesla T4) using llama-bench and llama-perplexity.

QuantSizeSpeedPerplexity (WT2)Notes
IQ4_XS7.02 GB24.40 t/s4.64โœ… Best overall
Q5KM9.38 GB13.04 t/s4.60High VRAM
IQ3_M6.03 GB14.77 t/s6.36Low VRAM
Q2_K4.79 GB17.73 t/s76.01โŒ Unusable

Notes

  • โ€”IQ4_XS delivers ~87% higher throughput than Q5KM with negligible quality loss.
  • โ€”2-bit quantization causes severe degradation on Phi-3 Medium.

๐Ÿ“ฆ Available Files

FileQuantSizeEst. RAMUse Case
Phi-3-medium-128k-instruct-Q5_K_M.ggufQ5KM10.0 GB~12 GBMax quality
Phi-3-medium-128k-instruct-IQ4_XS.ggufIQ4_XS8.0 GB~10 GBRecommended
Phi-3-medium-128k-instruct-IQ3_M.ggufIQ3_M6.5 GB~8 GBLow VRAM
Phi-3-medium-128k-instruct-Q2_K.ggufQ2_K4.8 GB~6 GBTesting only
RAM estimates include KV-cache overhead.

๐Ÿ’ก Quantization Info

Importance Matrix (IQ) quantization uses calibration data to preserve the most important weights, significantly reducing quality loss compared to standard K-quant methods at similar sizes.

Recommended: IQ4_XS Fits in ~8GB VRAM and sustains 20+ tokens/sec on consumer GPUs (RTX 3060 / 3070 / 4060).


๐Ÿš€ Usage

โš ๏ธ Choose ONE of the following options. Do NOT run both.

Option 1: CLI (llama.cpp)

Use this if you want an interactive terminal session.

bash
./llama-cli \
  -m Phi-3-medium-128k-instruct-IQ4_XS.gguf \
  -n -1 \
  --color \
  -cnv

Option 2: Python (llama-cpp-python)

python
from llama_cpp import Llama

# Set gpu_layers to -1 to offload all layers to GPU
llm = Llama(
    model_path="./Phi-3-medium-128k-instruct-IQ4_XS.gguf",
    n_ctx=4096, 
    n_gpu_layers=-1,
    verbose=True
)

output = llm.create_chat_completion(
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain quantum physics."},
    ]
)

print(output['choices'][0]['message']['content'])