ModelParser

interface ModelParser(source)

Common interface for all model format parsers.

Provides a unified API for loading and inspecting different model formats (ONNX, GGUF, SafeTensors, etc.) using a metadata-first approach.

Usage:

val parser = GgufModelParser()
val metadata = parser.parseMetadata("/path/to/model.gguf")
if (metadata.isValid) {
val tensors = parser.getTensors()
val modelInfo = parser.getModelInfo()
}

Inheritors

Properties

Link copied to clipboard
abstract val format: ModelFormat

The model format this parser handles.

Link copied to clipboard

The file extension this parser supports (without dot).

Functions

Link copied to clipboard
abstract fun getModelInfo(): ModelInfo

Get general model information.

Link copied to clipboard
abstract suspend fun getTensors(): List<TensorInfo>

Get list of tensors with their metadata.

Link copied to clipboard
abstract fun isInitialized(): Boolean

Check if the parser has been initialized with a model.

Link copied to clipboard
abstract fun isValid(): Boolean

Check if the last parsing attempt was successful.

Link copied to clipboard
abstract suspend fun parseMetadata(filePath: String): ModelMetadata

Parse model metadata from the given file path.