Skip to content

Add LORA support to TRLX #80

@ethankim00

Description

@ethankim00

🚀 The feature, motivation, and pitch

LORA and other parameter-efficient methods can provide a number of advantages when finetuning large language models. These methods typically only update a small fraction of the model parameters during finetuning. For example, LORA only trains low-rank reparameterizations of weight matrices during training reducing parameter cost up to 10000 times.

Key Advantages:

  • Reduced storage cost and ability to switch out different adapters for different tasks
  • Increased training efficiency and reduced memory requirements since fewer optimizer states need to be tracked

Alternatives

No response

Additional context

The OpenDelta library provides support for LORA and other "delta methods"

model =  AutoModelForCausalLM.from_pretrained(model_base)
from opendelta import LoraModel
delta_model = LoraModel(backbone_model=model, modified_modules=['fc2'])
delta_model.freeze_module(exclude=["deltas", "layernorm_embedding"], set_state_dict=True)
# save only  trained parameters
delta_model.save_finetuned(save_path)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions