ZETIC Melange

Hugging Face

Load and run models directly from Zetic Hugging Face repositories.

Overview

Melange provides a seamless integration with Hugging Face, allowing you to load and execute models using only their Repository ID This feature is ideal for quick prototyping and using public models without manual key management.

Explore compatible models on the Zetic Hugging Face Page.

Using ZeticMLangeHFModel

The ZeticMLangeHFModel API abstracts the complexity of model downloading, authentication, and loading into a simple, high-level interface.

Android Usage (Kotlin)

Add ZeticMLange Dependency

Integrate the MLange AAR (Android Archive) which contains the Unified HAL for Android devices.

Native Library Handling

We enable useLegacyPackaging to ensure our C++ NPU drivers (JNI) are correctly bundled without compression, optimizing load times.

build.gradle.kts

    android {
        ...
        packaging {
            jniLibs {
                useLegacyPackaging = true
            }
        }
    }

    dependencies {
        implementation("com.zeticai.mlange:mlange:+")
    }

build.gradle

    android {
        ...
        packagingOptions {
            jniLibs {
                useLegacyPackaging true
            }
        }
    }

    dependencies {
        implementation 'com.zeticai.mlange:mlange:+'
    }

Initialize & Run

On Android, we recommend performing initialization within a background thread or a CoroutineScope to maintain UI responsiveness.

// Initialize the model using a Hugging Face Repo ID
val model = ZeticMLangeHFModel(context, HUGGING_FACE_REPO_ID)

// Run inference
val outputs = model.run(arrayOf(inputTensor))

iOS Usage (Swift)

Add ZeticMLange Package to Project

We use Swift Package Manager (SPM) to automatically resolve and link the binary dependencies required for NPU acceleration.

  1. Click File → Add Package Dependencies in Xcode
  2. Search for https://github.com/zetic-ai/ZeticMLangeiOS.git
  3. Click Add Package

Select Target for ZeticMLange Package

Link the ZeticMLange library to your specific application target. This injects the Unified HAL runtime into your app bundle.

  1. Select target in the Add to Target column
  2. Click Add Package

Initialize and Run

Initialization must be performed within an asynchronous context. Once initialized, you can run inference synchronously.

// Initialize the model using a Hugging Face Repo ID
let model = try await ZeticMLangeHFModel(HUGGING_FACE_REPO_ID)

// Run inference
let outputs = try model.run(inputs: [inputTensor])