Skip to content
module

PEANuT

4 members
lucid.peft.tuners.peanut

lucid.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, W+f(W;θ)W + f(W;\theta), 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.

Paper

Zhong, Yibo, et al. "PEANuT: Parameter-Efficient Adaptation with Weight-aware Neural Tweakers." [arXiv:2410.01870](https://arxiv.org/abs/2410.01870), 2024.

Overview

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, W′=W+f(W;θ)W' = W + f(W; \theta), where ff is a small trained network, not a fixed low-rank product. At depth zero f(W)=s σ(W⊤A⊤) Bf(W) = s\,\sigma(W^\top A^\top)\,B with A∈Rr×doutA \in \mathbb{R}^{r \times d_{out}} and B∈Rdout×rB \in \mathbb{R}^{d_{out} \times r} (transposed back to the shape of WW); each unit of depth puts an encoder layer r→rr \to r before and a decoder layer after the middle, joined by residuals (appendix F), with the non-linearity act_fn between all of them. BB is zero when training begins, which makes the first update zero too.

Classes