PEANuT
4 memberslucid.peft.tuners.peanutlucid.peft.tuners.peanut — PEANuT: a small non-linear network that reads the frozen weight and tweaks it.
PEANuT (Zhong et al., 2024, arXiv:2410.01870 — later versions of the paper call it Neat) produces
the weight update from the frozen weight itself, , through a small trained
bottleneck network with a non-linearity, not a fixed low-rank product; depth adds encoder and
decoder layers with residuals between its ends. The update reads the weight, so a merge keeps the
weight it was folded into and an unmerge gives it back exactly. Pick it for a non-linear update
that can follow the structure of the weight it adapts, with LoRA-like parameter counts.
Where the reference library keeps them, so isinstance(m, PeanutLayer) and from lucid.peft.tuners.peanut import PeanutConfig, Linear read as they do there. One layer type for
the one module the method adapts, nn.Linear. PeanutConfig and PeanutModel are here and
exported from lucid.peft. Importing the package registers the method (its config under
PeftType.PEANUT, its tuner and layer), which is what makes get_peft_model and
PeftModel.from_pretrained know it.
Zhong, Yibo, et al. "PEANuT: Parameter-Efficient Adaptation with Weight-aware Neural Tweakers." [arXiv:2410.01870](https://arxiv.org/abs/2410.01870), 2024.
PEANuT (Zhong et al., 2024, arXiv:2410.01870, section 3.3; later versions of the paper call it
Neat) writes the update as a function of the frozen weight, , where
is a small trained network, not a fixed low-rank product. At depth zero
with and
(transposed back to the shape of ); each
unit of depth puts an encoder layer before and a decoder layer after the
middle, joined by residuals (appendix F), with the non-linearity act_fn between all of
them. is zero when training begins, which makes the first update zero too.
Classes
PeanutConfig9 methodsHow lucid.peft.get_peft_model adapts a model with PEANuT.
LinearAn nn.Linear with a PEANuT update: .
PeanutLayer20 methodsAdapter bookkeeping and the weight-reading network shared by the PEANuT layers.
PeanutModel15 methodsA model with PEANuT layers in it, and the tools to take them out again.