Table of Contents

Class LiteRtModelInfo

Namespace
LiteRtLmSharp
Assembly
LiteRtLmSharp.dll

Metadata a .litertlm model file declares, read without loading an engine: what kind of model it is, its context size, capabilities, default sampler, supported backends per modality, and embedding facts. Use it to validate a file before loading it or to adapt the app to the model.

public sealed class LiteRtModelInfo
Inheritance
LiteRtModelInfo
Inherited Members

Remarks

Read(string) opens the file, reads every value and closes it, so the object holds no native resources. Values a model does not declare read as false, 0, null or an empty list, as each property states. On a multimodal bundle the native reader copies the vision sections into memory while it reads (gemma-4-E2B-it: about 0.8 GB for a few hundred milliseconds), so on a phone call it before loading engines rather than next to them. Requires native LiteRT-LM v0.18.0+ (c/model_info.h).

Properties

DefaultSampler

Gets the sampler the model declares as its default, or null when it declares none.

public LiteRtSamplerParams? DefaultSampler { get; }

Property Value

LiteRtSamplerParams

EmbeddingDimension

Gets the length of the vectors an embedding model produces, or null for a language model.

public int? EmbeddingDimension { get; }

Property Value

int?

EmbeddingInputLengths

Gets the input lengths, in tokens, an embedding model's text encoder has signatures for, or an empty list for a language model. An embedding engine loads the ones up to MaxInputLength.

public IReadOnlyList<int> EmbeddingInputLengths { get; }

Property Value

IReadOnlyList<int>

InputModalities

Gets the input modalities the file declares (text, vision, audio, video). A bundle can declare a modality whose encoder it does not ship; the engine's own check at load time is authoritative.

public IReadOnlyList<LiteRtModality> InputModalities { get; }

Property Value

IReadOnlyList<LiteRtModality>

IsDynamicContext

Gets a value indicating whether the context size is configurable up to MaxContextTokens (dynamic) rather than fixed by the model graph. For an embedding model it means the file has several input signatures.

public bool IsDynamicContext { get; }

Property Value

bool

MaxContextTokens

Gets the maximum context size in tokens: the fixed size of a static model, or the largest value a dynamic model accepts for MaxNumTokens (see IsDynamicContext). 0 when the file does not declare it. For an embedding model it is the longest input signature (8,192 for EmbeddingGemma 2), which an embedding engine only accepts with MaxInputLength: by default it stops at the limit the model declares (1,024 for EmbeddingGemma 2), which the C API does not expose.

public int MaxContextTokens { get; }

Property Value

int

MaxVisionTokenBudget

Gets the largest per-image vision token budget the model supports, or null when it has no vision input or declares no budget. See VisualTokenBudget.

public int? MaxVisionTokenBudget { get; }

Property Value

int?

MinRuntimeVersion

Gets the minimum LiteRT-LM runtime version the file requires, or null when it declares none.

public string? MinRuntimeVersion { get; }

Property Value

string

ModelType

Gets whether the file is a language model or an embedding model.

public LiteRtModelType ModelType { get; }

Property Value

LiteRtModelType

SupportedBackends

Gets the backends the file declares for each modality, in the model's priority order (the first is its default). A modality without declared backends is absent.

public IReadOnlyDictionary<LiteRtModality, IReadOnlyList<LiteRtBackend>> SupportedBackends { get; }

Property Value

IReadOnlyDictionary<LiteRtModality, IReadOnlyList<LiteRtBackend>>

Remarks

The declaration is not exhaustive: gemma-4-E2B-it declares only CPU for vision, yet its vision encoder runs on the GPU backend. A backend the model truly cannot use makes Load(LiteRtEngineOptions) fail with the runtime's reason.

SupportsFunctionCalling

Gets a value indicating whether the model declares function calling. false when the metadata does not say.

public bool SupportsFunctionCalling { get; }

Property Value

bool

SupportsSpeculativeDecoding

Gets a value indicating whether the file ships a Multi-Token-Prediction drafter for EnableSpeculativeDecoding.

public bool SupportsSpeculativeDecoding { get; }

Property Value

bool

SupportsThinking

Gets a value indicating whether the model declares a reasoning ("thinking") mode. false when the metadata does not say.

public bool SupportsThinking { get; }

Property Value

bool

VisionTokenSizes

Gets the per-image vision token sizes the model's vision encoder supports (for example 70, 140 and 280 on the Gemma 4 E-series), or an empty list when it has no vision input.

public IReadOnlyList<int> VisionTokenSizes { get; }

Property Value

IReadOnlyList<int>

Methods

Read(string)

Reads the metadata of the model file at modelPath.

public static LiteRtModelInfo Read(string modelPath)

Parameters

modelPath string

The path to the .litertlm file.

Returns

LiteRtModelInfo

The model's declared metadata.

Exceptions

ArgumentException

modelPath is empty or the file does not exist.

LiteRtException

The native layer could not open the file as a model.