Skip to content

Commit

Permalink
Add support for AdapterPlus (#746)
Browse files Browse the repository at this point in the history
This PR aims to add support for AdapterPlus

Github: https://github.com/visinf/adapter_plus
Paper: https://arxiv.org/pdf/2406.06820

Integration of AdapterPlus into the `adapters` library will involve
adding new parameters/options to the `BnConfig`

Checklist of things that are added/to be added

1. New type of `scaling` called `channel`, in which we add learnable
parameters for the channel/input_size dimension
2. New type of `init_weights` called `houlsby`, where the projection
matrices $W_{down}$ and $W_{up}$ will be initialized with zero-centered
Gaussian with a standard deviation of $10^{-2}$ truncated at 2 standard
deviations, and zeros for bias
3. Support for `drop_path`, also known as stochastic depth **ONLY**
applicable for vision based tasks using residual networks - located
under a new file called `/methods/vision.py`
  • Loading branch information
julian-fong authored Nov 25, 2024
1 parent bf684ad commit ec4a59e
Show file tree
Hide file tree
Showing 9 changed files with 591 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests_torch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Install
run: |
pip install torch==2.3
pip install .[sklearn,testing,sentencepiece]
pip install .[sklearn,testing,sentencepiece,torchvision]
- name: Test
run: |
make test-adapter-methods
Expand All @@ -86,7 +86,7 @@ jobs:
- name: Install
run: |
pip install torch==2.3
pip install .[sklearn,testing,sentencepiece]
pip install .[sklearn,testing,sentencepiece,torchvision]
- name: Test
run: |
make test-adapter-models
Expand All @@ -109,7 +109,7 @@ jobs:
- name: Install
run: |
pip install torch==2.3
pip install .[sklearn,testing,sentencepiece]
pip install .[sklearn,testing,sentencepiece,torchvision]
pip install conllu seqeval
- name: Test Examples
run: |
Expand Down
3 changes: 3 additions & 0 deletions docs/classes/adapter_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ Single (bottleneck) adapters
.. autoclass:: adapters.CompacterPlusPlusConfig
:members:

.. autoclass:: adapters.AdapterPlusConfig
:members:

Prefix Tuning
~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
3 changes: 2 additions & 1 deletion docs/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ A visualization of further configuration options related to the adapter structur
- [`DoubleSeqBnConfig`](adapters.DoubleSeqBnConfig), as proposed by [Houlsby et al. (2019)](https://arxiv.org/pdf/1902.00751.pdf) places adapter layers after both the multi-head attention and feed-forward block in each Transformer layer.
- [`SeqBnConfig`](adapters.SeqBnConfig), as proposed by [Pfeiffer et al. (2020)](https://arxiv.org/pdf/2005.00052.pdf) places an adapter layer only after the feed-forward block in each Transformer layer.
- [`ParBnConfig`](adapters.ParBnConfig), as proposed by [He et al. (2021)](https://arxiv.org/pdf/2110.04366.pdf) places adapter layers in parallel to the original Transformer layers.

- [`AdapterPlusConfig`](adapters.AdapterPlusConfig), as proposed by [Steitz and Roth (2024)](https://arxiv.org/pdf/2406.06820) places adapter layers adapter layers after the multi-head attention and has channel wise scaling and houlsby weight initialization
_Example_:
```python
from adapters import BnConfig
Expand All @@ -56,6 +56,7 @@ _Papers:_
* [Parameter-Efficient Transfer Learning for NLP](https://arxiv.org/pdf/1902.00751.pdf) (Houlsby et al., 2019)
* [Simple, Scalable Adaptation for Neural Machine Translation](https://arxiv.org/pdf/1909.08478.pdf) (Bapna and Firat, 2019)
* [AdapterFusion: Non-Destructive Task Composition for Transfer Learning](https://aclanthology.org/2021.eacl-main.39.pdf) (Pfeiffer et al., 2021)
* [Adapters Strike Back](https://arxiv.org/pdf/2406.06820) (Steitz and Roth., 2024)
* [AdapterHub: A Framework for Adapting Transformers](https://arxiv.org/pdf/2007.07779.pdf) (Pfeiffer et al., 2020)

## Language Adapters - Invertible Adapters
Expand Down
1 change: 1 addition & 0 deletions notebooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ As adapters is fully compatible with HuggingFace's Transformers, you can also us
| [NER on Wikiann](https://github.com/Adapter-Hub/adapters/blob/main/notebooks/08_NER_Wikiann.ipynb) | Evaluating adapters on NER on the wikiann dataset | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Adapter-Hub/adapters/blob/main/notebooks/08_NER_Wikiann.ipynb) |
| [Finetuning Whisper with Adapters](https://github.com/Adapter-Hub/adapters/blob/main/notebooks/Adapter_Whisper_Audio_FineTuning.ipynb) | Fine Tuning Whisper using LoRA | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Adapter-Hub/adapters/blob/main/notebooks/Adapter_Whisper_Audio_FineTuning.ipynb) |
| [Adapter Training with ReFT](https://github.com/Adapter-Hub/adapters/blob/main/notebooks/ReFT_Adapters_Finetuning.ipynb) | Fine Tuning using ReFT Adapters | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Adapter-Hub/adapters/blob/main/notebooks/ReFT_Adapters_Finetuning.ipynb) |
| [ViT Fine-Tuning with AdapterPlus](https://github.com/Adapter-Hub/adapters/blob/main/notebooks/ViT_AdapterPlus_FineTuning.ipynb) | ViT Fine-Tuning with AdapterPlus | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Adapter-Hub/adapters/blob/main/notebooks/ViT_AdapterPlus_FineTuning.ipynb) |
Loading

0 comments on commit ec4a59e

Please sign in to comment.