{"id":23194,"library":"adapters","title":"Adapters","description":"A unified library for parameter-efficient and modular transfer learning, supporting adapter methods like LoRA, Bottleneck Adapters, AdapterPlus, DoRA, and ReFT. Built on Hugging Face Transformers. Current version: 1.3.0. Release cadence: irregular, roughly every 2-3 months.","status":"active","version":"1.3.0","language":"python","source_language":"en","source_url":"https://github.com/adapter-hub/adapters","tags":["parameter-efficient-fine-tuning","transfer-learning","adapter-hub","huggingface"],"install":[{"cmd":"pip install adapters","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Core dependency; adapters is built on top of HF Transformers","package":"transformers","optional":false}],"imports":[{"note":"Standard import for loading any model with adapter support.","wrong":"","symbol":"AutoAdapterModel","correct":"from adapters import AutoAdapterModel"},{"note":"Base class for configuration.","wrong":"","symbol":"AdapterConfig","correct":"from adapters import AdapterConfig"},{"note":"LoRA adapter configuration.","wrong":"","symbol":"LoRAConfig","correct":"from adapters import LoRAConfig"},{"note":"Utility to set up training with adapters.","wrong":"","symbol":"setup_adapter_training","correct":"from adapters import setup_adapter_training"}],"quickstart":{"code":"from transformers import AutoTokenizer\nfrom adapters import AutoAdapterModel, LoRAConfig\n\ntokenizer = AutoTokenizer.from_pretrained(\"bert-base-uncased\")\nmodel = AutoAdapterModel.from_pretrained(\"bert-base-uncased\")\n\n# Add a LoRA adapter with configuration\nconfig = LoRAConfig(r=8, alpha=16)\nmodel.add_adapter(\"my_lora_adapter\", config=config)\nmodel.train_adapter(\"my_lora_adapter\")\n\n# Example: encode a sentence\ninputs = tokenizer(\"Hello, adapters!\", return_tensors=\"pt\")\noutputs = model(**inputs)\nprint(outputs.last_hidden_state.shape)","lang":"python","description":"Load a BERT model, add a LoRA adapter, and run a forward pass."},"warnings":[{"fix":"Pin transformers to the version listed in the adapters release (e.g., for adapters 1.3.0 use transformers >=4.51.0, <4.58.0).","message":"Each version of adapters supports a specific range of transformers versions. Using an incompatible transformers version may cause import errors or silent misbehavior. Check the release notes for the supported transformers version.","severity":"breaking","affected_versions":"all"},{"fix":"Use `model = AutoAdapterModel.from_pretrained(..., load_in_4bit=True, torch_dtype=torch.bfloat16)` and ensure bitsandbytes is installed.","message":"When using QLoRA with bnb (bitsandbytes), the quantized model must be loaded with `load_in_4bit=True` and `torch_dtype=torch.bfloat16`. Omitting these may cause runtime errors or incorrect behavior.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"After adding an adapter, call `model.adapter_to('cuda')` or `model.adapter_to('cuda', dtype=torch.float16)`.","message":"The `adapter_to()` method is used to move adapter weights to a device and optionally convert dtype. Forgetting to call it after adding an adapter can leave weights on CPU, causing issues when training on GPU.","severity":"gotcha","affected_versions":">=0.2.1"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Replace `from transformers import BertModel` with `from adapters import AutoAdapterModel` and use `AutoAdapterModel.from_pretrained(...)`.","cause":"Using a bare Hugging Face model instead of an AutoAdapterModel (or AdapterModel wrapper).","error":"AttributeError: 'BertModel' object has no attribute 'add_adapter'"},{"fix":"Use `from adapters import AutoAdapterModel`.","cause":"Trying to import AutoAdapterModel from transformers, but it is provided by the adapters package.","error":"ImportError: cannot import name 'AutoAdapterModel' from 'transformers'"},{"fix":"Ensure `model.add_adapter('my_adapter', config=...)` is called before `model.train_adapter('my_adapter')`.","cause":"Calling `train_adapter('my_adapter')` before adding the adapter with `add_adapter()`.","error":"ValueError: Adapter 'my_adapter' not found. Make sure to add an adapter before training."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}