-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ReFT (LoReFT, NoReFT, DiReFT) (#705)
This PR integrates multiple ReFT variants as new adapter methods. Paper: https://arxiv.org/pdf/2404.03592 Original code: https://github.com/stanfordnlp/pyreft ## Changes - Add ReFT module implementation via `ReftLayer`, integrated into all models supported by Adapters. Integration via `init_reft()` method & Pytorch hook. - Add new `ReftConfig` as base config class with three default instances: `LoReftConfig`, `NoReftConfig` and `DiReftConfig`. - Method documentation can be found here: https://github.com/adapter-hub/adapters/blob/6c19ea06c143621a735226e477bf772068e55be3/docs/methods.md#reft ## Compatibility Tested that Pyreft & Adapters produce the same outputs on inference by converting Pyreft checkpoints to Adapters checkpoints (tested settings: LoReft, NoReft, DiReft, weight tying, prefix, suffix, rank, mostly using roberta-base). Script for testing & checkpoint conversion here: https://github.com/calpt/pyreft/blob/main/compatibility.py. ## Evaluation Roberta-base with LoReFT on GLUE, using hyperparameters similar to the paper: Task | Score --- | --- Cola (Matthews Corr.) | 53.95 MNLI (Acc.) | 83.23 MRPC (F1) | 91.70 QNLI (Acc.) | 90.94 QQP (Acc.) | 86.82 RTE (Acc.) | 76.53 SST-2 (Acc.) | 93.81 STS-B (Spearmanr) | 88.99 ## Todos - [x] Modeling implementations - [x] Add test methods - [x] Make all checks passing - [x] Add documentation - [x] Make sure implementation produces same outputs as original code - [x] Sanity check training runs
- Loading branch information
Showing
39 changed files
with
616 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.