MCPcopy Index your code
hub / github.com/adapter-hub/adapters

github.com/adapter-hub/adapters @adapters3.2.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release adapters3.2.1 ↗ · + Follow
42,274 symbols 166,693 edges 2,075 files 8,279 documented · 20% 4 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

adapter-transformers

A friendly fork of HuggingFace's Transformers, adding Adapters to PyTorch language models

Tests GitHub PyPI

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

💡 Important: This library can be used as a drop-in replacement for HuggingFace Transformers and regularly synchronizes new upstream changes. Thus, most files in this repository are direct copies from the HuggingFace Transformers source, modified only with changes required for the adapter implementations.

Installation

adapter-transformers currently supports Python 3.8+ and PyTorch 1.12.1+. After installing PyTorch, you can install adapter-transformers from PyPI ...

pip install -U adapter-transformers

... or from source by cloning the repository:

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

Getting Started

HuggingFace's great documentation on getting started with Transformers can be found here. adapter-transformers 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 adapter-transformers
  • 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, adapter-transformers 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}
}

Core symbols most depended-on inside this repo

from_pretrained
called by 3028
src/transformers/modelcard.py
model
called by 2954
hubconf.py
to
called by 2621
src/transformers/modeling_utils.py
size
called by 2402
src/transformers/onnx/utils.py
requires_backends
called by 1727
src/transformers/utils/import_utils.py
pop
called by 1199
src/transformers/utils/generic.py
replace
called by 1162
src/transformers/adapters/configuration.py
shape_list
called by 1134
src/transformers/utils/dummy_tf_objects.py

Shape

Method 30,079
Class 8,740
Function 2,962
Route 493

Languages

Python100%
C++1%

Modules by API surface

src/transformers/utils/dummy_pt_objects.py1,835 symbols
src/transformers/utils/dummy_tf_objects.py741 symbols
src/transformers/utils/dummy_flax_objects.py334 symbols
tests/trainer/test_trainer.py175 symbols
src/transformers/models/perceiver/modeling_perceiver.py158 symbols
src/transformers/models/oneformer/modeling_oneformer.py145 symbols
src/transformers/models/jukebox/modeling_jukebox.py145 symbols
src/transformers/utils/dummy_vision_objects.py134 symbols
src/transformers/testing_utils.py131 symbols
tests/test_tokenization_common.py120 symbols
src/transformers/models/mobilebert/modeling_tf_mobilebert.py118 symbols
tests/test_modeling_common.py117 symbols

For agents

$ claude mcp add adapters \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact