Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Huggingface Peft BoneModel

From Leeroopedia
Revision as of 15:10, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Huggingface_Peft_BoneModel.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Deep_Learning, Parameter_Efficient_Finetuning
Last Updated 2026-02-07 14:00 GMT

Overview

Concrete tool for applying Bone (Block Affine) adaptation to pretrained models, provided by the Huggingface PEFT library.

Description

BoneModel is a tuner class that creates a Bone adaptation model from a pretrained transformers model. It injects trainable low-rank block affine transformations into target Linear layers. The method belongs to the family of orthogonal/structured adaptation approaches and is described in https://huggingface.co/papers/2409.15371.

Usage

BoneModel is typically created internally by calling get_peft_model with a BoneConfig. It can also be instantiated directly by passing a base model, a BoneConfig, and an adapter name.

Code Reference

Source Location

Signature

class BoneModel(BaseTuner):
    prefix: str = "bone_"
    # Inherits __init__ from BaseTuner:
    # def __init__(self, model, config, adapter_name):
    #     ...

Import

from peft.tuners.bone import BoneModel

I/O Contract

Inputs

Name Type Required Description
model nn.Module Yes The pretrained model to adapt
config BoneConfig Yes Configuration for the Bone adapter (rank r, init_weights)
adapter_name str Yes Name identifier for the adapter, defaults to "default"

Outputs

Name Type Description
adapted_model BoneModel Model with Bone adapter layers injected into target Linear modules

Usage Examples

Basic Usage

from peft import get_peft_model, BoneConfig
from transformers import AutoModelForCausalLM

model = AutoModelForCausalLM.from_pretrained("model-name")
config = BoneConfig(
    r=8,
    target_modules=["k_proj", "q_proj", "v_proj", "out_proj", "fc1", "fc2"],
    init_weights=True,
)
model = get_peft_model(model, config)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment