Skip to main content
RunAnywhere.models is the model catalog and its residency. Everything about getting a model onto the device and into memory lives here.

The short version

You often do not need this page. Generation loads what it needs and downloads when options.model names a model that is not on disk:
Reach for the models namespace when you want to control when that cost is paid, show download progress, or let a person choose.

What is available

Downloading, with progress

download returns a Flow<DownloadEvent>. Models are hundreds of megabytes to several gigabytes, so show this rather than a spinner.
DownloadEvent.Progress carries bytesDone, bytesTotal, fraction, percent, bytesPerSecond, etaSeconds, retryAttempt, currentFileIndex, totalFiles, and overallProgress. A multi-file model reports both the current file and the overall figure. Collect this in a scope that outlives the screen if you want the download to survive navigation, or in viewModelScope if it should be cancelled with the screen.

Loading

Downloading puts the model on disk. Loading puts it in memory.
With options:
contextLength is the one that matters most. A larger window costs memory whether you use it or not, so allocate what your longest conversation actually needs.

Forcing the NPU

On Snapdragon hardware, pin the backend to compare against CPU:
QHexRT is arm64 only and rejects parts outside the validated V75, V79, and V81 set, so this throws on an emulator or an unsupported chip rather than silently falling back.

Switching models

On a phone, unload before loading rather than after. Holding two language models at once is how you get ERROR_CODE_INSUFFICIENT_MEMORY. You can also switch per call, without touching residency:
Simpler, and slower when you alternate.

Unloading

Frees memory and leaves the file on disk, so the next load is fast. Do this in onCleared, and when the app backgrounds if you hold several models.

What is resident right now

Deleting

Removes the file from disk, unloading first if it is resident.

Registering your own model

Three builders on ModelRegistration:
A vision model with a separate projector, or a speech model with encoder and decoder files, is the multi-file case.

Gated repositories

Needed for private or gated Hugging Face repos, including the runanywhere/*_HNPU NPU bundles. Hold it in EncryptedSharedPreferences or the Keystore, never in source, assets, or logs.

Refreshing the registry

Reconciles the catalog against the bytes actually on disk.

A complete picker

Errors worth handling

ERROR_CODE_INSUFFICIENT_MEMORY on load usually means something else is still resident. Unload first.