peft

🤗 PEFT: State-of-the-art Parameter-Efficient Fine-Tuning.

What is peft?

🤗 PEFT: State-of-the-art Parameter-Efficient Fine-Tuning.

Overview of peft

What it is

PEFT (Parameter-Efficient Fine-Tuning) is a library that provides state-of-the-art methods for efficiently adapting large pretrained models to downstream tasks. Instead of fine-tuning all model parameters, PEFT methods only update a small number of extra parameters, significantly reducing computational and storage costs while achieving performance comparable to full fine-tuning.

Key features

  • Supports multiple PEFT methods including LoRA, as demonstrated in the Quickstart.
  • Integrates with Transformers for easy model training and inference, allowing addition, loading, and switching of adapters.
  • Integrates with Diffusers for managing different adapters in diffusion models, reducing memory requirements.
  • Integrates with Accelerate for distributed training and inference of large models.
  • Enables fine-tuning of large models on consumer hardware; for example, LoRA reduces GPU memory for a 3B parameter model from 47GB to 14.4GB.
  • Can be combined with quantization (e.g., QLoRA) to further reduce memory requirements.
  • Produces small adapter checkpoints (e.g., 19MB for a 3B model) compared to full model checkpoints (e.g., 11GB).

Use cases

  • Fine-tuning large language models (e.g., bigscience/T0_3B, bigscience/mt0-xxl) on downstream tasks with limited GPU memory.
  • Training Stable Diffusion models with LoRA, reducing GPU memory from 27.5GB to 15.5GB (or 8.12GB with gradient checkpointing).
  • Saving storage by maintaining multiple small adapters for different tasks instead of full model copies.
  • Performing inference with PEFT adapters loaded on top of a base model.
  • Combining PEFT with quantization to fine-tune models on consumer hardware (e.g., Llama-2-7b on a 16GB GPU).

Getting started

Install PEFT from pip:

pip install peft

For full usage examples, including preparing a model with get_peft_model and loading adapters for inference, see the repository README.

License and pricing

The license is Apache-2.0. The project is open source.

Based on the project's public README and repository metadata.

Add this badge to your README

Featured on YunoDB Badge styles & help

Maintain this project? Show that it is featured on YunoDB.

Markdown[![Featured on YunoDB](https://yunodb.com/badge/huggingfacepeft.svg)](https://yunodb.com/tools/huggingfacepeft?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/huggingfacepeft?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/huggingfacepeft.svg" alt="Featured on YunoDB" height="20"></a>