Implementation:Huggingface Peft BoneConfig
| Knowledge Sources | |
|---|---|
| Domains | Deep_Learning, Parameter_Efficient_Finetuning |
| Last Updated | 2026-02-07 14:00 GMT |
Overview
Concrete configuration dataclass for the Bone PEFT adapter method provided by the Huggingface PEFT library.
Description
BoneConfig controls the hyperparameters for the Bone adapter, a parameter-efficient fine-tuning method that applies low-rank updates to selected model layers. It supports two initialization variants: the default Bone structure and the "bat" variant. This class extends PeftConfig. Note: Bone is deprecated and will be removed in PEFT v0.19.0 in favor of MissConfig.
Usage
Import and use BoneConfig when you want to apply the Bone adapter method for parameter-efficient fine-tuning, particularly for scenarios requiring low-rank weight updates with configurable rank and layer targeting. Consider using MissConfig instead for new projects.
Code Reference
Source Location
- Repository: Huggingface_Peft
- File: src/peft/tuners/bone/config.py
- Lines: 25-130
Signature
@dataclass
class BoneConfig(PeftConfig):
r: int = 64
target_modules: Optional[Union[list[str], str]] = None
exclude_modules: Optional[Union[list[str], str]] = None
init_weights: bool | Literal["bat"] = True
layers_to_transform: Optional[Union[list[int], int]] = None
layers_pattern: Optional[str] = None
bias: str = "none"
modules_to_save: Optional[list[str]] = None
Import
from peft import BoneConfig
I/O Contract
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| r | int | 64 | Rank of the Bone adapter. Best set to an even number for default initialization. |
| target_modules | Optional[Union[list[str], str]] | None | Module names or regex to apply adapter to. |
| exclude_modules | Optional[Union[list[str], str]] | None | Module names or regex to exclude from adapter. |
| init_weights | bool or Literal["bat"] | True | Initialization variant: True for Bone structure, "bat" for Bat structure. |
| layers_to_transform | Optional[Union[list[int], int]] | None | Specific layer indexes to apply transformations to. |
| layers_pattern | Optional[str] | None | Layer pattern name when layers_to_transform is set. |
| bias | str | "none" | Bias type. Can be 'none', 'all', or 'bone_only'. |
| modules_to_save | Optional[list[str]] | None | Additional modules to set as trainable and save in the final checkpoint. |
Outputs
| Name | Type | Description |
|---|---|---|
| instance | BoneConfig | Configuration object to pass to get_peft_model |
Usage Examples
Basic Configuration
from peft import BoneConfig, get_peft_model
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("model-name")
config = BoneConfig(
r=64,
target_modules=["q_proj", "v_proj"],
)
model = get_peft_model(model, config)