LeapDownloader
The LeapDownloader class is the recommended entrypoint for loading models. It is a wrapper around the LEAP SDK that provides a simple and convenient way to download and load models.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
config | LeapDownloaderConfig | No | LeapDownloaderConfig() | Configuration options for the downloader. See LeapDownloaderConfig for more details. |
loadModel
Download a model from the LEAP Model Library and load it into memory. If the model has already been downloaded, it will be loaded from the local cache without a remote request.
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
modelSlug | String | Yes | - | The name of the model to load. See the LEAP Model Library for all available models. |
quantizationSlug | String | Yes | - | The quantization level to download for the given model. See the LEAP Model Library for all available quantization levels. |
modelLoadingOptions | ModelLoadingOptions | No | null | Options for loading the model. See ModelLoadingOptions for more details. |
generationTimeParameters | GenerationTimeParameters | No | null | Parameters to control model generation at inference time. See GenerationTimeParameters for more details. |
progress | (ProgressData) -> Unit | No | {} | A callback function to receive the download progress. |
ModelRunner: A ModelRunner instance that can be used to interact with the loaded model.
downloadModel
Download a model from the LEAP Model Library and save it to the local cache, without loading it into memory.
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
modelSlug | String | Yes | - | The name of the model to download. See the LEAP Model Library for all available models. |
quantizationSlug | String | Yes | - | The quantization level to download for the given model. See the LEAP Model Library for all available quantization levels. |
progress | (ProgressData) -> Unit | No | {} | A callback function to receive the download progress. |
Manifest: The Manifest instance that contains the metadata of the downloaded model.
LeapDownloaderConfig
The LeapDownloaderConfig class contains all the configuration options for LeapDownloader. It is a data class with the following fields:
GenerationTimeParameters
The GenerationTimeParameters class contains all the parameters for controlling model generation. It is a data class with the following fields:
SamplingParameters
The SamplingParameters class contains sampling options to override the values provided in a model manifest. It is a data class with the following fields:
ProgressData
The ProgressData class can be used to track download progress. It is a data class with the following fields:
Manifest
The Manifest class is a wrapper class to read and encapsulate data read from the model manifests, and contains metadata about a downloaded model. It is a data class with the following fields:
It is rarely necessary to instantiate a
Manifest class directly. It is created internally by LeapDownloader to store and return metadata about downloaded models.Legacy: LeapClient
Legacy: LeapClient
The
This function can be called from UI thread. The app should hold the
For audio generation model, an instance of
This function can be called from UI thread. The
LeapClient class is a legacy class that is no longer recommended for use. It is still available for backward compatibility, but it is recommended to use the new LeapDownloader class instead.The entrypoint of LEAP SDK. It doesnβt hold any data.loadModel
This function can be called from UI thread. The app should hold the ModelRunner object returned by this function until there is no need to interact with the model anymore. See ModelRunner for more details.Argumentspath: A local path pointing to model bundle file. Both.bundlefiles and.gguffiles are supported.options: Options for loading the model.mmprojPath: Optional multimodal projection model path. This parameter should only be filled if the model needs a separate multimodal projection model to parsing multimodal (image, audio, etc.) contents.
The function will throw
LeapModelLoadingException if LEAP fails to load the model.AudioGenerationModelDescriptor
For audio generation model, an instance of AudioGenerationModelDescriptor contains all components that are necessary for audio generation.modelPath: Main model path.mmprojPath: Multimodal projection model path.audioDecoderPath: Audio decoder model path.audioTokenizerPath: Audio tokenizer model path.
loadModelAsResult
This function can be called from UI thread. The path should be a local path pointing to model bundle file. This function is merely a wrapper around loadModel function to return a Result.ModelLoadingOptions
A data class to represents options in loading a model.
randomSeed: Set the random seed for loading the model to reproduce the outputcpuThreads: How many threads to use in the generation.
ModelLoadingOptions.build is also available. For example, loading a model with 4 CPU threads can be done by