Skip to main content

//clika-runtime/io.clika.modelverse/Modelverse

Modelverse

[common]
object Modelverse

The entry of the Modelverse binding: loads the three native libraries in the one order that works, then answers the library's version.

Call load once per process before any other member of this package. It is idempotent: a second call returns at once. The order is the cross-language invariant of the ClikaRT bindings: the runtime library first (ClikaRt.load), then the model library libClikaRT_modelverse.so, then this binding's JNI bridge libclika_modelverse_jni.so, which resolves the two already-loaded images and never carries a copy of either.

On a desktop JVM the three libraries sit on java.library.path (the runtime distribution's lib/ with the bridge built beside it); on Android an app copies lib/libClikaRT.so and lib/libClikaRT_modelverse.so from the ClikaRT Android payload into its own jniLibs/arm64-v8a/, the AAR of this module bundles the bridge alone, and the entry is Modelverse.load(context, license) (the Android file of this package), which pins the cache root first.

Properties​

NameSummary
isLoaded[common]
val isLoaded: Boolean
True once load has succeeded in this process.
version[common]
val version: String
The model library's version string, the same as the runtime's.

Functions​

NameSummary
bench[common]
fun bench(model: GenerativeModel, options: BenchOptions = BenchOptions()): BenchReport
The serving-path benchmark over a loaded model, the command line's bench verb in process: options' cells times its concurrency widths, one (cell, width) at a time through the serving pipeline over the model, answered as a BenchReport (the rows typed, the CSV text the verb prints, the run's configuration document). The call blocks for the sweep, minutes for the command line's default cells on a phone; a chat sent to the model meanwhile waits behind it, and a close() of the model waits for the sweep to end (the sweep has no cancel). A setup failure (a closed model, an option the library refuses) throws ModelverseException; a cell the model's window cannot fit is a BenchRowStatus.SKIPPED row and a failed row a BenchRowStatus.ERROR row, never an exception. The measurement runs on the device the model loaded on; the configuration document names it.
check[common]
fun check(source: String, options: CheckOptions = CheckOptions()): FitReport
Does the model source loads as (a hub repo id, a hub URL, a local directory or a .gguf file) fit a device, judged from its metadata alone: the command line's check verb in process. Nothing is fetched beyond the model's small documents and its file listing, and nothing runs. One FitVerdict per device options names (this machine's inventory, one device by its spelling, or the caller's own FitDevices: a phone's memory, the budget left for one step), each with the law's terms, the grade, the admitted context and the reason; the report's table is the verb's. A source that cannot be read or a device spelling no device matches throws ModelverseException.
deviceMemory[common]
fun deviceMemory(device: String): DeviceMemory
A device's memory as the runtime reads it: device in the runtime's own spelling (cpu, cuda:0, vulkan:0). A device the runtime cannot read refuses with ModelverseException.
hardware[common]
fun hardware(): HardwareReport
The inventory of this machine's compute: the runtime's version, the CPU's cores and every backend with its devices and their memory, what the devices command prints. Read fresh on every call.
load[common]
fun load(license: String? = null)
Load the runtime, the model library and the bridge, in that order, then read the library's version. license is the runtime's license credential (the CLIKA1-... text, or the path of a file holding it), placed for this process before the first model runs; null leaves the process environment as it is (the runtime then reads its own variable, or the per-user license file). The credential is handed to the runtime and never logged. A second call is a no-op.
load[android]
@JvmOverloads
fun Modelverse.load(context: Context, license: String? = null)
The Android entry: pin the runtime's cache root under the app's cache directory and place license through ClikaRtAndroid.load, then Modelverse.load. One call readies the binding on Android; a second call is a no-op. license is the runtime's license credential (the CLIKA1-... text, or the path of a file holding it); null leaves the process environment as it is.
maxContextLength[common]
fun maxContextLength(source: String, options: CheckOptions = CheckOptions()): Long
The largest context the one device options names can serve source at, from the same law: the admitted window of its verdict (the largest rung of the context ladder up to the model's own window, or up to CheckOptions.maxSeq when given, whose need keeps FitGrade.GOOD or better), 0 when no context fits. options must judge exactly one device (one FitDevice, or one device spelling); more refuses with IllegalArgumentException.
pipeline[common]
fun pipeline(task: String, model: PreTrainedModel): Pipeline
The pipeline of task over an already loaded model; a model of another class refuses with IllegalArgumentException.
[common]
fun pipeline(task: String, source: String, options: LoadOptions = LoadOptions(), stageObserver: StageObserver? = null): Pipeline
The pipeline of task (transformers' task strings: text-generation, automatic-speech-recognition, text-to-speech, translation, image-to-text, object-detection, depth-estimation, image-feature-extraction, zero-shot-image-classification, feature-extraction, text-ranking, voice-activity-detection, text-to-image, text-to-video, and their aliases) over the model source loads as: a snapshot directory, a hub repo id or a GGUF file, under options. stageObserver is installed on the model where its kind reports stages (GenerativeModel); a kind that reports none refuses it. An unknown task refuses with IllegalArgumentException naming the tasks; a task whose handle is not in this binding refuses with ModelverseException. The pipeline owns the model.
registeredArchitectures[common]
fun registeredArchitectures(): Set<String>
The architectures[0] names of every runnable family.
registeredGgufArchitectures[common]
fun registeredGgufArchitectures(): Set<String>
The GGUF architecture names of every runnable family.
registeredModelTypes[common]
fun registeredModelTypes(): Set<String>
The model_type values of every runnable family.
registry[common]
fun registry(): List<RegisteredFamily>
The catalog of registered families, read once and kept.
selfTest[common]
fun selfTest(): String
The bridge's own check of the model library: a line naming the families it serves.
serve[common]
fun serve(model: GenerativeModel, options: ServeOptions = ServeOptions()): Server
A Server over a loaded model under options, not yet listening (Server.start). The server holds the model: the model's close() refuses until the server is closed.
[common]
fun serve(task: String, source: String, loadOptions: LoadOptions = LoadOptions(), options: ServeOptions = ServeOptions()): Server
A Server over the model source loads as (through AutoModel.fromPretrained with task, text-generation by default), not yet listening. The server owns nothing more than any other: the loaded model is answered through Server.model and is the caller's to close after the server.
snapshot[common]
fun snapshot(source: String, options: LoadOptions = LoadOptions(), listener: DownloadListener? = null): Snapshot
Download, or find in the cache, the model files of source (a hub repo id, a model-page URL, or a local directory, answered as it is) and say where they rest: the one resolve clikart-cli fetch runs. The checkpoint's planning verdict runs first, so an unservable checkpoint refuses before any weight byte moves; the files land in the hub cache (LoadOptions.cacheDir, else the hub's own) under options' hub knobs (the revision, the token, the offline switch), a GGUF repository's option through LoadOptions.weights (several options and no pick refuse naming them); the family's companions fetch too, each named in the answer with its outcome. listener hears each file's progress and may stop the download. A later load of Snapshot.loadPath with offline = true runs from the cache alone. Refuses with ModelverseException carrying the hub's own code name.