Table of Contents

Method ApplyLoraAdapter

Namespace
LMKit.Model
Assembly
LM-Kit.NET.dll

ApplyLoraAdapter(string, float, int)

Applies a Low-Rank Adaptation (LoRA) transformation to the model weights using parameters from a specified file. This method adjusts the model weights dynamically based on the adaptation parameters provided in the file.

public void ApplyLoraAdapter(string path, float scale = 1, int threadCount = -1)

Parameters

path string

The path to the LoRA adapter source file. This parameter must not be null or empty.

scale float

The scale factor for the LoRA adapter source. This must be a positive value. The default value is 1.

threadCount int

The number of threads to allocate for the operation. If this value is less than or equal to 0, the ThreadCount will be used.

Exceptions

ArgumentNullException

Thrown if the path parameter is null or empty.

ArgumentOutOfRangeException

Thrown if the scale parameter is less than or equal to 0.

FileNotFoundException

Thrown if the file specified by the path parameter does not exist.

InvalidDataException

Thrown if the file header is invalid.

RuntimeException

Thrown if the LoRA adaptation fails to load or apply correctly from the specified file. This may occur due to issues such as reading the file, parsing the adaptation parameters, or applying these parameters to the model.

ApplyLoraAdapter(LoraAdapterSource, int)

Applies a Low-Rank Adaptation (LoRA) transformation to the model weights using parameters from a LoraAdapterSource instance. This method adjusts the model weights dynamically based on the adaptation parameters provided in the LoraAdapterSource.

public void ApplyLoraAdapter(LoraAdapterSource loraAdapterSource, int threadCount = -1)

Parameters

loraAdapterSource LoraAdapterSource

An instance of LoraAdapterSource containing the path to the LoRA parameters and the scale factor.

threadCount int

The number of threads to allocate for the operation. If this value is less than or equal to 0, the ThreadCount will be used.

Exceptions

ArgumentNullException

Thrown if the loraAdapterSource parameter is null.

RuntimeException

Thrown if the LoRA adaptation fails to load or apply correctly from the specified file. This may occur due to issues such as reading the file, parsing the adaptation parameters, or applying these parameters to the model.