Zum Inhalt springen
Skillpedia
Machine Learning14k · #11208

gguf-quantization

Was er macht

Dieser Skill erklärt das GGUF-Dateiformat und wie man Modelle für llama.cpp quantisiert. Er ist für Leute gedacht, die lokale KI auf alltäglicher Hardware wie einem Laptop oder Mac nutzen wollen.

Wann du ihn nutzt

  • ✓Wenn du ein Sprachmodell auf einem Laptop ohne eigene GPU laufen lassen willst.
  • ✓Wenn du einen Mac mit Apple-Silicon-Chip nutzt und Metal-Beschleunigung willst.
  • ✓Wenn du eine lokale KI-App wie LM Studio oder Ollama nutzt und die passende Dateigröße wählen willst.

Link zum Skill

https://github.com/Orchestra-Research/AI-Research-SKILLs/blob/main/10-optimization/gguf/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/Orchestra-Research/AI-Research-SKILLs/blob/main/10-optimization/gguf/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Wandle mein feinabgestimmtes Modell in eine GGUF-Datei um, die klein genug für mein MacBook ist.”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Du baust llama.cpp, wandelst ein Modell in das GGUF-Format um und wählst dann eine Quantisierungsstufe von 2 bis 8 Bit. Kleinere Stufen brauchen weniger Speicher, können aber etwas Qualität verlieren.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

GGUF - Quantization Format for llama.cpp

The GGUF (GPT-Generated Unified Format) is the standard file format for llama.cpp, enabling efficient inference on CPUs, Apple Silicon, and GPUs with flexible quantization options.

When to use GGUF

Use GGUF when:

  • Deploying on consumer hardware (laptops, desktops)
  • Running on Apple Silicon (M1/M2/M3) with Metal acceleration
  • Need CPU inference without GPU requirements
  • Want flexible quantization (Q2_K to Q8_0)
  • Using local AI tools (LM Studio, Ollama, text-generation-webui)

Key advantages:

  • Universal hardware: CPU, Apple Silicon, NVIDIA, AMD support
  • No Python runtime: Pure C/C++ inference
  • Flexible quantization: 2-8 bit with various methods (K-quants)
  • Ecosystem support: LM Studio, Ollama, koboldcpp, and more
  • imatrix: Importance matrix for better low-bit quality

Use alternatives instead:

  • AWQ/GPTQ: Maximum accuracy with calibration on NVIDIA GPUs
  • HQQ: Fast calibration-free quantization for HuggingFace
  • bitsandbytes: Simple integration with transformers library
  • TensorRT-LLM: Production NVIDIA deployment with maximum speed

Quick start

Installation

# Clone llama.cpp
git clone https://github.com/ggml-org/llama.cpp
cd llama.cpp

# Build (CPU)
make

# Build with CUDA (NVIDIA)
make GGML_CUDA=1

# Build with Metal (Apple Silicon)
make GGML_METAL=1

# Install Python bindings (optional)
pip install llama-cpp-python

Convert model to GGUF

# Install requirements
pip install -r requirements.txt

# Convert HuggingFace model to GGUF (FP16)
python convert_hf_to_gguf.py ./path/to/model --outfile model-f16.gguf

# Or specify output type
python convert_hf_to_gguf.py ./path/to/model \
    --outfile model-f16.gguf \
    --outtype f16

Quantize model

# Basic quantization to Q4_K_M
./llama-quantize model-f16.gguf model-q4_k_m.gguf Q4_K_M

# Quantize with importance matrix (better quality)
./llama-imatrix -m model-f16.gguf -f calibration.txt -o model.imatrix
./llama-quantize --imatrix model.imatrix model-f16.gguf model-q4_k_m.gguf Q4_K_M

Run inference

# CLI inference
./llama-cli -m model-q4_k_m.gguf -p "Hello, how are you?"

# Interactive mode
./llama-cli -m model-q4_k_m.gguf --interactive

# With GPU offload
./llama-cli -m model-q4_k_m.gguf -ngl 35 -p "Hello!"

Quantization types

K-quant methods (recommended)

Type Bits Size (7B) Quality Use Case
Q2_K 2.5 ~2.8 GB Low Extreme compression
Q3_K_S 3.0 ~3.0 GB Low-Med Memory constrained
Q3_K_M 3.3 ~3.3 GB Medium Balance
Q4_K_S 4.0 ~3.8 GB Med-High Good balance
Q4_K_M 4.5 ~4.1 GB High Recommended default
Q5_K_S 5.0 ~4.6 GB High Quality focused
Q5_K_M 5.5 ~4.8 GB Very High High quality
Q6_K 6.0 ~5.5 GB Excellent Near-original
Q8_0 8.0 ~7.2 GB Best Maximum quality

Legacy methods

Type Description
Q4_0 4-bit, basic
Q4_1 4-bit with delta
Q5_0 5-bit, basic
Q5_1 5-bit with delta

Recommendation: Use K-quant methods (Q4_K_M, Q5_K_M) for best quality/size ratio.

Conversion workflows

Workflow 1: HuggingFace to GGUF

# 1. Download model
huggingface-cli download meta-llama/Llama-3.1-8B --local-dir ./llama-3.1-8b

# 2. Convert to GGUF (FP16)
python convert_hf_to_gguf.py ./llama-3.1-8b \
    --outfile llama-3.1-8b-f16.gguf \
    --outtype f16

# 3. Quantize
./llama-quantize llama-3.1-8b-f16.gguf llama-3.1-8b-q4_k_m.gguf Q4_K_M

# 4. Test
./llama-cli -m llama-3.1-8b-q4_k_m.gguf -p "Hello!" -n 50

Workflow 2: With importance matrix (better quality)

# 1. Convert to GGUF
python convert_hf_to_gguf.py ./model --outfile model-f16.gguf

# 2. Create calibration text (diverse samples)
cat > calibration.txt << 'EOF'
The quick brown fox jumps over the lazy dog.
Machine learning is a subset of artificial intelligence.
Python is a popular programming language.
# Add more diverse text samples...
EOF

# 3. Generate importance matrix
./llama-imatrix -m model-f16.gguf \
    -f calibration.txt \
    --chunk 512 \
    -o model.imatrix \
    -ngl 35  # GPU layers if available

# 4. Quantize with imatrix
./llama-quantize --imatrix model.imatrix \
    model-f16.gguf \
    model-q4_k_m.gguf \
    Q4_K_M

Workflow 3: Multiple quantizations

#!/bin/bash
MODEL
Häufige Fragen

Welche Quantisierungsstufen gibt es?

Der Skill nennt Stufen von Q2_K bis Q8_0, einschließlich der K-Quants.

Was ist imatrix?

Der Skill beschreibt es als Importance-Matrix, die bei niedrigen Bitstufen hilft, die Qualität zu erhalten.

Welche Werkzeuge können GGUF-Dateien lesen?

Der Skill nennt LM Studio, Ollama, koboldcpp und text-generation-webui.

Details

Originalbeschreibung des Autors

GGUF format and llama.cpp quantization for efficient CPU/GPU inference. Use when deploying models on consumer hardware, Apple Silicon, or when needing flexible quantization from 2-8 bit without GPU requirements.

repo: Orchestra-Research/AI-Research-SKILLs

Beliebtheit

GitHub-Sterne
14k
Platz im Ranking
#11208
Lizenz
MIT
Aktualisiert
10.10.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills