Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Ggml org Llama cpp Android GgufMetadata

From Leeroopedia
Revision as of 12:38, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Ggml_org_Llama_cpp_Android_GgufMetadata.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Android, GGUF
Last Updated 2026-02-15 00:00 GMT

Overview

Data class hierarchy representing structured metadata extracted from GGUF model files, covering all major metadata categories.

Description

The top-level `GgufMetadata` data class contains file-level fields (version, tensor count, KV count) and nested data classes for: `BasicInfo` (name, UUID, size label), `AuthorInfo` (organization, author, license, URLs), `AdditionalInfo` (type, description, tags, languages), `ArchitectureInfo` (architecture name, file type, vocab size, finetune), `BaseModelInfo` (for derivative models), `TokenizerInfo` (model type, special token IDs, chat template), `DimensionsInfo`, `AttentionInfo`, `RopeInfo`, and `ExpertsInfo`. Includes a `GgufVersion` enum supporting Legacy v1, Extended v2, and Validated v3 formats.

Usage

Use this type-safe Kotlin representation of GGUF file metadata to enable the Android app to display detailed model information (architecture, quantization, tokenizer configuration, licensing) to users before and during inference.

Code Reference

Source Location

  • Repository: Ggml_org_Llama_cpp
  • File: examples/llama.android/lib/src/main/java/com/arm/aichat/gguf/GgufMetadata.kt
  • Lines: 1-132

Signature

data class GgufMetadata(
    val version: GgufVersion,
    val tensorCount: Long,
    val kvCount: Long,
    val basic: BasicInfo,
    val author: AuthorInfo? = null,
    val additional: AdditionalInfo? = null,
    val architecture: ArchitectureInfo? = null,
    val baseModels: List<BaseModelInfo>? = null,
    val tokenizer: TokenizerInfo? = null,
    val dimensions: DimensionsInfo? = null,
    val attention: AttentionInfo? = null,
    val rope: RopeInfo? = null,
    val experts: ExpertsInfo? = null
)

enum class GgufVersion(val code: Int, val label: String) {
    LEGACY_V1(1, "Legacy v1"),
    EXTENDED_V2(2, "Extended v2"),
    VALIDATED_V3(3, "Validated v3")
}

data class BasicInfo(val uuid: String?, val name: String?, val nameLabel: String?, val sizeLabel: String?)
data class AuthorInfo(val organization: String?, val author: String?, val doi: String?, val url: String?, val repoUrl: String?, val license: String?, val licenseLink: String?)
data class AdditionalInfo(val type: String?, val description: String?, val tags: List<String>?, val languages: List<String>?)
data class ArchitectureInfo(val architecture: String?, val fileType: Int?, val vocabSize: Int?, val finetune: String?, val quantizationVersion: Int?)
data class BaseModelInfo(val name: String?, val author: String?, val version: String?, val organization: String?, val description: String?, val repoUrl: String?, val doi: String?)
data class TokenizerInfo(val model: String?, val bosTokenId: Int?, val eosTokenId: Int?, val chatTemplate: String?)
data class DimensionsInfo(val embeddingLength: Int?, val feedForwardLength: Int?, val blockCount: Int?, val contextLength: Int?)
data class AttentionInfo(val headCount: Int?, val headCountKV: Int?, val layerNormRmsEpsilon: Float?)
data class RopeInfo(val dimensionCount: Int?, val freqBase: Float?, val scalingType: String?)
data class ExpertsInfo(val count: Int?, val usedCount: Int?)

Import

import java.io.IOException

I/O Contract

Inputs

Name Type Required Description
version GgufVersion Yes GGUF file format version (v1, v2, or v3)
tensorCount Long Yes Number of tensors in the GGUF file
kvCount Long Yes Number of key-value metadata pairs
basic BasicInfo Yes Basic model identification info (name, UUID, size label)

Outputs

Name Type Description
GgufMetadata data class Immutable structured representation of all GGUF metadata fields

Usage Examples

// Access metadata fields after reading a GGUF file
val metadata: GgufMetadata = reader.readStructuredMetadata(inputStream)

// Display model information
println("Model: ${metadata.basic.name}")
println("Version: ${metadata.version}")
println("Architecture: ${metadata.architecture?.architecture}")
println("Vocab size: ${metadata.architecture?.vocabSize}")
println("Tensor count: ${metadata.tensorCount}")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment