home
diamond Go Premium
Data Engineering Path  ·  Data & AI

Quantization, GGUF, and Ollama

+-------------------------------------------------------------------------------+
|                            HOW QUANTIZATION WORKS                             |
+-------------------------------------------------------------------------------+
|  FP32 (32-bit float)  -> 4 bytes per weight   -> Huge memory, extreme precision|
|  FP16 (16-bit float)  -> 2 bytes per weight   -> Standard training precision  |
|  INT8 (8-bit integer) -> 1 byte per weight    -> 50% memory reduction, ~0 loss|
|  INT4 (4-bit integer) -> 0.5 bytes per weight -> 75% memory drop, runnable on  |
|                                                  MacBook / Edge hardware     |
+-------------------------------------------------------------------------------+

What Is Quantization?

Quantization maps continuous high-precision floating point numbers into discrete lower-precision representations. By quantizing weights from 16-bit to 4-bit (using algorithms like AWQ, GPTQ, or GGUF k-quants), an 8-billion parameter model drops from 16 GB down to ~4.8 GB with virtually no loss in conversational ability.


What is GGUF?

GGUF (GPT-Generated Unified Format) is the binary format developed by Georgi Gerganov for llama.cpp. A .gguf file stores:

  • All model tensor weights in a single unified file.
  • The tokenizer vocabulary.
  • Quantization parameters and metadata.
  • Allows instant memory-mapping (mmap) into system RAM without slow initialization.

Running Ollama Locally for Zero-Cost AI

Ollama wraps llama.cpp in an intuitive CLI and REST API daemon that auto-selects CPU, GPU, or Apple Silicon acceleration:

1. Installation & Running a Model

# Install Ollama (Mac/Linux/Windows)
curl -fsSL https://ollama.com/install.sh | sh

# Pull and run Llama 3.1 8B in 4-bit quantization
ollama run llama3.1

2. Calling Ollama with Python

import requests

def call_ollama(prompt: str, model: str = "llama3.1") -> str:
    url = "http://localhost:11434/api/generate"
    payload = {
        "model": model,
        "prompt": prompt,
        "stream": False,
        "options": {
            "temperature": 0.1
        }
    }
    response = requests.post(url, json=payload)
    return response.json()["response"]

print(call_ollama("Write an Airflow BashOperator that unzips a file."))
Find this content helpful? ☕ Buy me a coffee

Entity Details

Create New Item

help

Submit Technical Query

Have a question or run into an issue? Describe it below, upload an optional screenshot, and our engineering team will answer it!

image Attach image (optional)

Submit Feedback

build Free Developer Utility Free Tool
gavel

Privacy & Legal Disclaimer

1. Client-Side Browser Processing

All utility tools on DeepEngineerHub (including Image to PDF, Text Formatters, JSON Converters, and Encryptors) execute 100% locally within your client browser using WebAssembly and JavaScript. No uploaded images, text, or documents are transmitted, collected, or stored on remote servers.

2. Limitation of Liability ("As-Is" Provision)

Tools and services are provided free of charge for convenience and educational purposes "as-is" without warranties of any kind. DeepEngineerHub shall not be held liable for any data loss, formatting inconsistencies, or indirect damages resulting from tool usage.

3. Open Source & Third-Party Software

Certain utilities utilize open-source client libraries (such as jsPDF, Mermaid.js, Pyodide) licensed under MIT, Apache, or BSD open licenses. All intellectual property remains with their respective copyright holders.