MCPcopy Create free account

hub / github.com/huggingface/transformers / functions

Functions4,119 in github.com/huggingface/transformers

↓ 285 callersMethodto
Send all values to device by calling v.to(device)
src/transformers/tokenization_utils_base.py:522
↓ 255 callersFunctionmodel
r""" # Using torch.hub ! import torch model = torch.hub.load('huggingface/transformers', 'model', 'bert-base-unca
hubconf.py:57
↓ 223 callersMethodfrom_pretrained
r""" Instantiate a :class:`~transformers.ModelCard` from a pre-trained model model card. Parameters: pretrained_model_name_or_pat
src/transformers/modelcard.py:88
↓ 187 callersMethoditems
(self)
src/transformers/tokenization_utils_base.py:205
↓ 126 callersMethodkeys
(self)
src/transformers/tokenization_utils_base.py:199
↓ 88 callersMethodinit_weights
Initialize and prunes weights if needed.
src/transformers/modeling_utils.py:446
↓ 81 callersFunctionget_initializer
Creates a `tf.initializers.truncated_normal` with the given range. Args: initializer_range: float, initializer range for stddev. Retur
src/transformers/modeling_tf_utils.py:1812
↓ 79 callersFunctionis_torch_available
()
src/transformers/file_utils.py:131
↓ 76 callersMethodload
(module: nn.Module, prefix="")
src/transformers/modeling_utils.py:726
↓ 76 callersMethodupdate
Updates attributes of this class with attributes from `config_dict`. Args: :obj:`Dict[str, any]`: Dictionary of
src/transformers/configuration_utils.py:399
↓ 75 callersFunctionshape_list
Deal with dynamic shape in tensorflow cleanly.
src/transformers/modeling_tf_utils.py:1794
↓ 72 callersMethodsave
Save the provided data object with the representation for the current `DataFormat`. :param data: data to store :return:
src/transformers/pipelines.py:189
↓ 63 callersMethodencode
Converts a string in a sequence of ids (integer), using the tokenizer and vocabulary. Same as doing ``self.convert_tokens_to_ids(sel
src/transformers/tokenization_utils_base.py:1389
↓ 61 callersFunctionis_tf_available
()
src/transformers/file_utils.py:135
↓ 58 callersMethodsave_pretrained
Save the pipeline's model and tokenizer to the specified save_directory
src/transformers/pipelines.py:404
↓ 47 callersFunctionids_tensor
(shape, vocab_size, rng=None, name=None)
tests/test_modeling_common.py:821
↓ 43 callersMethodgenerate
r""" Generates sequences for models with a LM head. The method currently supports greedy decoding, beam-search decoding, sampling with temperature, sa
src/transformers/modeling_utils.py:872
↓ 41 callersMethodconvert_tokens_to_ids
Converts a token string (or a sequence of tokens) in a single integer id (or a sequence of ids), using the vocabulary.
src/transformers/tokenization_utils.py:376
↓ 41 callersMethoddecode
Take the output of any QuestionAnswering head and will generate probalities for each span to be the actual answer. In additio
src/transformers/pipelines.py:1267
↓ 40 callersMethodtokenize
Tokenize the provided input and eventually returns corresponding tokens id: - **text_input**: String to tokenize - **return_i
src/transformers/commands/serving.py:162
↓ 38 callersMethoddetach
Need to document this
examples/seq2seq/bertabs/modeling_bertabs.py:541
↓ 38 callersMethodprepare_config_and_inputs_for_common
(self)
tests/test_modeling_bart.py:77
↓ 34 callersMethod_read_tsv
Reads a tab separated value file.
src/transformers/data/processors/utils.py:118
↓ 32 callersMethodrun_common_tests
(self)
tests/test_configuration_common.py:69
↓ 30 callersMethodcompute_loss
(self, labels, logits)
src/transformers/modeling_tf_utils.py:110
↓ 29 callersFunctionpipeline
Utility factory method to build a pipeline. Pipeline are made of: - A Tokenizer instance in charge of mapping raw textual input to
src/transformers/pipelines.py:1682
↓ 28 callersMethod__init__
(self, feat_size, epsilon=None, **kwargs)
src/transformers/modeling_tf_mobilebert.py:65
↓ 28 callersMethodget_tokenizers
(self, fast=True, **kwargs)
tests/test_tokenization_common.py:96
↓ 27 callersMethod__init__
(self, feat_size, eps=None)
src/transformers/modeling_mobilebert.py:129
↓ 27 callersFunctioncast_bool_to_primitive
Function arguments can be inserted as boolean tensor and bool variables to cope with keras serialization we need to cast `output_atten
src/transformers/modeling_tf_utils.py:1822
↓ 27 callersMethodrun
(self)
src/transformers/commands/run.py:81
↓ 26 callersMethodencode_plus
Returns a dictionary containing the encoded sequence or sequence pair and additional information: the mask for sequence classificatio
src/transformers/tokenization_utils_base.py:1672
↓ 25 callersMethodvalues
(self)
src/transformers/tokenization_utils_base.py:202
↓ 23 callersMethodconvert_ids_to_tokens
Converts a single index or a sequence of indices (integers) in a token " (resp.) a sequence of tokens (str), using the vocabulary and add
src/transformers/tokenization_utils.py:837
↓ 22 callersMethod__init__
(self, config)
src/transformers/modeling_bert.py:352
↓ 22 callersMethodzero_grad
(self)
examples/seq2seq/bertabs/modeling_bertabs.py:1015
↓ 21 callersMethod__init__
(self, config, **kwargs)
src/transformers/modeling_tf_bert.py:365
↓ 21 callersMethodbatch_encode_plus
Returns a dictionary containing the encoded sequence or sequence pair and additional information: the mask for sequence classificatio
src/transformers/tokenization_utils_base.py:1763
↓ 20 callersMethodconvert_to_tensor
(self, symbols)
src/transformers/tokenization_transfo_xl.py:329
↓ 18 callersMethod_test_mono_column_pipeline
( self, nlp: Pipeline, valid_inputs: List, output_keys: Iterable[str],
tests/test_pipelines.py:118
↓ 18 callersMethoddevice
Get torch.device from module, assuming that the whole module has one device.
src/transformers/modeling_utils.py:126
↓ 17 callersFunctionget_linear_schedule_with_warmup
Create a schedule with a learning rate that decreases linearly after linearly increasing during a warmup period.
src/transformers/optimization.py:47
↓ 16 callersMethod__init__
(self, config, **kwargs)
src/transformers/modeling_tf_albert.py:328
↓ 16 callersMethodbackward
(ctx, gradOutput)
examples/movement-pruning/emmental/modules/binarizer.py:107
↓ 16 callersMethodget_head_mask
# Prepare head mask if needed # 1.0 in head_mask indicate we keep the head attention_probs has shape bsz x n_heads x N x N
src/transformers/modeling_utils.py:231
↓ 16 callersFunctionis_torch_tpu_available
()
src/transformers/file_utils.py:139
↓ 16 callersMethodstep
One optimization step: forward of student AND teacher, backward on the loss (for gradient accumulation), and possibly a parameter upd
examples/distillation/distiller.py:372
↓ 15 callersMethodfrom_json_file
Constructs a `ModelCard` from a json file of parameters.
src/transformers/modelcard.py:189
↓ 15 callersMethodmodel
Only load the model if needed.
tests/test_modeling_bart.py:230
↓ 14 callersMethod__init__
(self, config, layer_id=0)
src/transformers/modeling_reformer.py:1081
↓ 14 callersMethodclose
(self)
src/transformers/hf_api.py:226
↓ 14 callersMethoddecoder
(self)
src/transformers/tokenization_utils_fast.py:140
↓ 14 callersMethodstep
Performs a single optimization step. Arguments: closure (callable, optional): A closure that reevaluates the model
src/transformers/optimization.py:119
↓ 14 callersFunctiontokenizer
r""" # Using torch.hub ! import torch tokenizer = torch.hub.load('huggingface/transformers', 'tokenizer', 'bert-base-uncased'
hubconf.py:43
↓ 14 callersMethodtrain
The real training loop.
examples/distillation/distiller.py:330
↓ 13 callersMethod__init__
(self, config)
src/transformers/modeling_albert.py:264
↓ 13 callersMethod__init__
(self, config)
examples/movement-pruning/emmental/modeling_bert_masked.py:290
↓ 13 callersMethodadd_tokens
Add a list of new tokens to the tokenizer class. If the new tokens are not in the vocabulary, they are added to it with indices start
src/transformers/tokenization_utils_base.py:680
↓ 13 callersMethodparse_args_into_dataclasses
Parse command-line args into instances of the specified dataclass types. This relies on argparse's `ArgumentParser.parse_known_args`
src/transformers/hf_argparser.py:90
↓ 12 callersMethod__init__
(self, config, **kwargs)
src/transformers/modeling_tf_distilbert.py:279
↓ 12 callersMethod_prepare_for_class
(self, inputs_dict, model_class)
tests/test_modeling_common.py:66
↓ 12 callersMethodadd
Add a new hypothesis to the list.
src/transformers/modeling_utils.py:1736
↓ 12 callersMethodbackward
(ctx, grad_out_vectors, grad_logits)
src/transformers/modeling_reformer.py:761
↓ 12 callersMethodprepare_config_and_inputs
(self)
tests/test_modeling_reformer.py:124
↓ 12 callersMethodtrain
Main training entry point. Args: model_path: (Optional) Local path to model if model to train has been i
src/transformers/trainer.py:343
↓ 11 callersMethod__init__
(self, config: BartConfig)
src/transformers/modeling_bart.py:809
↓ 11 callersMethodkey
(self, i)
examples/seq2seq/utils.py:155
↓ 11 callersMethodpad
Pad a single encoded input or a batch of encoded inputs up to predefined length or to the max sequence length in the batch. Padding side
src/transformers/tokenization_utils_base.py:1863
↓ 11 callersMethodprepare_config_and_inputs
(self)
tests/test_modeling_bert.py:91
↓ 10 callersMethod__init__
(self, config)
src/transformers/modeling_distilbert.py:194
↓ 10 callersMethod__init__
(self, config, **kwargs)
src/transformers/modeling_tf_xlnet.py:333
↓ 10 callersMethod__init__
(self, config)
src/transformers/modeling_electra.py:242
↓ 10 callersFunctioncached_path
Given something that might be a URL (or might be a local path), determine which. If it's a URL, download the file and cache it, and retur
src/transformers/file_utils.py:525
↓ 10 callersMethodcheck_results_dict_not_empty
(self, results)
tests/test_benchmark.py:20
↓ 10 callersMethodget_labels
(self)
examples/adversarial/utils_hans.py:156
↓ 10 callersMethodis_world_master
This will be True only in one process, even in distributed mode, even when training on multiple machines.
src/transformers/trainer.py:602
↓ 10 callersMethodnormalize
Cover moses empty string edge case. They return empty list for '' input!
src/transformers/tokenization_marian.py:92
↓ 10 callersMethodprepare_config_and_inputs
(self)
tests/test_modeling_mobilebert.py:92
↓ 10 callersMethodto_json_string
Serializes this instance to a JSON string.
src/transformers/modelcard.py:207
↓ 9 callersMethod__init__
(self, config, *inputs, **kwargs)
src/transformers/modeling_tf_electra.py:382
↓ 9 callersMethod__init__
(self, config)
src/transformers/modeling_xlnet.py:478
↓ 9 callersMethod__init__
(self, config)
src/transformers/modeling_xlm.py:317
↓ 9 callersMethod__init__
(self, config, *inputs, **kwargs)
src/transformers/modeling_tf_roberta.py:200
↓ 9 callersMethod__init__
(self, config, *inputs, **kwargs)
src/transformers/modeling_tf_xlm.py:613
↓ 9 callersMethod__init__
(self, config, has_relative_attention_bias=False)
src/transformers/modeling_t5.py:469
↓ 9 callersMethod__init__
(self, config, has_relative_attention_bias=False, **kwargs)
src/transformers/modeling_tf_t5.py:384
↓ 9 callersMethod_get_basic_config_and_input
(self)
tests/test_modeling_reformer.py:581
↓ 9 callersMethod_prepare_for_class
(self, inputs_dict, model_class, return_labels=False)
tests/test_modeling_tf_common.py:78
↓ 9 callersMethodcheck_loss_output
(self, result)
tests/test_modeling_bert.py:154
↓ 9 callersFunctionfind_pruneable_heads_and_indices
( heads: List, n_heads: int, head_size: int, already_pruned_heads: set )
src/transformers/modeling_utils.py:58
↓ 9 callersMethodfrom_pretrained
r""" Instantiates one of the base model classes of the library from a pre-trained model configuration. The `from_pretrained()` method
src/transformers/modeling_auto.py:409
↓ 9 callersMethodinit_weights
(self)
examples/seq2seq/bertabs/modeling_bertabs.py:92
↓ 9 callersMethodprepare_config_and_inputs
(self)
tests/test_modeling_tf_mobilebert.py:109
↓ 9 callersMethodprepare_config_and_inputs
(self)
tests/test_modeling_tf_bert.py:89
↓ 9 callersMethodprepare_translation_batch
Arguments: src_texts: list of src language texts src_lang: default en_XX (english) tgt_texts: list of tgt
src/transformers/tokenization_bart.py:131
↓ 9 callersFunctionprune_linear_layer
Prune a linear layer (a model parameters) to keep only entries in index. Return the pruned layer as a new layer with requires_grad=True.
src/transformers/modeling_utils.py:2097
↓ 8 callersMethod__init__
(self, d_model, d_inner, dropout, pre_lnorm=False, layer_norm_epsilon=1e-5, init_std=0.02, **kwargs)
src/transformers/modeling_tf_transfo_xl.py:64
↓ 8 callersMethod__init__
( self, model: Union["PreTrainedModel", "TFPreTrainedModel"], tokenizer: PreTrainedTok
src/transformers/pipelines.py:372
↓ 8 callersMethod__init__
(self, config)
src/transformers/modeling_roberta.py:152
↓ 8 callersMethodadd_special_tokens
Add a dictionary of special tokens (eos, pad, cls...) to the encoder and link them to class attributes. If special tokens are NOT in
src/transformers/tokenization_utils_base.py:619
next →1–100 of 4,119, ranked by callers