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.ZeticMLangeModelConstructor
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,
)| Parameter | Type | Default | Description |
|---|---|---|---|
context | Context | - | Android context used for cache and file access. |
personalKey | String | - | Personal key for accessing the model. |
name | String | - | Model name in account_name/project_name format. |
version | Int? | null | Model version. null loads the latest version. |
modelMode | ModelMode | RUN_AUTO | Backend selection strategy. |
quantType | QuantType? | null | Optional precision filter. |
onDownload | ((Float) -> Unit)? | null | Download progress callback from 0.0 to 1.0. |
cacheHandlingPolicy | ModelCacheHandlingPolicy | REMOVE_OVERLAPPING | Managed 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>| Parameter | Type | Description |
|---|---|---|
inputs | Array<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()