Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Identifiers and configuration classes are explained in more detail in the [next
| `prefix_tuning_flat` | `PrefixTuningConfig(flat=True)` | [Prefix Tuning](methods.html#prefix-tuning) |
| `lora` | `LoRAConfig()` | [LoRA](methods.html#lora) |
| `vera` | `VeraConfig()` | [Vera](methods.html#vera) |
| `adamix` | `AdaMixConfig()` | [AdaMix](methods.html#adamix)
| `ia3` | `IA3Config()` | [IA³](methods.html#ia-3) |
| `mam` | `MAMConfig()` | [Mix-and-Match Adapters](method_combinations.html#mix-and-match-adapters) |
| `unipelt` | `UniPELTConfig()` | [UniPELT](method_combinations.html#unipelt) |
Expand Down
2 changes: 2 additions & 0 deletions src/adapters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"StaticAdapterFusionConfig",
"UniPELTConfig",
"VeraConfig",
"AdaMixConfig",
],
"context": [
"AdapterSetup",
Expand Down Expand Up @@ -194,6 +195,7 @@
StaticAdapterFusionConfig,
UniPELTConfig,
VeraConfig,
AdaMixConfig,
)
from .context import AdapterSetup, ForwardContext
from .heads import (
Expand Down
23 changes: 23 additions & 0 deletions src/adapters/configuration/adapter_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,28 @@ def __init__(
]

super().__init__(*[c.replace(use_gating=True) for c in components])


class AdaMixConfig(AdapterConfig):
"""
The 'Mixture of Adapter Experts' AdaMix method was proposed by Zhang et al. (2022).
See https://arxiv.org/abs/2205.12410.
"""
mh_adapter = True
output_adapter = True
reduction_factor = 16
non_linearity = "relu"

num_experts = 4
expert_dropout = 0.1
routing_algorithm = "linear"
use_load_balancing = True
load_balancing_weight = 0.01
selection_mode = "top_k"
k = 2

def __init__(self, **kwargs):
super().__init__(**kwargs)


# IMPORTANT: When adding a new config here, also add it to docs/overview.md!
Expand Down Expand Up @@ -874,6 +896,7 @@ def __init__(
"direft": DiReftConfig(),
"mam": MAMConfig(),
"unipelt": UniPELTConfig(),
"adamix": AdaMixConfig(),
}

DEFAULT_ADAPTER_CONFIG = "seq_bn"
Empty file added src/adapters/methods/adamix.py
Empty file.
Loading