OFT
5 memberslucid.peft.tuners.oftlucid.peft.tuners.oft — OFT: a learned rotation of each layer's input space.
OFT (Qiu et al., 2023, arXiv:2306.07280 — Orthogonal Finetuning) leaves the weight's spectrum alone and rotates its input space instead, , with block-diagonal and each block an orthogonal matrix built by a Cayley transform of a learned skew-symmetric matrix. The rotation preserves the pairwise angles between the weight's neurons, which the paper found to keep a pretrained model's behaviour intact while it is steered. It starts as the identity and folds into the weight. Pick it when the pretrained weight's geometry should survive the fine-tune (the paper tuned text-to-image diffusion models); BOFT and HRA are the same idea parameterised otherwise.
Where the reference library keeps them, so isinstance(m, OFTLayer) and from lucid.peft.tuners.oft import OFTConfig, Linear read as they do there. One layer type per module
the method adapts: Linear and Conv2d. OFTConfig and OFTModel are here and exported
from lucid.peft. Importing the package registers the method (its config under PeftType.OFT,
its tuner and layers), which is what makes get_peft_model and PeftModel.from_pretrained know
it.
Qiu, Zeju, et al. "Controlling Text-to-Image Diffusion by Orthogonal Finetuning." [arXiv:2306.07280](https://arxiv.org/abs/2306.07280), 2023.
OFT (Qiu et al., 2023, arXiv:2306.07280 — Orthogonal Finetuning) rotates the input space of each targeted layer instead of adding to its weight: with block-diagonal, each block an orthogonal matrix of a learned skew-symmetric . A rotation keeps the pairwise angles between the weight's neurons, which is what OFT tunes while the weight's spectrum stays. The s start at zero, so the adapted model starts as the base; the rotation folds into the weight, so a merged model costs what the base does.
Classes
OFTConfig9 methodsHow lucid.peft.get_peft_model adapts a model with OFT.
Conv2dAn nn.Conv2d with an OFT rotation of its flattened in x kernel axis: the convolution runs with the rotated filters.
LinearAn nn.Linear with an OFT rotation of its input: .
OFTLayer20 methodsAdapter bookkeeping and the rotation shared by the OFT layers.
OFTModel15 methodsA model with OFT layers in it, and the tools to take them out again.