🦙

llama.cpp
Explained

The open-source C/C++ engine that made running LLMs on your own hardware possible

Created March 2023 85,000+ GitHub Stars 1,200+ Contributors MIT Licensed

LLM inference without the cloud. On hardware you already own.

llama.cpp is an open-source software library, written in pure C/C++ with no external dependencies, that runs large language models on everyday consumer hardware. Laptops, desktops, phones, Raspberry Pis, old MacBooks — if it has a CPU, llama.cpp can probably run an LLM on it. No NVIDIA GPU required. No cloud API keys. No PyTorch.

Created by Bulgarian software engineer Georgi Gerganov in March 2023 — just ten days after Meta released LLaMA — it proved that a 7-billion-parameter model could do inference on a MacBook CPU. That single demonstration kicked off the entire local AI movement. Three years later, llama.cpp is the inference backbone behind Ollama, LM Studio, GPT4All, Jan.ai, KoboldCpp, and dozens more tools. If you've ever run an AI model locally, llama.cpp almost certainly made it possible.

The Problem

AI locked behind GPUs and cloud APIs

Running LLMs required expensive NVIDIA hardware, CUDA, and heavy Python frameworks like PyTorch. Most people and most businesses couldn't access AI inference without paying cloud providers per-token.

The Solution

Pure C/C++ inference with quantization

llama.cpp strips away framework dependencies and uses quantization (compressing model weights from 32-bit to 4-bit or lower) to shrink models by 75%+. The result: a 7B model runs in 4GB of RAM on a CPU.

The Result

AI on every device, no cloud needed

Full data privacy (nothing leaves your machine), zero API costs, offline capability, and the ability to run models on everything from ARM processors to old x86 laptops. Sovereign AI, practically.

📦
Model Weights
PyTorch / Safetensors
🔄
Convert to GGUF
convert_hf_to_gguf.py
📐
Quantize
Q4_K_M / Q5_K_M
🚀
Run Locally
llama-cli / llama-server

The infrastructure layer beneath local AI.

Every prediction about what local hardware couldn't run has been wrong within 6-12 months. In March 2023, a 7B model on CPU was surprising. By December 2023, quantized 70B models ran on MacBooks. By mid-2025, trillion-parameter mixture-of-experts models loaded on consumer GPUs. llama.cpp has been the constant through all of it — the plumbing that persists while models turn over every few months.

85K+
GitHub stars
1,200+
Contributors worldwide
14K+
Forks on GitHub
3 yrs
Central to local AI since March 2023

Why not just use a cloud API?

Cloud APIs are great when you need frontier reasoning, long multi-turn conversations, or can tolerate per-query costs. llama.cpp wins when privacy is non-negotiable (data never leaves the device), when you need offline access, when you're processing high volumes where per-token costs stack up, or when you want full control over model selection and behaviour. It's not either/or — most serious setups use both.

Five concepts that make local inference tick.

llama.cpp's power comes from a handful of well-executed ideas: a custom tensor library, a self-contained file format, aggressive quantization, multi-backend hardware support, and an OpenAI-compatible server. Here's what each does.

Concept 01

GGML — The Tensor Library

