Introduction
GGML files are the model files of the ggml
tensor library from before GGUF. They were used by llama.cpp and other ggml programs in
2023, usually with the extension .bin, and are still the model format of
whisper.cpp, whose speech
recognition models have names such as ggml-base.en.bin.
The format had no general way to add information: each program wrote a fixed list of settings for its own model type, so new model types and new quantisation methods kept breaking old files. llama.cpp replaced it with GGUF in August 2023 and no longer reads it.
Structure
Numbers are little-endian. The file starts with a 32-bit magic number, written as a number, so the bytes appear reversed:
ggml(byteslmgg): the original, unversioned layoutggmf(bytesfmgg): followed by a version numberggjt(bytestjgg): followed by a version number, with tensor data aligned to 32 bytes so it can be mapped into memory
0Magic and, in ggmf and ggjt files, a version4 or 8 bytes…Hyperparameters a fixed list of 32-bit numbers for the model type, such as vocabulary size, layers and headsvaries…Vocabulary each token as a length and its bytes, with a score in later versionsvaries…Tensors each with dimension count, name length, type, dimensions, name and datathe rest
Because the hyperparameters have no names, a reader must know in advance which model type wrote the file. The layouts and versions page gives the details known for LLaMA files.
Not described
The old GGML, GGMF and GGJT files have no specification; the layouts page follows
llama.cpp at the commit it names and the history in docs/gguf.md.
Known, not yet covered
- Reference: hyperparameter blocks of programs outside the ggml
examples: Falcon and BLOOM ports (separate repositories), the whisper example
(
examples/whisperand itsconvert-pt-to-ggml.py, which has its own header and mel filters), sam, mnist and the other examples. The layouts page now covers LLaMA and the GPT-2, StarCoder, GPT-J, GPT-NeoX, Dolly v2, MPT and Replit examples. - Viewer: not re-audited in this pass.
Unknown
- Reference: a specification: none was ever published for the unversioned GGML format; any layout is whatever a given program wrote.
Also used for
- PyTorch model (pytorch_model.bin) – Tensors saved by torch.save: a pickle and raw data in a ZIP archive.
Links
Software
- whisper.cpp – speech recognition program whose models use this format (Windows, macOS, Linux)
Developers
- ggml – the tensor library, whose examples read and write these files (C)