Table of Contents

Class LoraMerger

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

Handles the merging of Low-Rank Adaptation (LoRA) transformations into a base model.
This class is responsible for loading LoRA transformation files and integrating them with a base model's weights. The base model may be a plain GGUF file, an LM-Kit model archive whose GGUF entry is stored uncompressed, or an LM-Kit encrypted GGUF container (with EncryptionPassword set); container-packaged bases are read through the same provider contract as model loading, so no plaintext copy of the base is ever materialized.

public sealed class LoraMerger
Inheritance
LoraMerger
Inherited Members

Constructors

LoraMerger(LM)

Initializes a new instance of the LoraMerger class using an existing LM object.

LoraMerger(string)

Initializes a new instance of the LoraMerger class with a specified base model file path.

Properties

EnableQuantization

Gets or sets a flag indicating whether the merged model is re-quantized back to the base model's precision after the merge.

EncryptionPassword

Password used to open the base model when it is an LM-Kit encrypted GGUF container. Ignored for plain GGUF files and LM-Kit model archives.

ThreadCount

Gets or sets the number of threads to be used for the merging process.
Ensures that the thread count is always at least 1 to prevent invalid configurations.

Methods

AddLoraAdapter(LoraAdapterSource)

Adds a LoRA (Low-Rank Adaptation) transformation to the internal list of adapters using the specified file.

AddLoraAdapter(string, float)

Adds a LoRA (Low-Rank Adaptation) transformation to the internal list of adapters using the specified file path and scale factor.

ClearAdapters()

Clears all previously added LoRA (Low-Rank Adaptation) adapters from the internal list.

Merge(string, MetadataCollection)

Merges the currently loaded LoRA (Low-Rank Adaptation) transformations into the base model and saves the result to the specified destination file path.
This operation combines the base model with the applied LoRA adapters, allowing for efficient fine-tuning of the model.

Share