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 whenoptions.model names a model that is not on disk:
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.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:Switching models
ERROR_CODE_INSUFFICIENT_MEMORY.
You can also switch per call, without touching residency:
Unloading
onCleared,
and when the app backgrounds if you hold several models.
What is resident right now
Deleting
Registering your own model
Three builders onModelRegistration:
Gated repositories
runanywhere/*_HNPU NPU
bundles. Hold it in EncryptedSharedPreferences or the Keystore, never in source, assets, or
logs.
Refreshing the registry
A complete picker
Errors worth handling
ERROR_CODE_INSUFFICIENT_MEMORY on load usually means something else is still resident.
Unload first.