Running local large language models can feel overwhelming when you first encounter the maze of file formats and quantization options. You’ll see cryptic extensions like .gguf, .safetensors, and .bin, alongside mysterious quantization codes like Q4_K_M, IQ3_M, or FP16. This guide cuts through the confusion with practical explanations and clear recommendations.
Contents
- 1 π§ Understanding Model Formats (The Foundation)
- 2 π’ GGUF Quantization Deep Dive
- 3 π Hardware-Optimized Recommendations
- 4 π οΈ Practical Format Selection Guide
- 5 π§ Tools and Software Ecosystem
- 6 π Performance Comparison Matrix
- 7 π― Quick Decision Tree
- 8 π Advanced Topics
- 9 π¨ Common Pitfalls and Solutions
- 10 π Further Resources
- 11 π― TL;DR – The Essentials
π§ Understanding Model Formats (The Foundation)
Model formats determine how neural network weights are stored, loaded, and processed. Each format has specific use cases, performance characteristics, and compatibility requirements.
Core Format Categories
| Format | Precision | Primary Use | Storage Efficiency | Loading Speed |
|---|---|---|---|---|
| FP32 | 32-bit float | Training, research | β Very Large | β οΈ Slow |
| FP16 | 16-bit float | GPU inference | β οΈ Large | β Fast |
| BF16 | 16-bit bfloat | Modern GPU inference | β οΈ Large | β Fast |
| INT8 | 8-bit integer | Quantized inference | β Medium | β Fast |
| INT4 | 4-bit integer | Aggressive quantization | β Small | β Very Fast |
Popular Format Implementations
GGUF (GPT-Generated Unified Format)
- What: Current standard for quantized models, replacing GGML
- Best for: CPU inference, mixed CPU/GPU setups, memory-constrained environments
- Supports: Multiple quantization levels, embedded tokenizers, model metadata
- Compatible with: llama.cpp, koboldcpp, text-generation-webui, LM Studio, GPT4All
Safetensors
- What: Secure, fast-loading tensor format for PyTorch ecosystems
- Best for: GPU inference with Transformers library, production deployments
- Advantages: Memory-mapped loading, corruption resistance, metadata support
- Compatible with: HuggingFace Transformers, vLLM, TGI (Text Generation Inference)
PyTorch (.bin/.pth)
- What: Native PyTorch serialization format
- Best for: Research, fine-tuning, when safetensors isn’t available
- Drawbacks: Security concerns, slower loading, larger memory footprint
- Compatible with: Any PyTorch-based inference engine
Ollama Models
- What: Self-contained model packages with runtime and dependencies
- Best for: Plug-and-play local inference, non-technical users
- Includes: Model weights, tokenizer, chat templates, system prompts
- Management:
ollama pull modelname, automatic updates and caching
π’ GGUF Quantization Deep Dive
Quantization reduces model size and increases inference speed by using fewer bits per parameter. GGUF supports multiple quantization schemes optimized for different hardware and quality requirements.
Quantization Quality Hierarchy
| Quant Type | Bits/Weight | Size Reduction | Quality Loss | Best Hardware |
|---|---|---|---|---|
| F32 | 32 | None (baseline) | None | High-end GPUs |
| F16 | 16 | 50% | Negligible | Modern GPUs |
| Q8_0 | 8 | 75% | Minimal | Any GPU/CPU |
| Q6_K | 6.56 | 80% | Very Low | GPU preferred |
| Q5_K_M | 5.67 | 82% | Low | GPU/CPU |
| Q5_1 | 5.5 | 83% | Low | CPU optimized |
| Q4_K_M | 4.58 | 85% | Moderate | Balanced choice |
| Q4_1 | 4.5 | 86% | Moderate | CPU optimized |
| Q4_0 | 4.5 | 86% | Moderate | Legacy |
| IQ4_XS | 4.25 | 87% | Moderate | Latest CPUs |
| Q3_K_M | 3.91 | 88% | Noticeable | Memory-limited |
| IQ3_M | 3.66 | 89% | Noticeable | Experimental |
| Q2_K | 2.96 | 91% | Significant | Emergency only |
Advanced Quantization Types
K-Series (K_S, K_M, K_L)
- Mixed precision within layers
K_S(Small): Aggressive quantizationK_M(Medium): Balanced approachK_L(Large): Conservative quantization
IQ-Series (Importance-Based Quantization)
- Newer experimental formats
- Better quality at same bit rates
- Requires recent llama.cpp builds
- Examples:
IQ4_XS,IQ3_M,IQ2_S
π Hardware-Optimized Recommendations
CPU-Only Systems
RAM < 16GB: Q4_0 or Q4_K_M for 7B models
RAM 16-32GB: Q5_K_M for 7B-13B models, Q4_K_M for 30B+ models
RAM 32GB+: Q6_K or Q8_0 for maximum quality
Recommended Tools: llama.cpp, koboldcpp, LM Studio
GPU Systems (NVIDIA)
4-8GB VRAM: Q4_K_M with partial GPU offloading
8-12GB VRAM: Q5_K_M or Q6_K fully on GPU
16GB+ VRAM: Q8_0, F16, or safetensors FP16
24GB+ VRAM: Full precision models, multiple models
Recommended Tools: text-generation-webui, vLLM, HuggingFace TGI
Apple Silicon (M1/M2/M3)
8GB Unified: Q4_K_M for 7B models
16GB Unified: Q5_K_M for 13B models, Q4_K_M for 30B+ models
32GB+ Unified: Q6_K or Q8_0 for large models
Recommended Tools: llama.cpp (Metal acceleration), Ollama, MLX
Mobile/Edge Devices
Android/iOS: Q4_0 or IQ4_XS for maximum efficiency
Raspberry Pi: Q2_K or Q3_K_M for small models only
Edge TPUs: INT8 quantized models in TensorFlow Lite format
π οΈ Practical Format Selection Guide
For Chat/Assistant Use
- Premium experience: Safetensors FP16 on GPU (16GB+ VRAM)
- Balanced quality: GGUF
Q5_K_MorQ6_K - Resource-constrained: GGUF
Q4_K_M - Mobile/lightweight: GGUF
Q4_0orIQ4_XS
For Creative Writing/Roleplay
- Maximum creativity: Full precision (F32/F16) on powerful GPU
- High quality: GGUF
Q6_KorQ8_0 - Good balance: GGUF
Q5_K_M - Minimum viable: GGUF
Q4_K_M(avoid lower)
For Code Generation
- Professional use: Safetensors FP16 or GGUF
Q8_0 - Development: GGUF
Q6_Kminimum - Learning/hobby: GGUF
Q5_K_M - Quick testing: GGUF
Q4_K_M
For Research/Analysis
- Reproducible results: Full precision safetensors
- Evaluation/benchmarking: GGUF
Q8_0minimum - Experimentation: GGUF
Q6_K - Rapid prototyping: GGUF
Q4_K_M
π§ Tools and Software Ecosystem
GGUF-Native Applications
- llama.cpp: Core engine, command-line interface
- koboldcpp: Web UI with gaming/RP focus
- LM Studio: User-friendly desktop application
- GPT4All: Simple desktop client with model management
- Ollama: Docker-like model management system
Transformers/PyTorch Ecosystem
- text-generation-webui: Feature-rich web interface
- vLLM: High-performance inference server
- HuggingFace TGI: Production-ready inference
- AutoGPTQ/ExLlama: GPU-optimized quantization
Model Conversion Tools
- llama.cpp/convert.py: HuggingFace to GGUF conversion
- AutoGPTQ: PyTorch to GPTQ quantization
- transformers: Format conversion utilities
- optimum: Intel/ONNX optimization tools
π Performance Comparison Matrix
7B Parameter Model on RTX 4090 (24GB)
| Format | VRAM Usage | Tokens/Second | Quality Score | Use Case |
|---|---|---|---|---|
| Safetensors FP16 | ~14GB | 85 | 10/10 | Maximum quality |
| GGUF Q8_0 | ~8GB | 78 | 9.8/10 | Near-perfect balance |
| GGUF Q6_K | ~6GB | 82 | 9.5/10 | Excellent efficiency |
| GGUF Q5_K_M | ~5GB | 85 | 9.0/10 | Sweet spot |
| GGUF Q4_K_M | ~4GB | 88 | 8.5/10 | Good compromise |
| GGUF Q4_0 | ~4GB | 90 | 8.0/10 | Speed priority |
13B Parameter Model on RTX 3080 (10GB)
| Format | VRAM Usage | Feasible | Recommendation |
|---|---|---|---|
| Safetensors FP16 | ~26GB | β | Won’t fit |
| GGUF Q8_0 | ~14GB | β | Won’t fit |
| GGUF Q6_K | ~11GB | β | Won’t fit |
| GGUF Q5_K_M | ~9GB | β | Recommended |
| GGUF Q4_K_M | ~7.5GB | β | Good alternative |
π― Quick Decision Tree
Start here: What’s your primary use case?
I want the simplest setup
β Use Ollama: ollama pull llama2 or ollama pull codellama
I want maximum quality and have a powerful GPU
β Use Safetensors FP16 with text-generation-webui or vLLM
I want good quality with reasonable resource usage
β Use GGUF Q5_K_M with llama.cpp or koboldcpp
I’m resource-constrained but need decent performance
β Use GGUF Q4_K_M with any GGUF-compatible tool
I’m experimenting or learning
β Start with Ollama, then explore GGUF formats
π Advanced Topics
Model Sharding and Distribution
Large models may be split across multiple files:
- PyTorch:
pytorch_model-00001-of-00003.bin - Safetensors:
model-00001-of-00003.safetensors - GGUF: Usually single file, but can be split for very large models
Custom Quantization
Creating your own quantized models:
# Convert HuggingFace model to GGUF
python convert.py /path/to/model --outtype f16
# Quantize GGUF model
./quantize model-f16.gguf model-q4_k_m.gguf Q4_K_M
Memory Mapping and Optimization
- mmap: Load models without copying to RAM
- mlock: Prevent swapping to disk
- numa: Optimize for multi-socket systems
- tensor parallelism: Split large models across GPUs
π¨ Common Pitfalls and Solutions
“Model won’t load” Issues
- Check format compatibility: Not all tools support all formats
- Verify file integrity: Re-download corrupted files
- Update software: Newer quantization types need recent versions
- Check available memory: Model might be too large for your system
“Poor quality output” Problems
- Try higher quantization: Q2_K is usually too aggressive
- Check model source: Some models are poorly trained or converted
- Verify chat template: Wrong template can break conversation flow
- Test with different prompts: Some models are sensitive to prompting style
“Slow inference” Performance
- Enable GPU acceleration: Offload layers to GPU when possible
- Use appropriate batch size: Larger batches can improve throughput
- Consider model size: Smaller models might be faster despite lower quality
- Check system resources: CPU/RAM bottlenecks affect performance
π Further Resources
Official Documentation
- llama.cpp: GitHub repository
- HuggingFace Transformers: Documentation
- Ollama: Official website
Community Resources
- r/LocalLLaMA: Reddit community for local model enthusiasts
- HuggingFace Hub: Largest collection of open-source models
- TheBloke: Popular quantized model provider (legacy, now community-maintained)
Benchmarking and Evaluation
- Open LLM Leaderboard: Compare model performance
- lm-evaluation-harness: Standardized evaluation framework
- FastChat Arena: Crowdsourced model comparisons
π― TL;DR – The Essentials
For most users: Start with Ollama for simplicity, or GGUF Q4_K_M/Q5_K_M for more control.
For maximum quality: Use Safetensors FP16 on powerful GPUs or GGUF Q8_0 for CPU/mixed setups.
For resource-constrained systems: GGUF Q4_0 or IQ4_XS provide the best efficiency.
For production: vLLM with safetensors or text-generation-webui with GGUF offer robust serving capabilities.
When in doubt: Ask the community with your specific hardware specs and use case – the local LLM community is incredibly helpful and knowledgeable.
Still have questions? The local LLM community is active on Reddit (r/LocalLLaMA), Discord, and GitHub. Don’t hesitate to ask for hardware-specific recommendations or help troubleshooting setup issues.


0 Comments