@@ -1996,52 +1996,22 @@ def llama_adapter_get_alora_invocation_tokens(adapter: llama_adapter_lora_p, /)
19961996# // The following functions operate on a llama_context, hence the naming: llama_verb_...
19971997
19981998
1999- # // Add a loaded LoRA adapter to given context
2000- # // This will not modify model's weight
2001- # LLAMA_API int32_t llama_set_adapter_lora(
1999+ # // Set LoRa adapters on the context. Will only modify if the adapters currently in context are different.
2000+ # LLAMA_API int32_t llama_set_adapters_lora(
20022001# struct llama_context * ctx,
2003- # struct llama_adapter_lora * adapter,
2004- # float scale);
2002+ # struct llama_adapter_lora ** adapters,
2003+ # size_t n_adapters,
2004+ # float * scales);
20052005@ctypes_function (
2006- "llama_set_adapter_lora " ,
2007- [llama_context_p_ctypes , llama_adapter_lora_p_ctypes , ctypes .c_float ],
2006+ "llama_set_adapters_lora " ,
2007+ [llama_context_p_ctypes , ctypes . POINTER ( llama_adapter_lora_p_ctypes ), ctypes . c_size_t , ctypes .c_float ],
20082008 ctypes .c_int32 ,
20092009)
2010- def llama_set_adapter_lora (
2011- ctx : llama_context_p , adapter : llama_adapter_lora_p , scale : float , /
2010+ def llama_set_adapters_lora (
2011+ ctx : llama_context_p , adapters : CtypesArray [ llama_adapter_lora_p ], n_adapters : ctypes . c_size_t , scale : float , /
20122012) -> int :
2013- """Add a loaded LoRA adapter to given context
2014- This will not modify model's weight"""
2015- ...
2016-
2017-
2018- # // Remove a specific LoRA adapter from given context
2019- # // Return -1 if the adapter is not present in the context
2020- # LLAMA_API int32_t llama_rm_adapter_lora(
2021- # struct llama_context * ctx,
2022- # struct llama_adapter_lora * adapter);
2023- @ctypes_function (
2024- "llama_rm_adapter_lora" ,
2025- [llama_context_p_ctypes , llama_adapter_lora_p_ctypes ],
2026- ctypes .c_int32 ,
2027- )
2028- def llama_rm_adapter_lora (
2029- ctx : llama_context_p , adapter : llama_adapter_lora_p , /
2030- ) -> int :
2031- """Remove a specific LoRA adapter from given context
2032- Return -1 if the adapter is not present in the context"""
2033- ...
2034-
2035-
2036- # // Remove all LoRA adapters from given context
2037- # LLAMA_API void llama_clear_adapter_lora(struct llama_context * ctx);
2038- @ctypes_function (
2039- "llama_clear_adapter_lora" ,
2040- [llama_context_p_ctypes ],
2041- None ,
2042- )
2043- def llama_clear_adapter_lora (ctx : llama_context_p , / ):
2044- """Remove all LoRA adapters from given context"""
2013+ """Set LoRa adapters on the context.
2014+ Will only modify if the adapters currently in context are different."""
20452015 ...
20462016
20472017
@@ -2051,15 +2021,15 @@ def llama_clear_adapter_lora(ctx: llama_context_p, /):
20512021# // to an n_embd x n_layers buffer starting from layer 1.
20522022# // il_start and il_end are the layer range the vector should apply to (both inclusive)
20532023# // See llama_control_vector_load in common to load a control vector.
2054- # LLAMA_API int32_t llama_apply_adapter_cvec (
2024+ # LLAMA_API int32_t llama_set_adapter_cvec (
20552025# struct llama_context * ctx,
2056- # const float * data,
2057- # size_t len,
2058- # int32_t n_embd,
2059- # int32_t il_start,
2060- # int32_t il_end);
2026+ # const float * data,
2027+ # size_t len,
2028+ # int32_t n_embd,
2029+ # int32_t il_start,
2030+ # int32_t il_end);
20612031@ctypes_function (
2062- "llama_apply_adapter_cvec " ,
2032+ "llama_set_adapter_cvec " ,
20632033 [
20642034 llama_context_p_ctypes ,
20652035 ctypes .POINTER (ctypes .c_float ),
@@ -2070,7 +2040,7 @@ def llama_clear_adapter_lora(ctx: llama_context_p, /):
20702040 ],
20712041 ctypes .c_int32 ,
20722042)
2073- def llama_apply_adapter_cvec (
2043+ def llama_set_adapter_cvec (
20742044 ctx : llama_context_p ,
20752045 data : CtypesPointerOrRef [ctypes .c_float ],
20762046 len : int ,
@@ -2079,12 +2049,14 @@ def llama_apply_adapter_cvec(
20792049 il_end : int ,
20802050 / ,
20812051) -> int :
2082- """Apply a loaded control vector to a llama_context, or if data is NULL, clear
2052+ """
2053+ Apply a loaded control vector to a llama_context, or if data is NULL, clear
20832054 the currently loaded vector.
20842055 n_embd should be the size of a single layer's control, and data should point
20852056 to an n_embd x n_layers buffer starting from layer 1.
20862057 il_start and il_end are the layer range the vector should apply to (both inclusive)
2087- See llama_control_vector_load in common to load a control vector."""
2058+ See llama_control_vector_load in common to load a control vector.
2059+ """
20882060 ...
20892061
20902062
0 commit comments