Implementation:Huggingface Peft FourierFTModel
| Knowledge Sources | |
|---|---|
| Domains | Deep_Learning, Parameter_Efficient_Finetuning |
| Last Updated | 2026-02-07 14:00 GMT |
Overview
Concrete tool for applying FourierFT (Fourier Fine-Tuning) to pretrained transformer models, provided by the Huggingface PEFT library.
Description
FourierFTModel is a tuner class that creates a FourierFT model from a pretrained transformers model. It adapts target modules by learning updates in the Fourier frequency domain rather than directly in the weight space, supporting both torch.nn.Linear and Conv1D layers. The method is described in detail in https://huggingface.co/papers/2405.03003.
Usage
FourierFTModel is typically created internally by calling get_peft_model with a FourierFTConfig. It can also be instantiated directly by passing a base model, a FourierFTConfig, and an adapter name.
Code Reference
Source Location
- Repository: Huggingface_Peft
- File: src/peft/tuners/fourierft/model.py
- Lines: 31-129
Signature
class FourierFTModel(BaseTuner):
prefix: str = "fourierft_"
# Inherits __init__ from BaseTuner:
# def __init__(self, model, config, adapter_name):
# ...
Import
from peft.tuners.fourierft import FourierFTModel
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| model | nn.Module | Yes | The pretrained model to adapt |
| config | FourierFTConfig | Yes | Configuration for the FourierFT adapter (n_frequency, scaling, random_loc_seed, etc.) |
| adapter_name | str | Yes | Name identifier for the adapter, defaults to "default" |
Outputs
| Name | Type | Description |
|---|---|---|
| adapted_model | FourierFTModel | Model with FourierFT adapter layers injected into target modules |
Usage Examples
Basic Usage
from peft import get_peft_model, FourierFTConfig
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("model-name")
config = FourierFTConfig(
n_frequency=1000,
target_modules=["q_proj", "v_proj"],
)
model = get_peft_model(model, config)