GGML is the low-level C library that handles tensor algebra underneath llama.cpp. Created by Gerganov in late 2022 (inspired by Fabrice Bellard's LibNC), it was designed with strict memory management and multi-threading from day one. GGML is why llama.cpp doesn't need PyTorch — it replaces the entire computation layer.

Concept 02

GGUF — The File Format

GGUF (GPT-Generated Unified Format) is a self-contained binary that packages everything needed to run a model: architecture metadata, tokenizer vocabulary, quantization parameters, and weight tensors. One file, no separate config.json, no external tokenizer. It supports 40+ model architectures (LLaMA, Mistral, Qwen, Gemma, Phi, and more) and uses memory-mapping for near-instant loading.

Concept 03

Quantization — Shrinking Models to Fit

Quantization compresses model weights from 32-bit or 16-bit floats down to 4-bit integers (or lower). A 7B model drops from ~14GB to ~4GB at Q4_K_M. The "K-quant" family (Q2_K through Q6_K) uses super-blocks with per-layer precision allocation — more bits for attention layers, fewer for redundant ones — preserving quality at aggressive compression. For most users, Q4_K_M is the sweet spot: 92% quality retention with 75% size reduction.

# Quantize a model to Q4_K_M (the community default)
./llama-quantize model-f16.gguf model-Q4_K_M.gguf Q4_K_M

# With importance matrix for better quality at low bits
./llama-imatrix -m model-f16.gguf -f calibration.txt -o imatrix.dat
./llama-quantize --imatrix imatrix.dat model-f16.gguf model-Q4_K_M.gguf Q4_K_M

Concept 04

Hardware Backends — Run Anywhere

llama.cpp targets an extraordinary range of hardware via backend modules: Apple Silicon (Metal + Accelerate), NVIDIA GPUs (CUDA), AMD GPUs (HIP/ROCm), Intel GPUs (SYCL + OpenVINO), Huawei Ascend (CANN), Vulkan (cross-platform GPU), and of course bare CPU with AVX/AVX2/AVX-512/AMX optimisations. As of December 2025, it also runs natively on Android and ChromeOS devices with full GPU acceleration.

Concept 05

llama-server — Production-Ready API

llama-server provides an OpenAI-compatible HTTP API out of the box — including chat completions, embeddings, and tool calling. This means any application built against the OpenAI API can switch to local inference by changing one URL. It includes a built-in web UI, supports streaming, speculative decoding (small draft model predicting tokens for a larger target), and structured output via grammar constraints.

# Start an OpenAI-compatible local server
llama-server -m model.gguf --port 8080

# Or download and serve directly from Hugging Face
llama-server -hf ggml-org/gemma-3-1b-it-GGUF

llama.cpp doesn't work alone. It powers an entire stack.

llama.cpp is infrastructure — a library, not an end-user app. An enormous ecosystem of tools builds on top of it, each targeting different audiences. The GGUF format has become the de facto standard for distributing quantized models, and Hugging Face hosts thousands of community-quantized GGUF models ready for download.

User-Friendly Wrapper

Ollama

One-command model pulling and serving (ollama run llama3). Exposes a local HTTP API. Built on llama.cpp. The "Docker for LLMs" — dead simple, but inherits llama.cpp's single-GPU limitations.

Desktop GUI

LM Studio

Polished desktop app for browsing, downloading, and chatting with GGUF models. Side-by-side comparison, one-click quantization, and a model discovery UI. The "app store" experience for local AI.

Privacy-First Chat

GPT4All

Desktop app by Nomic AI with built-in LocalDocs for private document chat (RAG). The 2026 Reasoner adds on-device reasoning with tool calling and sandboxed code execution. Best for non-technical users.

Single Executable

KoboldCpp

One-file, zero-install fork of llama.cpp. Triple API compatibility (KoboldAI + OpenAI + Ollama endpoints). Popular for creative writing and roleplay with built-in memory and world info features.

Privacy Assistant

Jan.ai

Open-source (AGPLv3) desktop app with hybrid local + cloud switching. Connect OpenAI, Anthropic, and local models in one interface. MCP integration for agentic workflows. Runs on the Cortex engine (wrapping llama.cpp).

Apple Silicon

MLX (Apple)

Apple's own ML framework with Metal-optimised kernels. Not built on llama.cpp, but a complementary option for Mac-only deployments. Delivers ~230 tokens/sec on M2 Ultra — fastest Apple-native throughput. GGUF files work across both ecosystems.

When to use what

NeedUse ThisWhy
Fastest setup, local API server Ollama One command to pull and run. Built-in HTTP API. No compilation needed.
Model discovery and side-by-side eval LM Studio Browse GGUF models, compare outputs, download with a click.
Maximum control, custom builds llama.cpp direct Full access to every flag, backend, and quantization option. Compile for your exact hardware.
Multi-GPU production throughput vLLM True tensor parallelism with PagedAttention. llama.cpp splits layers sequentially, vLLM processes in parallel.
Apple Silicon max performance MLX Apple's own optimised kernels. Higher throughput than llama.cpp on Mac hardware, but Mac-only.
OpenAI API drop-in replacement LocalAI Multi-backend (llama.cpp, vLLM, diffusers). Supports text, images, audio, video, embeddings — all locally.

What people actually build with it.

llama.cpp runs the full range from personal assistants on laptops to production APIs handling thousands of requests. The sweet spot is anywhere data privacy, cost control, or offline access matters more than frontier model quality.

Personal Productivity

Private AI Assistants

Always-on, offline AI assistants running on Mac Minis, old laptops, or Raspberry Pis. Morning briefings, task automation, code reviews — all with zero data leakage and zero API cost. OpenClaw on NVIDIA Jetson is a popular reference implementation.

Software Development

Local Code Completion

IDE plugins (VS Code, Vim, Neovim) using llama-server for fill-in-the-middle completions. Qwen2.5-Coder 14B at Q4_K_M runs comfortably on a 24GB Mac Mini — fast enough for real-time autocomplete, private enough for proprietary code.

Enterprise Compliance

On-Premises AI for Regulated Industries

Healthcare, finance, legal, and government use cases where data cannot leave the building. llama.cpp runs inside air-gapped networks with zero external dependencies. POPIA, GDPR, HIPAA compliance by architecture.

Edge & IoT

AI on Industrial Devices

Running small models (1-3B) on ARM devices, edge gateways, and embedded systems. Manufacturing quality inspection, real-time sensor analysis, and smart-device interactions — all without cloud connectivity.

Education & Research

Accessible LLM Experimentation

Students and researchers running billion-parameter models on commodity hardware. Benchmark quantization quality, test fine-tuned models, explore architecture differences — all on a laptop. The great equaliser.

Security & Surveillance

AI-Powered Camera Systems

Open-source AI camera platforms use llama.cpp with vision-language models (Qwen, LLaVA, SmolVLM) for local video analysis. Real-time scene understanding without sending footage to the cloud.

From a weekend hack to the backbone of local AI.

The original README said: "The main goal is to run the model using 4-bit quantization on a MacBook. This was hacked in an evening — I have no idea if it works correctly." Three years later, it powers the inference layer for millions of users worldwide.

SEP 2022

GGML Library Created

Georgi Gerganov begins work on the GGML tensor library in C, inspired by Fabrice Bellard's LibNC. Designed for strict memory management and multi-threading from the start.

MAR 2023

llama.cpp Released

Ten days after Meta releases LLaMA, Gerganov publishes llama.cpp — proving a 7B model can run on a MacBook CPU. GitHub stars grow faster than Stable Diffusion did. The local AI movement begins.

AUG 2023

GGUF Format Introduced

GGUF replaces the older GGML format with a flexible key-value metadata system. One self-contained file with architecture, tokenizer, and weights. Backwards-compatible by design. Becomes the standard for distributing quantized models.

APR 2024

FlashAttention Added

FlashAttention support lands, dramatically improving long-context performance and memory efficiency. Enables practical use of models with 128K+ context windows on consumer hardware.

APR 2025

Multimodal Support via libmtmd

The libmtmd library reinvigorates multimodal model support, enabling vision-language models (LLaVA, Qwen-VL) to run through the same llama.cpp pipeline. Images in, text out, fully local.

DEC 2025

Native Android & ChromeOS Acceleration

Full GPU acceleration on Android and ChromeOS via a new GUI binding, moving beyond the previous adb shell workaround. Local LLMs now run natively on phones and tablets.

FEB 2026

ggml.ai Joins Hugging Face

Gerganov and team formally join Hugging Face. The projects stay fully open-source and MIT-licensed. Roadmap targets single-click integration with the transformers library and first-party GGUF quantizations on Hugging Face Hub. The goal: near-zero friction from "model announced" to "running locally."

Is llama.cpp right for your project?

llama.cpp is the right choice more often than people think — but it's not always the right choice. Here's an honest breakdown.

✓ Use llama.cpp when

Data cannot leave your network. Regulatory requirements (POPIA, GDPR, HIPAA), client confidentiality, or competitive IP concerns make cloud APIs a non-starter.

You need offline or air-gapped AI. Deployments without reliable internet — industrial sites, remote offices, mobile field teams, military contexts.

Volume economics make cloud expensive. When you're running thousands of inferences daily, the per-token cost of cloud APIs adds up. Local inference is free after hardware investment.

Your task fits small-to-mid models. Summarisation, classification, code completion, RAG over documents, embeddings, translation — 7-14B models handle these well locally.

✗ Skip llama.cpp when

You need frontier reasoning. For complex multi-step logic, nuanced creative writing, or tasks where GPT-4o/Claude Opus quality is the floor, local models aren't there yet.

Multi-GPU throughput is critical. llama.cpp splits layers sequentially across GPUs (for fitting, not speed). If you need tensor-parallel production serving, use vLLM or TensorRT-LLM.

Your team has zero appetite for CLI. While Ollama and LM Studio make it easier, the llama.cpp ecosystem still leans developer-first. Non-technical teams may struggle without support.

You're building for real-time voice/video. Current local models and inference speeds struggle with the latency requirements of real-time conversational AI. Cloud APIs still win here.

Where llama.cpp fits best.

Summary

llama.cpp is arguably the single most important open-source AI project of the past three years. It didn't just make local AI possible — it made it practical. For businesses dealing with bandwidth constraints, data sovereignty requirements, and the cost of cloud APIs, local inference is a genuine competitive advantage. It's a strong starting point for any team exploring self-hosted AI.

Enterprise Use Cases

On-Prem AI for Regulated Industries

llama.cpp-based inference can run entirely inside your own infrastructure — compliant by architecture. A typical setup: Ollama or llama-server behind an internal API gateway, serving classification, summarisation, and document-processing workflows. No data crosses the network boundary.

Hybrid Architectures

Local + Cloud Workflows

llama.cpp handles the cost-sensitive and privacy-sensitive parts of agentic pipelines well — embeddings, classification, first-pass summarisation — while complex reasoning routes to cloud models. The hybrid approach gives teams the best of both worlds.

Learning

Hands-On Local AI

Installing Ollama, pulling GGUF models, and running inference on your own laptop is one of the fastest ways to build intuition for how LLMs actually work. Zero cloud dependency, zero cost, immediate feedback.

Go deeper. Start building.

Official

llama.cpp Resources

GitHub Repository — Source code, build instructions, and all CLI tools ↗
Hugging Face Partnership — Feb 2026 announcement and roadmap ↗
Quantization Guide — Full documentation for all quant types ↗
GGUF-my-repo — Convert any HF model to GGUF in your browser ↗
Ollama — Easiest way to start running llama.cpp-powered models ↗

Imbila.AI

More Explainers

This page is part of the Know knowledge base — independent AI explainers published by Imbila.AI.

Browse all explainers imbila.ai ↗

Sources & References

llama.cpp GitHub · Wikipedia: llama.cpp · HF: GGML Joins HF · ggml.ai + HF Discussion · Simon Willison · Changelog Interview with Gerganov · GGUF Quantization Study (2026) · History of Local LLMs · Local LLM Inference Guide 2026

Content validated March 2026. llama.cpp is maintained by ggml-org under the MIT license, now part of Hugging Face. This is an independent educational explainer by Imbila.AI.