Melange
API ReferenceAndroid

ZeticMLangeModel

API reference for general model inference on Android.

This page reflects ZeticMLange Android 1.9.0.

ZeticMLangeModel loads a general on-device model from the Melange registry and runs tensor inference on Android.

Import

import com.zeticai.mlange.core.model.ZeticMLangeModel

Constructor

ZeticMLangeModel(
    context: Context,
    personalKey: String,
    name: String,
    version: Int? = null,
    modelMode: ModelMode = ModelMode.RUN_AUTO,
    quantType: QuantType? = null,
    onDownload: ((Float) -> Unit)? = null,
    cacheHandlingPolicy: ModelCacheHandlingPolicy = ModelCacheHandlingPolicy.REMOVE_OVERLAPPING,
)
ParameterTypeDefaultDescription
contextContext-Android context used for cache and file access.
personalKeyString-Personal key for accessing the model.
nameString-Model name in account_name/project_name format.
versionInt?nullModel version. null loads the latest version.
modelModeModelModeRUN_AUTOBackend selection strategy.
quantTypeQuantType?nullOptional precision filter.
onDownload((Float) -> Unit)?nullDownload progress callback from 0.0 to 1.0.
cacheHandlingPolicyModelCacheHandlingPolicyREMOVE_OVERLAPPINGManaged artifact cache cleanup policy.
val model = ZeticMLangeModel(
    context = context,
    personalKey = PERSONAL_KEY,
    name = "account_name/project_name",
    modelMode = ModelMode.RUN_AUTO,
)

run(inputs)

Runs inference with tensors matching the model input order.

fun run(inputs: Array<Tensor> = emptyArray()): Array<Tensor>
ParameterTypeDescription
inputsArray<Tensor>Input tensors matching the model's expected shapes and data types.

Returns: output tensors in model output order.

val outputs = model.run(arrayOf(inputTensor))
val firstOutput = outputs[0]

Lifecycle

val isClosed: Boolean
fun close()

Call close() when the model is no longer needed.

model.close()

On this page