class
Llama::AdapterLora
- Llama::AdapterLora
- Reference
- Object
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.crllama/adapter_lora/error.cr
Constructors
-
.new(model : Model, path : String)
Creates a new LoRA adapter from a file
Instance Method Summary
-
#begin_attachment! : AttachmentLease
Reserves the native handle until an attachment either commits or fails.
-
#close : Nil
Releases the adapter unless it is still attached to a context.
-
#closed? : Bool
Returns whether the native adapter has been released.
-
#finalize
Frees the resources associated with this adapter
-
#free : Nil
Releases the underlying C resources
-
#model : Model
Returns the model this adapter was loaded for.
-
#to_unsafe : Pointer(Llama::LibLlama::LlamaAdapterLora)
Returns the raw pointer to the underlying llama_adapter_lora structure
-
#unsafe_handle! : Pointer(LibLlama::LlamaAdapterLora)
Returns a checked native handle for internal wrapper use.
Constructor Detail
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
Instance Method Detail
Reserves the native handle until an attachment either commits or fails. :nodoc:
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.
Returns the raw pointer to the underlying llama_adapter_lora structure
Returns a checked native handle for internal wrapper use. :nodoc: