Poly
4 memberslucid.peft.tuners.polylucid.peft.tuners.poly — Poly and Multi-Head Routing: low-rank skills mixed per task by a learned router.
Polytropon (Ponti et al., 2022, arXiv:2202.13914) gives every adapted linear layer n_skills
low-rank adapters and a router with one learned logit vector per task. A batch row's update is the
mixture of the skills its task's logits weight, with
and likewise . Multi-Head Routing (Caccia et al., 2022,
arXiv:2211.03831) routes each of n_splits blocks of the features separately. The router logits
start near zero, so every skill is mixed equally, and starts at zero, so the adapted model
starts as the base. Pick it for multitask fine-tuning where tasks should share some skills and a
new task can be learned by routing alone; each call names its tasks (task_ids).
The update depends on the task of each row, so it does not fold into the weights and nothing merges.
The layer type is Linear (an nn.Linear); PolyConfig and PolyModel are here and
exported from lucid.peft. Importing the package registers the method under PeftType.POLY.
Ponti, Edoardo M., et al. "Combining Modular Skills in Multitask Learning." [arXiv:2202.13914](https://arxiv.org/abs/2202.13914), 2022.
Polytropon (Ponti et al., 2022, arXiv:2202.13914) gives each targeted layer n_skills
low-rank adapters (skills) and a router that holds one learned logit vector per task; the
layer's update for a task is the router-weighted mixture of the skills,
. Multi-Head Routing
(Caccia et al., 2022, arXiv:2211.03831) splits every skill into n_splits blocks along the
feature axis, each routed on its own: n_splits > 1. The weights are the
sigmoid of the task's logits, normalised to sum to one — in training a relaxed Bernoulli
sample of them instead, which makes the routing stochastic.
Classes
PolyConfig9 methodsHow lucid.peft.get_peft_model adapts a model with Poly (multi-skill LoRA with a task router).
LinearAn nn.Linear with a task-routed mixture of low-rank skills.
PolyLayer21 methodsAdapter bookkeeping shared by the Poly layers.
PolyModel15 methodsA model with Poly layers in it, and the tools to take them out again.