Fine-tuning API#
Registration-time helpers for adapting pretrained models before optimizer construction.
See also
User guide: Fine-Tuning Pretrained Models
Training strategy API: Training strategy API
Training update hooks: Training update hooks
Strategy#
Training strategy for patching modules and selecting trainable parameters. |
|
Start a new fine-tuning run from checkpointed model weights. |
Use FineTuningStrategy.load_checkpoint(...) to resume an interrupted run
with saved optimizer state, scheduler state, counters, and serialized
fine-tuning configuration. Use FineTuningStrategy.from_pretrained_checkpoint(...)
to start a new fine-tuning run whose model weights are initialized from an
existing checkpoint; optimizer state, hooks, and counters do not carry over.
Hooks#
Registration-time hooks that adapt the model tree and optimizer parameter set
before training starts. They do not own backward() or optimizer-step
behavior; use Training update hooks for batch-update policies.
Patch model submodules at registration time. |
|
Select which parameters stay trainable during fine-tuning. |
|
Cache fine-tuning parameter counts after registration hooks run. |
|
Cache model fingerprints before PEFT hooks mutate models. |
ModulePatchHook
Field |
Type |
Description |
|---|---|---|
|
|
Ordered mapping of target paths to replacement modules or specs that build modules. |
|
|
If True, register the patched module parameters as both trainable and managed under the fixed ‘patch’ source. Registered patch parameters are included in the final trainable allow-list by default and are protected from being overridden by other sources modifying the model. |
TrainableParameterHook
Field |
Type |
Description |
|---|---|---|
|
|
Glob patterns for parameters to freeze. Overridden by |
|
|
Glob patterns for parameters to keep trainable. When supplied without |
|
|
Whether excluded parameters are temporarily frozen via |
FineTuningSummaryHook
This class has no configurable fields.
BaseFingerprintHook
This class has no configurable fields.
LoRAHook
Apply LoRA adapters to models. |
Field |
Type |
Description |
|---|---|---|
|
|
LoRA PEFT configuration describing adapter targets, rank, scaling, dropout, MLP wrapping, and custom wrapper registrations. |
|
|
If |
PEFT helpers#
Configuration and utility APIs for parameter-efficient fine-tuning workflows.
LoRA is the only PEFT method currently supported. Pass
peft_config=LoRAConfig(...) to FineTuningStrategy to train LoRA adapters
and use load_peft_checkpoint_into_model(...) to load a trainable-state PEFT
checkpoint into a compatible base model.
Operations and configuration type associated with one PEFT method. |
|
Register all behavior required to use one PEFT method. |
|
Return registered and built-in PEFT method names. |
|
Load PEFT weights from a native checkpoint into a compatible base model. |
ALCHEMI LoRA configuration for |
|
Return registered (layer, LoRA-wrapper) pairs. |