Skip to content

Full Fine-Tuning

About

The d9d.peft.full_tune package brings standard fine-tuning into the PEFT workflow. It does not change the model architecture. It unfreezes all parameters of the modules whose names fully match a regular expression, e.g. normalization layers or a specific head. Full fine-tuning is most useful together with other PEFT methods through Method Stacking. For example, you can apply LoRA to attention layers and fully fine-tune the normalization layers.

Usage

import re
from d9d.peft import inject_peft_and_freeze
from d9d.peft.full_tune import FullTune, FullTuneConfig

model = ...  # Your model.

method = FullTune(FullTuneConfig(module_name_pattern=re.compile(r".*norm.*")))

# Freezes every parameter except those of modules named like "...norm...".
# Full fine-tuning keeps the state keys, so the returned mapper is empty.
inject_peft_and_freeze(method, model)

API Reference

d9d.peft.full_tune

Full fine-tuning of selected modules within the PEFT framework.

FullTune

Bases: PeftMethod[FullTuneConfig]

PEFT method for full fine-tuning.

It injects no adapters. It marks all parameters of the matching modules as trainable.

__init__(config)

Constructs the FullTune object.

Parameters:

Name Type Description Default
config FullTuneConfig

Configuration with the module name pattern to fine-tune.

required

FullTuneConfig

Bases: BaseModel

Configuration for full fine-tuning of the modules that match a regular expression.

Attributes:

Name Type Description
kind Literal['full_tune']

Discriminator field. Always "full_tune".

module_name_pattern Pattern

Regular expression that must fully match the names of modules to unfreeze.