QLoRA Support:
QLoRA uses 4-bit quantization to compress a pretrained language model. The LM parameters are then frozen and a relatively small number of trainable parameters are added to the model in the form of Low-Rank Adapters. During finetuning, QLoRA backpropagates gradients through the frozen 4-bit quantized pretrained language model into the Low-Rank Adapters. The LoRA layers are the only parameters being updated during training. For more details read the blog Making LLMs even more accessible with bitsandbytes, 4-bit quantization and QLoRA
- 4-bit QLoRA via bitsandbytes (4-bit base model + LoRA) by @TimDettmers in #476
- [
core
] Protect 4bit import by @younesbelkada in #480 - [
core
] Raise warning on usingprepare_model_for_int8_training
by @younesbelkada in #483
New PEFT methods: IA3 from T-Few paper
To make fine-tuning more efficient, IA3 (Infused Adapter by Inhibiting and Amplifying Inner Activations) rescales inner activations with learned vectors. These learned vectors are injected into the attention and feedforward modules in a typical transformer-based architecture. These learned vectors are the only trainable parameters during fine-tuning, and thus the original weights remain frozen. Dealing with learned vectors (as opposed to learned low-rank updates to a weight matrix like LoRA) keeps the number of trainable parameters much smaller. For more details, read the paper Few-Shot Parameter-Efficient Fine-Tuning is Better and Cheaper than In-Context Learning
- Add functionality to support IA3 by @SumanthRH in #578
Support for new tasks: QA and Feature Extraction
Addition of PeftModelForQuestionAnswering
and PeftModelForFeatureExtraction
classes to support QA and Feature Extraction tasks, respectively. This enables exciting new use-cases with PEFT, e.g., LoRA for semantic similarity tasks.
- feat: Add PeftModelForQuestionAnswering by @sjrl in #473
- add support for Feature Extraction using PEFT by @pacman100 in #647
AutoPeftModelForxxx for better and Simplified UX
Introduces a new paradigm, AutoPeftModelForxxx intended for users that want to rapidly load and run peft models.
from peft import AutoPeftModelForCausalLM
peft_model = AutoPeftModelForCausalLM.from_pretrained("ybelkada/opt-350m-lora")
- Introducing
AutoPeftModelForxxx
by @younesbelkada in #694
LoRA for custom models
Not a transformer model, no problem, we have got you covered. PEFT now enables the usage of LoRA with custom models.
- FEAT: Make LoRA work with custom models by @BenjaminBossan in #676
New LoRA utilities
Improvements to add_weighted_adapter
method to support SVD for combining multiple LoRAs when creating new LoRA.
New utils such as unload
and delete_adapter
providing users much better control about how they deal with the adapters.
- [Core] Enhancements and refactoring of LoRA method by @pacman100 in #695
PEFT and Stable Diffusion
PEFT is very extensible and easy to use for performing DreamBooth of Stable Diffusion. Community has added conversion scripts to be able to use PEFT models with Civitai/webui format and vice-versa.
- LoRA for Conv2d layer, script to convert kohya_ss LoRA to PEFT by @kovalexal in #461
- Added Civitai LoRAs conversion to PEFT, PEFT LoRAs conversion to webui by @kovalexal in #596
- [Bugfix] Fixed LoRA conv2d merge by @kovalexal in #637
- Fixed LoraConfig alpha modification on add_weighted_adapter by @kovalexal in #654
What's Changed
- Release: v0.4.0.dev0 by @pacman100 in #391
- do not use self.device. In FSDP cpu offload mode. self.device is "CPU… by @sywangyi in #352
- add accelerate example for DDP and FSDP in sequence classification fo… by @sywangyi in #358
- [
CI
] Fix CI - pin urlib by @younesbelkada in #402 - [docs] Fix index by @stevhliu in #397
- Fix documentation links on index page by @mikeorzel in #406
- Zero 3 init ReadME update by @dumpmemory in #399
- [
Tests
] Add soundfile to docker images by @younesbelkada in #401 - 4-bit QLoRA via bitsandbytes (4-bit base model + LoRA) by @TimDettmers in #476
- [
core
] Protect 4bit import by @younesbelkada in #480 - [
core
] Raise warning on usingprepare_model_for_int8_training
by @younesbelkada in #483 - Remove merge_weights by @Atry in #392
- [
core
] Add gradient checkpointing check by @younesbelkada in #404 - [docs] Fix LoRA image classification docs by @stevhliu in #524
- [docs] Prettify index by @stevhliu in #478
- change comment in tuners.lora, lora_alpha float to int by @codingchild2424 in #448
- [
LoRA
] Allow applying LoRA at different stages by @younesbelkada in #429 - Enable PeftConfig & PeftModel to load from revision by @lewtun in #433
- [
Llama-Adapter
] fix half precision inference + add tests by @younesbelkada in #456 - fix merge_and_unload when LoRA targets embedding layer by @0x000011b in #438
- return load_result when load_adapter by @dkqkxx in #481
- Fixed problem with duplicate same code. by @hotchpotch in #517
- Add starcoder model to target modules dict by @mrm8488 in #528
- Fix a minor typo where a non-default token_dim would crash prompt tuning by @thomas-schillaci in #459
- Remove device_map when training 4,8-bit model. by @SunMarc in #534
- add library name to model card by @pacman100 in #549
- Add thousands separator in print_trainable_parameters by @BramVanroy in #443
- [doc build] Use secrets by @mishig25 in #556
- improve readability of LoRA code by @martin-liu in #409
- [
core
] Add safetensors integration by @younesbelkada in #553 - [
core
] Fix config kwargs by @younesbelkada in #561 - Fix typo and url to
openai/whisper-large-v2
by @alvarobartt in #563 - feat: add type hint to
get_peft_model
by @samsja in #566 - Add issues template by @younesbelkada in #562
- [BugFix] Set alpha and dropout defaults in LoraConfig by @apbard in #390
- enable lora for mpt by @sywangyi in #576
- Fix minor typo in bug-report.yml by @younesbelkada in #582
- [
core
] Correctly passing the kwargs all over the place by @younesbelkada in #575 - Fix adalora device mismatch issue by @younesbelkada in #583
- LoRA for Conv2d layer, script to convert kohya_ss LoRA to PEFT by @kovalexal in #461
- Fix typo at peft_model.py by @Beomi in #588
- [
test
] Adds more CI tests by @younesbelkada in #586 - when from_pretrained is called in finetune case of lora with flag "… by @sywangyi in #591
- feat: Add PeftModelForQuestionAnswering by @sjrl in #473
- Improve the README when using PEFT by @pacman100 in #594
- [
tests
] Fix dockerfile by @younesbelkada in #608 - Fix final failing slow tests by @younesbelkada in #609
- [
core
] Addadapter_name
inget_peft_model
by @younesbelkada in #610 - [
core
] Stronger import of bnb by @younesbelkada in #605 - Added Civitai LoRAs conversion to PEFT, PEFT LoRAs conversion to webui by @kovalexal in #596
- update whisper test by @pacman100 in #617
- Update README.md, citation by @pminervini in #616
- Update train_dreambooth.py by @nafiturgut in #624
- [
Adalora
] Add adalora 4bit by @younesbelkada in #598 - [
AdaptionPrompt
] Add 8bit + 4bit support for adaption prompt by @younesbelkada in #604 - Add seq2seq prompt tuning support by @thomas-schillaci in #519
- [Bugfix] Fixed LoRA conv2d merge by @kovalexal in #637
- [Bugfix] Inserted adapter_name to get_peft_model_state_dict function by @nafiturgut in #626
- fix Prefix-tuning error in clm Float16 evaluation by @sywangyi in #520
- fix ptun and prompt tuning generation issue by @sywangyi in #543
- feat(model): Allow from_pretrained to accept PeftConfig class by @aarnphm in #612
- Fix
PeftModel.disable_adapter
by @ain-soph in #644 - bitsandbytes version check by @glerzing in #646
- DOC: Remove loralib requirements from examples, a few small fixes by @BenjaminBossan in #640
- style: tentatively add hints for some public function by @aarnphm in #614
- Add pytest-cov for reporting test coverage by @BenjaminBossan in #641
- Require Python version >= 3.8 by @BenjaminBossan in #649
- Fixed LoraConfig alpha modification on add_weighted_adapter by @kovalexal in #654
- [docs] API example by @stevhliu in #650
- FIX: bug resulting in config copies not working by @BenjaminBossan in #653
- Update clm-prompt-tuning.mdx by @richard087 in #652
- Adding support for RoBERTa layers_transform in COMMON_LAYERS_PATTERN by @sunyuhan19981208 in #669
- TST: Remove skipping certain tests by @BenjaminBossan in #668
- Added wandb support for lora train_dreambooth by @nafiturgut in #639
- FIX: Embedding LoRA weights are initialized randomly by @BenjaminBossan in #681
- Fix broken docker images by @younesbelkada in #684
- Add functionality to support IA3 by @SumanthRH in #578
- Fix base_model_torch_dtype when using model.half() after init by @rayrayraykk in #688
- Init IA³ weights randomly when so configured by @BenjaminBossan in #693
- add support for Feature Extraction using PEFT by @pacman100 in #647
- Fix a small bug in forward method of IA³ by @BenjaminBossan in #696
- Update Readme to include IA3 by @SumanthRH in #702
- Fix code typo in int8-asr.mdx by @zsamboki in #698
- chore(type): annotate that peft does contains type hints by @aarnphm in #678
- Introducing
AutoPeftModelForxxx
by @younesbelkada in #694 - [WIP] FIX for disabling adapter, adding tests by @BenjaminBossan in #683
- [Core] Enhancements and refactoring of LoRA method by @pacman100 in #695
- [
Feature
] Save only selected adapters for LoRA by @younesbelkada in #705 - [
Auto
] SupportAutoPeftModel
for custom HF models by @younesbelkada in #707 - FEAT: Make LoRA work with custom models by @BenjaminBossan in #676
- [
core
] Better hub kwargs management by @younesbelkada in #712 - FIX: Removes warnings about unknown pytest marker by @BenjaminBossan in #715
New Contributors
- @sywangyi made their first contribution in #352
- @mikeorzel made their first contribution in #406
- @TimDettmers made their first contribution in #476
- @Atry made their first contribution in #392
- @codingchild2424 made their first contribution in #448
- @lewtun made their first contribution in #433
- @0x000011b made their first contribution in #438
- @dkqkxx made their first contribution in #481
- @hotchpotch made their first contribution in #517
- @thomas-schillaci made their first contribution in #459
- @SunMarc made their first contribution in #534
- @BramVanroy made their first contribution in #443
- @mishig25 made their first contribution in #556
- @martin-liu made their first contribution in #409
- @alvarobartt made their first contribution in #563
- @samsja made their first contribution in #566
- @apbard made their first contribution in #390
- @kovalexal made their first contribution in #461
- @Beomi made their first contribution in #588
- @sjrl made their first contribution in #473
- @pminervini made their first contribution in #616
- @nafiturgut made their first contribution in #624
- @aarnphm made their first contribution in #612
- @ain-soph made their first contribution in #644
- @glerzing made their first contribution in #646
- @BenjaminBossan made their first contribution in #640
- @richard087 made their first contribution in #652
- @sunyuhan19981208 made their first contribution in #669
- @SumanthRH made their first contribution in #578
- @rayrayraykk made their first contribution in #688
- @zsamboki made their first contribution in #698
Full Changelog: v0.3.0...v0.4.0
Significant community contributions
The following contributors have made significant changes to the library over the last release:
- 4-bit QLoRA via bitsandbytes (4-bit base model + LoRA) by @TimDettmers in #476
- Add functionality to support IA3 by @SumanthRH in #578
- LoRA for Conv2d layer, script to convert kohya_ss LoRA to PEFT by @kovalexal in #461
- Added Civitai LoRAs conversion to PEFT, PEFT LoRAs conversion to webui by @kovalexal in #596
- [Bugfix] Fixed LoRA conv2d merge by @kovalexal in #637
- Fixed LoraConfig alpha modification on add_weighted_adapter by @kovalexal in #654
- do not use self.device. In FSDP cpu offload mode. self.device is "CPU… by @sywangyi in #352
- add accelerate example for DDP and FSDP in sequence classification fo… by @sywangyi in #358
- enable lora for mpt by @sywangyi in #576
- fix Prefix-tuning error in clm Float16 evaluation by @sywangyi in #520
- fix ptun and prompt tuning generation issue by @sywangyi in #543
- when from_pretrained is called in finetune case of lora with flag "… by @sywangyi in #591
- feat(model): Allow from_pretrained to accept PeftConfig class by @aarnphm in #612
- style: tentatively add hints for some public function by @aarnphm in #614
- chore(type): annotate that peft does contains type hints by @aarnphm in #678
- improve readability of LoRA code by @martin-liu in #409
- Add seq2seq prompt tuning support by @thomas-schillaci in #519