class Llama::AdapterLora

Overview

Wrapper for the llama_adapter_lora structure

This class represents a LoRA (Low-Rank Adaptation) adapter that can be applied to a model to modify its behavior without changing the original weights.

Included Modules

Defined in:

llama/adapter_lora.cr
llama/adapter_lora/error.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(model : Model, path : String) #

Creates a new LoRA adapter from a file

Parameters:

  • model: The Model to load the adapter for
  • path: Path to the LoRA adapter file

Raises:

  • Llama::AdapterLora::Error if the adapter cannot be loaded

[View source]

Instance Method Detail

def begin_attachment! : AttachmentLease #

Reserves the native handle until an attachment either commits or fails. :nodoc:


[View source]
def close : Nil #

Releases the adapter unless it is still attached to a context.


[View source]
def closed? : Bool #

Returns whether the native adapter has been released.


[View source]
def finalize #

Frees the resources associated with this adapter


[View source]
def free : Nil #

Releases the underlying C resources

Calling this method multiple times is safe; only the first call releases the resources. The finalizer also calls this method, so manual calls are only needed to release resources deterministically, for example before process exit.


[View source]
def model : Model #

Returns the model this adapter was loaded for.


[View source]
def to_unsafe : Pointer(Llama::LibLlama::LlamaAdapterLora) #

Returns the raw pointer to the underlying llama_adapter_lora structure


[View source]
def unsafe_handle! : Pointer(LibLlama::LlamaAdapterLora) #

Returns a checked native handle for internal wrapper use. :nodoc:


[View source]