MCPcopy Create free account

hub / github.com/adapter-hub/adapters / functions

Functions1,559 in github.com/adapter-hub/adapters

↓ 130 callersMethodget_model
Builds a model instance for testing based on the provied model configuration.
tests/test_methods/base.py:47
↓ 101 callersMethodadd_adapter
(self, adapter_name: str, layer_idx: int)
src/adapters/methods/reft.py:194
↓ 76 callersMethodset_active_adapters
Sets the adapter modules to be used by default in every forward pass. If no adapter with the given name is found, no module of the re
src/adapters/model_mixin.py:649
↓ 73 callersMethodget
Gets the config dictionary for a given adapter. Args: adapter_name (str): The name of the adapter. Returns:
src/adapters/configuration/model_adapters_config.py:47
↓ 47 callersMethodconfig
()
tests/test_methods/test_all_custom_interfaces.py:342
↓ 43 callersFunctionadjust_tensors_for_parallel
Replicates a given list of tensors based on the shape of the reference tensor (first argument).
src/adapters/composition.py:288
↓ 39 callersMethodget_input_samples
(self, vocab_size=5000, config=None, dtype=torch.float, **kwargs)
tests/test_methods/test_on_clip/test_model.py:36
↓ 36 callersMethodload
Loads the module weights from the given directory. Override this method for additional loading actions. If adding the loaded weights
src/adapters/loading.py:328
↓ 34 callersFunctionpatch_forward
(module: torch.nn.Module)
src/adapters/utils.py:917
↓ 34 callersMethodreplace
(self, **changes)
src/adapters/configuration/adapter_config.py:842
↓ 33 callersMethodwrap
( cls, module: Union[nn.Linear, Conv1D], location_key: str, model_config: Pret
src/adapters/methods/lora.py:807
↓ 30 callersMethodprefix_tuning
(self)
src/adapters/configuration/adapter_config.py:876
↓ 30 callersMethodstate_dict
(self, filter_func)
src/adapters/loading.py:61
↓ 28 callersFunctiongenerate_method_tests
Generates a set of method test classes for a given model test base. Args: model_test_base (type): The base class for the model tests
tests/test_methods/generator.py:30
↓ 27 callersFunctioninit
( model: PreTrainedModel, adapters_config: Optional[ModelAdaptersConfig] = None, interface: Option
src/adapters/wrappers/model.py:82
↓ 27 callersMethoditer_layers
Iterates over all layers of the model. This abstract method has to ne implemented by every implementing model.
src/adapters/model_mixin.py:552
↓ 27 callersFunctionmatch_attn_matrices_for_parallel
Matches the shapes of query, key and value matrices for parallel composition.
src/adapters/composition.py:316
↓ 26 callersMethodbottleneck_layer_forward
Forward pass through the adapter layer. NOTE: This method should only be called if the calling module directly inherits from BottleneckLayer.
src/adapters/methods/bottleneck.py:348
↓ 26 callersMethodget_context
(cls)
src/adapters/context.py:51
↓ 26 callersMethodload_adapter
Loads a pre-trained pytorch adapter module from the local file system or a remote location. Args: adapter_name_or_path (
src/adapters/model_mixin.py:1075
↓ 26 callersFunctionmake_config
(config_class, **kwargs)
tests/test_methods/method_test_impl/utils.py:39
↓ 23 callersMethod_init_head_modules
(self)
src/adapters/heads/model_mixin.py:123
↓ 23 callersMethodforward_head
The forward pass through a prediction head configuration. There are three ways to specify the used prediction head configuration (in
src/adapters/heads/model_mixin.py:571
↓ 22 callersMethodadd_adapter_fusion
Adds AdapterFusion to the model with alll the necessary configurations and weight initializations Args: adapter_names (F
src/adapters/model_mixin.py:904
↓ 22 callersMethodtrain_adapter
Sets the model into mode for training the given adapters.
src/adapters/model_mixin.py:579
↓ 21 callersMethodreshape
separate heads
src/adapters/models/distilbert/modeling_distilbert.py:224
↓ 20 callersMethodadd_head
(self, *args, **kwargs)
tests/test_methods/test_on_clip/test_model.py:66
↓ 20 callersMethodflatten
(self)
src/adapters/composition.py:46
↓ 18 callersFunctioncreate_twin_models
(model_class, config_creator=None, interface=None)
tests/test_methods/method_test_impl/utils.py:13
↓ 18 callersMethodmatch
Tries to match the given criteria to an existing adapter. Return the adapter config if a match is found, otherwise None.
src/adapters/configuration/model_adapters_config.py:69
↓ 18 callersMethodrun_forward_test
( self, model, adapter_config, adapter_setup, tasks, dtype=tor
tests/test_methods/method_test_impl/composition/test_multi_task.py:178
↓ 18 callersMethodsave_adapter
Saves an adapter and its configuration file to a directory so that it can be shared or reloaded using `load_adapter()`. Args
src/adapters/model_mixin.py:1006
↓ 17 callersMethod_filter_parameters
(self, model, filter_keys)
tests/test_methods/method_test_impl/base.py:35
↓ 17 callersMethodrun_train_test
( self, adapter_config, filter_keys, adapter_setup, shared_parameters,
tests/test_methods/method_test_impl/composition/test_multi_task.py:73
↓ 16 callersFunctionadjust_tensors_for_parallel_
In-place version of adjust_tensors_for_parallel().
src/adapters/composition.py:304
↓ 16 callersMethodbuild_model
(self)
tests/test_misc/test_adapter_composition.py:46
↓ 16 callersMethodinit_weights
(self)
src/adapters/heads/dependency_parsing.py:49
↓ 15 callersFunctionprefix_attention_mask
Adds a prefix to an attention mask. The length of the prefix is determined by the `prefix_attention_mask_length` attribute in the ForwardCont
src/adapters/utils.py:873
↓ 15 callersMethodrun_add_test
(self, model, adapter_config, filter_keys)
tests/test_methods/method_test_impl/base.py:38
↓ 15 callersMethodrun_get_test
(self, model, adapter_config, num_expected_modules)
tests/test_methods/method_test_impl/base.py:149
↓ 15 callersMethodrun_load_test
(self, adapter_config)
tests/test_methods/method_test_impl/base.py:205
↓ 14 callersMethodapply_to_adapter_layers
Applies a function to all adapter layers of the model.
src/adapters/model_mixin.py:560
↓ 14 callersMethodmean
(self, states: List[LoRAState], weights: torch.Tensor)
src/adapters/methods/lora.py:924
↓ 14 callersMethodrun_delete_test
(self, model, adapter_config, filter_keys)
tests/test_methods/method_test_impl/base.py:127
↓ 14 callersMethodrun_linear_average_test
(self, model, adapter_config, filter_keys)
tests/test_methods/method_test_impl/base.py:82
↓ 13 callersMethoddelete_adapter
(self, adapter_name: str)
src/adapters/methods/lora.py:599
↓ 13 callersMethodget_context_head_setup
(cls)
src/adapters/context.py:65
↓ 13 callersFunctionids_tensor
(shape, vocab_size=5000, dtype=torch.long)
tests/test_methods/method_test_impl/utils.py:43
↓ 13 callersMethodrun_full_model_load_test
(self, adapter_config)
tests/test_methods/method_test_impl/base.py:242
↓ 12 callersMethodadd_prediction_head
( self, head: PredictionHead, overwrite_ok: bool = False, set_active: bool = T
src/adapters/heads/model_mixin.py:315
↓ 12 callersMethodinvertible_adapters_forward
(self, hidden_states, rev=False)
src/adapters/model_mixin.py:154
↓ 12 callersMethodload_state_dict
Override load_state_dict to handle key remapping between static and flex models. Static models (e.g., BartForConditionalGeneration,
src/adapters/heads/model_mixin.py:79
↓ 11 callersMethodadd_classification_head
Adds a sequence classification head on top of the model. Args: head_name (str): The name of the head. num_la
src/adapters/heads/model_mixin.py:346
↓ 11 callersMethodaverage_adapter
( self, adapter_name: str, input_adapters: Dict[str, float], combine_strategy:
src/adapters/methods/lora.py:605
↓ 11 callersMethodload_head
Loads a model prediction head from a directory where it was saved using `save_head()`. Args: save_directory (str): Path to the di
src/adapters/model_mixin.py:2309
↓ 11 callersFunctionparse_composition
Parses and validates a setup of adapters. Args: adapter_composition: The adapter setup to be parsed. level (int, optional):
src/adapters/composition.py:222
↓ 11 callersMethodrun_leave_out_test
(self, model, adapter_config, leave_out)
tests/test_methods/method_test_impl/base.py:62
↓ 11 callersMethodsave_head
Saves a model prediction head to a directory such that it can be reloaded using `load_head()`. Args: save_directory (str): Path t
src/adapters/model_mixin.py:2293
↓ 10 callersMethodevaluate
Run evaluation and return metrics. The calling script will be responsible for providing a method to compute metrics, as they are
examples/pytorch/dependency-parsing/utils_udp.py:206
↓ 10 callersFunctionfix_seed
Helper function to fix the torch seed on cpu and gpu for initializing adapters with the same weights. Is only executed if the config provides
src/adapters/methods/utils.py:20
↓ 10 callersFunctionget_adapter_config_hash
Calculates the hash of a given adapter configuration which is used to identify this configuration. Returns: str: The resulting hash
src/adapters/utils.py:146
↓ 10 callersMethodget_model_config
(self)
tests/test_misc/test_adapter_trainer/test_adapter_trainer.py:30
↓ 10 callersFunctionsetup_adapter_training
Setup model for adapter training based on given adapter arguments. Args: model (_type_): The model instance to be trained. adapte
src/adapters/training.py:36
↓ 9 callersMethodapply_to_basemodel_childs
Applies a function to all direct childs of the model if they are a instance of AdapterLayerBase.
src/adapters/model_mixin.py:569
↓ 9 callersMethodget_input_embeddings
(self)
src/adapters/models/bart/mixin_bart.py:115
↓ 9 callersMethodget_model
(self)
tests/test_methods/test_all_custom_interfaces.py:211
↓ 9 callersFunctionget_results
(output_dir)
examples/pytorch/test_adapter_examples.py:48
↓ 9 callersFunctionmultigetattr
(o: object, name: str, default=None)
src/adapters/utils.py:166
↓ 9 callersMethodrun_gradient_checkpointing_single_adapter_test
(self, adapter_config)
tests/test_methods/method_test_impl/base.py:449
↓ 9 callersMethodrun_prediction_head_test
( self, model, compare_model, head_name, input_shape=None, out
tests/test_methods/method_test_impl/heads/test_adapter_heads.py:17
↓ 9 callersMethodrun_same_weights_test
(self, adapter_config, filter_keys)
tests/test_methods/method_test_impl/base.py:476
↓ 9 callersMethodrun_test
(self, static_model, input_shape=None, label_dict=None)
tests/test_methods/method_test_impl/core/test_adapter_conversion.py:30
↓ 9 callersMethodsave_pretrained
( self, save_directory: Union[str, os.PathLike], **kwargs, )
src/adapters/model_mixin.py:1934
↓ 8 callersMethodadd_embeddings
Add a new embedding to the model. If a reference embedding and reference tokenizer are provided tokens in the present in both tokeniz
src/adapters/model_mixin.py:280
↓ 8 callersMethodget_active_setup
(self)
src/adapters/methods/adapter_layer_base.py:46
↓ 8 callersMethodget_input_embeddings
(self)
tests/test_methods/test_all_custom_interfaces.py:122
↓ 8 callersMethodload_adapter_fusion
Loads a pre-trained AdapterFusion layer from the local file system. Args: adapter_fusion_name_or_path (str):
src/adapters/model_mixin.py:1136
↓ 8 callersMethodrepeat
(self, state: LoRAState, channels: int)
src/adapters/methods/lora.py:916
↓ 8 callersMethodrun_forward_test
(self, model, adapter_config, dtype=torch.float32, **kwargs)
tests/test_methods/method_test_impl/base.py:167
↓ 8 callersMethodsupports_adapter
Checks if the model supports a given adapter type. Args: adapter_type (str): The adapter type to check. Returns
src/adapters/model_mixin.py:509
↓ 7 callersMethod__init__
( self, lora_A_shape, lora_B_shape, config: LoRAConfig, gating_heads:
src/adapters/methods/lora.py:237
↓ 7 callersMethod_assert_adapter_available
Check wether the adapter name is present in the model's adapter config and has been created.
tests/test_methods/method_test_impl/base.py:25
↓ 7 callersMethod_get_compose_func
Retrieves the correct composition function based on the mapping in 'composition_to_func_map'.
src/adapters/methods/adapter_layer_base.py:249
↓ 7 callersMethodbuild
(self, model)
src/adapters/heads/base.py:81
↓ 7 callersMethodfirst
(self)
src/adapters/composition.py:30
↓ 7 callersMethodget_adapter
Returns the adapter module with the given name. Args: adapter_name (str): The name of the adapter module.
src/adapters/methods/lora.py:675
↓ 7 callersMethodrun_merge_test
(self, adapter_config)
tests/test_methods/method_test_impl/base.py:355
↓ 7 callersMethodrun_reset_test
(self, adapter_config)
tests/test_methods/method_test_impl/base.py:378
↓ 7 callersMethodsave
Saves the module config and weights into the given directory. Override this method for additional saving actions. Args:
src/adapters/loading.py:296
↓ 7 callersMethodsave_adapter_fusion
Saves an AdapterFusion layer and its configuration file to a directory so that it can be shared or reloaded using `load_adapter_fusio
src/adapters/model_mixin.py:1039
↓ 7 callersMethodtrain_adapter_fusion
Sets the model into mode for training of adapter fusion determined by a list of adapter names.
src/adapters/model_mixin.py:613
↓ 6 callersMethod__init__
( self, *fuse_stacks: List[Union[AdapterCompositionBlock, str]], name: Optional[str] =
src/adapters/composition.py:95
↓ 6 callersMethod__init__
( self, adapter_name, input_size, down_sample, config: BnConfig, )
src/adapters/methods/modeling.py:40
↓ 6 callersMethod__init__
( self, model, head_name, num_labels=2, layers=1, activation_f
src/adapters/heads/base.py:316
↓ 6 callersFunctionbuild_full_config
(adapter_config, model_config, save_id2label=False, **kwargs)
src/adapters/configuration/model_adapters_config.py:243
↓ 6 callersMethodcheck_composition_valid
Checks whether the given composition is valid. Args: parent (AdapterCompositionBlock): The parent composition block.
src/adapters/methods/adapter_layer_base.py:354
↓ 6 callersMethodcom
Performs the composition operation between existing and injected weights.
src/adapters/methods/lora.py:289
↓ 6 callersMethodget_contexts
(cls)
src/adapters/context.py:45
↓ 6 callersMethodget_fusion
Gets the config dictionary for a given AdapterFusion. Args: fusion_name (Union[str, List[str]]): The name of the Adapter
src/adapters/configuration/model_adapters_config.py:137
↓ 6 callersMethodget_labels
(self)
src/adapters/model_mixin.py:2630
next →1–100 of 1,559, ranked by callers