ModelFormat enum

The container format of a model file, which selects the runtime that loads it.

On native platforms LlamaEngine(LlamaBackend()) reads a model file's header to choose the runtime, so a model whose path or URL has no model extension still loads in the right one. Web URL loads cannot read the file before the runtime fetches it, so they route by the URL's extension; pass a format explicitly, as in ModelSource.url(uri, format: ModelFormat.liteRtLm), when the URL has none.

Inheritance
Available extensions

Values

gguf → const ModelFormat

A GGUF file, run by llama.cpp.

const ModelFormat(LlamaRuntime.llamaCpp, '.gguf', [0x47, 0x47, 0x55, 0x46])
liteRtLm → const ModelFormat

A LiteRT-LM .litertlm bundle, run by LiteRT-LM.

const ModelFormat(LlamaRuntime.liteRtLm, '.litertlm', [0x4C, 0x49, 0x54, 0x45, 0x52, 0x54, 0x4C, 0x4D])

Properties

extension → String
The lowercase file extension of this format, including the dot.
final
hashCode → int
The hash code for this object.
no setterinherited
index → int
A numeric identifier for the enumerated value.
no setterinherited
name → String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
runtime → LlamaRuntime
The runtime that loads this format.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

fromHeader(List<int> header) → ModelFormat?
The format whose magic bytes start header, or null when header matches none.
fromPath(String pathOrUrl) → ModelFormat?
The format named by the file extension of pathOrUrl, ignoring case, or null when it has no model extension.

Constants

headerLength → const int
The number of leading file bytes fromHeader needs to recognize every format.
values → const List<ModelFormat>
A constant List of the values in this enum, in order of their declaration.