
ggml
A small C/C++ library for building the math core of machine learning programs.
- Stars
- 15.6k
- Forks
- 1.9k
- Licence
- MIT
- Language
- C++
- Last update
- 9 days ago
- Type
- Library
What it is
ggml is a tensor library: it provides the low-level building blocks for doing the number crunching behind machine learning models, written in plain C and C++ with no outside dependencies. It is designed to be simple, portable, and efficient, and it runs on many CPU types and some GPUs, NPUs, and browsers. It is mainly a foundation for other software rather than a finished end-user tool.
- Build the library from source with CMake and run the bundled minimal matrix multiplication example
- Study the commented examples/simple code to learn how tensor operations are expressed
- Use quantized 2- to 8-bit number formats to reduce memory needs of a model
- Compile the same code for x86, ARM, RISC-V, or WebAssembly targets
Great for
- C/C++ developers who want to embed machine learning math into their own program
- Engineers running models on modest or unusual hardware, such as ARM, RISC-V, or WebAssembly targets
- People who need low-level control over memory and quantized (smaller, lower-precision) number formats
- Developers exploring how tensor libraries work under the hood
Not ideal for
- Beginners who want to run a chatbot or model without writing code: the README describes a library, not an application
- Python-first data scientists: the README shows only C/C++ build steps and no Python interface
- Teams needing a stable high-level API: the README does not describe API guarantees, and core changes are routed through another project
How to get it
- 1
Clone and build from source
You'll need: CMake · A C/C++ compiler
Clone the repository
git clone https://github.com/ggml-org/ggmlEnter the directory and create a build folder
cd ggml && mkdir build && cd buildConfigure the build with CMake
cmake ..Build in Release mode
cmake --build . --config Release -j 8 - 2
Run it
- Build the project using the commands above
- Open the examples/simple directory
- Read the commented matrix multiplication example
- Run the compiled example binary from the build output
- 3
Get the most out of it
- Start with examples/simple, which the README describes as a minimal, fully commented example
- Read docs/gguf.md to understand the GGUF file format used by the wider ecosystem
- Read the linked introduction blog post and community tips page for background on ggml concepts
- Try the quantized formats if you are working under memory limits
Downloads
Strengths
- No external dependencies, in plain C/C++, which keeps setup and deployment simple
- Broad platform support across CPU architectures plus GPU, NPU, and browser backends
- Designed for efficiency, with SIMD-optimized kernels and no memory allocations at runtime
Trade-offs
- The README is short and gives little API documentation, so using it directly requires reading the source and examples
- Core library changes are directed to the llama.cpp project, so this repo is not the place for most contributions
- Latest release lists no prebuilt binaries, so you must build from source
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| ggml (this) | 15.6k | Library | advanced | 9 days ago | C/C++ developers who want to embed machine learning math into their own program |
| llama.cpp | 133k | Library | intermediate | 4 days ago | Developers who want to run open-weight models locally without a cloud API |
| onnxruntime | 22.2k | Library | intermediate | 4 days ago | Developers who want to deploy a trained model inside an application or service |
| spaCy | 34k | Library | intermediate | 10 days ago | Python developers building text-processing features into an application |
| recommenders | 22k | Library | intermediate | 4 days ago | Data scientists prototyping recommendation models |
| nni | 14.4k | Library | intermediate | 2.3 years ago | Researchers comparing hyperparameter tuning algorithms such as TPE, Hyperband, or Bayesian methods |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.