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= 8Monte Carlo samples drawn per forward pass; positive.
use_ entropybool= FalseAdd an entropy term that keeps the sampled weights from collapsing onto one sample.
dirichlet_ priorfloat= 0.1Concentration of the Dirichlet prior the expert weights are sampled from; positive.
sample_ scalerfloat= 1e-4Scale of the perturbation each sample adds.
kl_ loss_ weightfloat= 1e-5Weight of the KL-divergence term of the variational objective.
buffer_ sizeint= 150Size of the sampler's buffer; positive.
Raises
ValueErrornum_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)