Skip to content
data

MontecloraConfig

MontecloraConfig(num_samples: int = 8, use_entropy: bool = False, dirichlet_prior: float = 0.1, sample_scaler: float = 0.0001, kl_loss_weight: float = 1e-05, buffer_size: int = 150)

Options of MonteCLoRA, which averages the LoRA update over Monte Carlo samples.

MonteCLoRA draws num_samples perturbed copies of the low-rank update per forward pass and mixes them with Dirichlet-sampled expert weights, so the adapter is trained as a variational posterior rather than a point estimate; kl_loss_weight and use_entropy regularise it. LoraConfig(monteclora_config=...) is refused: the extension is not implemented.

Parameters

num_samplesint= 8
Monte Carlo samples drawn per forward pass; positive.
use_entropybool= False
Add an entropy term that keeps the sampled weights from collapsing onto one sample.
dirichlet_priorfloat= 0.1
Concentration of the Dirichlet prior the expert weights are sampled from; positive.
sample_scalerfloat= 1e-4
Scale of the perturbation each sample adds.
kl_loss_weightfloat= 1e-5
Weight of the KL-divergence term of the variational objective.
buffer_sizeint= 150
Size of the sampler's buffer; positive.

Raises

ValueError
num_samples, dirichlet_prior or buffer_size is not positive.

Examples

>>> from lucid.peft import MontecloraConfig
>>> config = MontecloraConfig(num_samples=4)
>>> config.num_samples, config.buffer_size
(4, 150)

Used by 2