These formats were never written down as a specification. This page describes them
as the llama.cpp loader read them before it moved to GGUF
(its llama.cpp and llama.h at tag
master-2e6cd4b),
and as the “Historical State of Affairs” in
gguf.md
summarises them, both read 2026-11-12. Numbers are little-endian 32-bit unless noted.
gguf.md says the plain ggml layout was mainly used by the examples in
ggml and ggjt by llama.cpp; all share the same frame with model-specific
hyperparameters.
Magic numbers and versions
| Magic (number) | Bytes in the file | Version | Notes |
|---|---|---|---|
0x67676D6C ggml | 6C 6D 67 67 | None | The first layout; vocabulary without scores. |
0x67676D66 ggmf | 66 6D 67 67 | 1 | Adds a version and token scores. |
0x67676A74 ggjt | 74 6A 67 67 | 1, 2, 3 | Tensor data aligned to 32 bytes for memory mapping. Version 2 changed the quantisation format and version 3 the Q4 and Q8 formats; gguf.md says the three are otherwise identical but incompatible. |
LLaMA hyperparameters
Seven 32-bit integers, in this order:
| Field | Meaning |
|---|---|
n_vocab | Vocabulary size |
n_embd | Embedding width |
n_mult | Used to work out the feed-forward width |
n_head | Attention heads |
n_layer | Layers |
n_rot | Rotary embedding dimensions |
ftype | File type |
Vocabulary and tensors
- Vocabulary:
n_vocabentries, each a 32-bit length, the token’s bytes and (ggmf, ggjt) a 32-bit float score. - Tensors, until the end of the file: number of dimensions, name length, type (all 32-bit), the dimensions (32-bit each; the LLaMA loader accepts only 1 or 2), the name, then in ggjt files padding to a multiple of 32 bytes from the start of the file, then the data. The type uses the ggml type numbers listed on the GGUF types page.
Other models in the ggml examples
The ggml repository's example programs each read their own file, the plain
ggml layout of the first table above. This section is from the examples as
they stood at commit 13e2fa692bb30ca9441d3558bc74dc2703c06ead (ggml-org/ggml,
28 September 2023, per the GitHub commit list), read 2026-11-13: each example's
main.cpp loader, its convert-*-to-ggml.py script and
common-ggml.cpp. The examples were later removed from the repository's current
tree, which keeps only gpt-2 and gpt-j among these. Every file starts with the 32-bit
magic 0x67676d6c (GGML_FILE_MAGIC; GGML_FILE_VERSION
is 1, but none of these loaders reads a version). All integers are 32-bit little-endian
and floats are 32-bit.
- Common frame: magic, the model's hyperparameters (below), the vocabulary, then tensor records until the end of the file. A tensor record is
n_dims,lengthof the name,ttype(ggml type number), thenne[0] … ne[n_dims−1](the loaders read at most two), the name bytes, then the data, with no padding or alignment. The converters write the dimensions in reverse numpy order (shape[n_dims − 1 − i]), sone[0]is the contiguous one. A loader rejects a name it does not know and a shape that differs from what the hyperparameters imply. - ftype and quantisation version: the
ftypefield holds the file type plusqntvr × 1000(GGML_QNT_VERSION_FACTORis 1000,GGML_QNT_VERSIONis 2 in this header); a loader divides to get the quantisation version and takes the remainder as the file type. The converters write 0 (F32) or 1 (F16) there; thequantizeexamples rewrite it. - Which tensors are F16: with ftype 1 the converters store a tensor as float16 only when its name and dimensions fit a rule: GPT-J, GPT-NeoX, Dolly v2, Replit and the GPT-2 h5 converter, a name ending
.weightwith exactly 2 dimensions; MPT,.weightwith more than 1 dimension; the StarCoder converter, a 2-D tensor namedmodel/wte,model/lm_heador ending/gor/w. Every other tensor is F32. The tensor record'sttypesays which. (The Dolly v2 and GPT-2 checkpoint converters were not read for this rule.)
| Model (example) | Hyperparameters, in file order | Vocabulary |
|---|---|---|
GPT-2 (gpt-2) | n_vocab, n_ctx, n_embd, n_head, n_layer, ftype (the program's eps 1e-5 is not stored) | n_vocab again (the loader requires it to equal the hyperparameter), then per token a 32-bit length and the bytes; no scores. |
StarCoder (starcoder) | Same six as GPT-2. | Same as GPT-2. After loading, the program adds the StarChat tokens it finds (<|system|>, <|user|>, <|assistant|>, <|end|>, <fim-prefix>, <fim-middle>, <fim-suffix>, <fim-pad>, <|end_of_turn|>) as special tokens. |
GPT-J (gpt-j) | n_vocab, n_ctx, n_embd, n_head, n_layer, n_rot, ftype. The converter writes vocab_size, n_positions, n_embd, n_head, n_layer, rotary_dim. | A repeated n_vocab (checked), then length and bytes per token. The converter writes the base and added tokens (count = both), text through the byte-to-unicode decoder. |
GPT-NeoX (gpt-neox), Dolly v2 (dolly-v2) | n_vocab, n_ctx, n_embd, n_head, n_layer, n_rot, par_res (1 = parallel residual), ftype. The NeoX converter writes vocab_size, max_position_embeddings, hidden_size, num_attention_heads, num_hidden_layers, int(rotary_pct × (hidden_size / num_attention_heads)), use_parallel_residual (True if absent). | No repeated count: exactly n_vocab entries of length and bytes. Dolly v2 then adds the special tokens ### End, ### Instruction: and ### Response: in the program. |
MPT (mpt) | d_model, max_seq_len, n_heads, n_layers, n_vocab (int32), alibi_bias_max (float), clip_qkv (float; the converter writes 0 if the config has none), ftype. The program sets n_ctx to the smaller of max_seq_len and its own setting. | n_vocab entries of length and bytes; the program converts each token from UTF-8 back to single bytes. |
Replit (replit) | d_model, max_seq_len, n_heads, n_layers, n_vocab, ftype. | n_vocab entries of 32-bit length, bytes and a float score (SentencePiece piece scores; the program negates the score when it loads). The converter writes a zero length and score 0 for ids it fills in. |
| Model | Names |
|---|---|
| GPT-2 and StarCoder | model/ln_f/g, model/ln_f/b, model/wte, model/wpe, model/lm_head; per layer model/hi/ln_1/g and /b, ln_2/g and /b, attn/c_attn/w and /b, attn/c_proj/w and /b, mlp/c_fc/w and /b, mlp/c_proj/w and /b. The GPT-2 loader copies model/wte into the LM head when the file has no separate model/lm_head. The StarCoder converter renames from the Hugging Face names (transformer.h.i.attn.c_attn.weight → model/hi/attn/c_attn/w and so on) and skips attn.masked_bias and .attn.bias. StarCoder uses multi-query attention; the converter duplicates the K and V heads (np.tile) so the file holds the multi-head 3 × n_head × head_dim layout. |
| GPT-J | transformer.wte.weight, transformer.ln_f.weight, transformer.ln_f.bias, lm_head.weight, lm_head.bias; per layer transformer.h.i.ln_1.weight and .bias, attn.q_proj.weight, attn.k_proj.weight, attn.v_proj.weight, attn.out_proj.weight, mlp.fc_in.weight and .bias, mlp.fc_out.weight and .bias. |
| GPT-NeoX and Dolly v2 | gpt_neox.embed_in.weight, gpt_neox.final_layer_norm.weight and .bias, embed_out.weight; per layer gpt_neox.layers.i.input_layernorm.weight and .bias, attention.query_key_value.weight and .bias, attention.dense.weight and .bias, post_attention_layernorm.weight and .bias, mlp.dense_h_to_4h.weight and .bias, mlp.dense_4h_to_h.weight and .bias. |
| MPT and Replit | transformer.wte.weight, transformer.norm_f.weight; per layer transformer.blocks.i.norm_1.weight, attn.Wqkv.weight, attn.out_proj.weight, norm_2.weight, ffn.up_proj.weight, ffn.down_proj.weight. No bias tensors. |
File types
| ftype | Meaning |
|---|---|
| 0 | All F32 |
| 1 | Mostly F16 |
| 2 | Mostly Q4_0 |
| 3 | Mostly Q4_1 |
| 4 | Mostly Q4_1; tok_embeddings.weight and output.weight F16 |
| 5, 6 | Q4_2, Q4_3 (removed) |
| 7 | Mostly Q8_0 |
| 8 | Mostly Q5_0 |
| 9 | Mostly Q5_1 |
| 10 | Mostly Q2_K |
| 11, 12, 13 | Mostly Q3_K_S, Q3_K_M, Q3_K_L |
| 14, 15 | Mostly Q4_K_S, Q4_K_M |
| 16, 17 | Mostly Q5_K_S, Q5_K_M |
| 18 | Mostly Q6_K |
“Mostly” because, as the header comments say, one-dimensional tensors are left
out. Values 0 to 9 are in the old llama.h; 10 to 18 are listed in
gguf.md as GGUF’s general.file_type, which uses the same
numbers. In plain ggml files, gguf.md says the quantisation version
is packed into ftype as a multiple of 1,000.