Skip to main content

A Unified Library for Parameter-Efficient and Modular Transfer Learning

Project description

adapters Library

This branch contains the development version of adapters, the next-generation library for parameter-efficient and modular transfer learning.

Note: For the stable version of adapter-transformers, please switch to the master branch of the repo.

Changes compared to adapter-transformers

  • adapters is a standalone package, using transformers as an external dependency but not patching it directly
  • All adapter-related classes now are imported via adapters namespace, e.g.:
    from adapters import BertAdapterModel
    # ...
    
  • Built-in HF model classes can be adapted for usage with adapters via a wrapper method, e.g.:
    import adapters
    from transformers import BertModel
    
    model = BertModel.from_pretrained("bert-base-uncased")
    adapters.init(model)
    

Features not (yet) working:

  • Loading model + adapter checkpoints using HF classes
  • Using Transformers pipelines with adapters
  • Using HF language modeling classes with invertible adapters

Documentation

To read the documentation of Adapters, follow the steps in docs/README.md. Currently, the documentation is not yet available from https://docs.adapterhub.ml/.


Adapters

A Unified Library for Parameter-Efficient and Modular Transfer Learning

Tests GitHub PyPI

adapters is an add-on to HuggingFace's Transformers library, integrating adapters into state-of-the-art language models by incorporating AdapterHub, a central repository for pre-trained adapter modules.

Installation

adapters currently supports Python 3.8+ and PyTorch 1.10+. After installing PyTorch, you can install adapters from PyPI ...

pip install -U adapters

... or from source by cloning the repository:

git clone https://github.com/adapter-hub/adapter-transformers.git
git checkout adapters
cd adapters
pip install .

Getting Started

HuggingFace's great documentation on getting started with Transformers can be found here. adapters is fully compatible with Transformers.

To get started with adapters, refer to these locations:

  • Colab notebook tutorials, a series notebooks providing an introduction to all the main concepts of (adapter-)transformers and AdapterHub
  • https://docs.adapterhub.ml, our documentation on training and using adapters with adapters
  • https://adapterhub.ml to explore available pre-trained adapter modules and share your own adapters
  • Examples folder of this repository containing HuggingFace's example training scripts, many adapted for training adapters

Implemented Methods

Currently, adapters integrates all architectures and methods listed below:

Method Paper(s) Quick Links
Bottleneck adapters Houlsby et al. (2019)
Bapna and Firat (2019)
Quickstart, Notebook
AdapterFusion Pfeiffer et al. (2021) Docs: Training, Notebook
MAD-X,
Invertible adapters
Pfeiffer et al. (2020) Notebook
AdapterDrop Rücklé et al. (2021) Notebook
MAD-X 2.0,
Embedding training
Pfeiffer et al. (2021) Docs: Embeddings, Notebook
Prefix Tuning Li and Liang (2021) Docs
Parallel adapters,
Mix-and-Match adapters
He et al. (2021) Docs
Compacter Mahabadi et al. (2021) Docs
LoRA Hu et al. (2021) Docs
(IA)^3 Liu et al. (2022) Docs
UniPELT Mao et al. (2022) Docs

Supported Models

We currently support the PyTorch versions of all models listed on the Model Overview page in our documentation.

Citation

If you use this library for your work, please consider citing our paper AdapterHub: A Framework for Adapting Transformers:

@inproceedings{pfeiffer2020AdapterHub,
    title={AdapterHub: A Framework for Adapting Transformers},
    author={Pfeiffer, Jonas and
            R{\"u}ckl{\'e}, Andreas and
            Poth, Clifton and
            Kamath, Aishwarya and
            Vuli{\'c}, Ivan and
            Ruder, Sebastian and
            Cho, Kyunghyun and
            Gurevych, Iryna},
    booktitle={Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations},
    pages={46--54},
    year={2020}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adapters-0.0.0.dev20231111.tar.gz (149.2 kB view details)

Uploaded Source

Built Distribution

adapters-0.0.0.dev20231111-py3-none-any.whl (242.4 kB view details)

Uploaded Python 3

File details

Details for the file adapters-0.0.0.dev20231111.tar.gz.

File metadata

  • Download URL: adapters-0.0.0.dev20231111.tar.gz
  • Upload date:
  • Size: 149.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.23.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.6.8

File hashes

Hashes for adapters-0.0.0.dev20231111.tar.gz
Algorithm Hash digest
SHA256 d7915cb0281a7bd1f1da065583715422102a4a150ffa8da6e0564824aa710105
MD5 10d7c9e988285fd097f15623ce45b0bc
BLAKE2b-256 8ce4b5c14e3fa203c6d3fd34df8988240e22389fc6fa7006c0a4d3ab35107a73

See more details on using hashes here.

File details

Details for the file adapters-0.0.0.dev20231111-py3-none-any.whl.

File metadata

  • Download URL: adapters-0.0.0.dev20231111-py3-none-any.whl
  • Upload date:
  • Size: 242.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.23.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.6.8

File hashes

Hashes for adapters-0.0.0.dev20231111-py3-none-any.whl
Algorithm Hash digest
SHA256 d2742220e3920aae5af687f3df190061d8d3b8b94277a37c89ea7bac4fbc5dfd
MD5 50ffeb41d26eb3bb08e65ddc6cab005f
BLAKE2b-256 0d12cd072223d15ab24645a59386a7ebad105aba61bed8731c5e7d2eaf514aa2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page