Skip to content
module

OFT

5 members
lucid.peft.tuners.oft

lucid.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, y=(WR⊤)x+by = (W R^\top) x + b, with RR 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.

Paper

Qiu, Zeju, et al. "Controlling Text-to-Image Diffusion by Orthogonal Finetuning." [arXiv:2306.07280](https://arxiv.org/abs/2306.07280), 2023.

Overview

OFT (Qiu et al., 2023, arXiv:2306.07280 — Orthogonal Finetuning) rotates the input space of each targeted layer instead of adding to its weight: y=(WR⊤)x+by = (W R^\top) x + b with RR block-diagonal, each block an orthogonal matrix (I−Q)(I+Q)−1(I - Q)(I + Q)^{-1} of a learned skew-symmetric QQ. A rotation keeps the pairwise angles between the weight's neurons, which is what OFT tunes while the weight's spectrum stays. The QQs 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