Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/huggingface/transformers
/ functions
Functions
4,119 in github.com/huggingface/transformers
⨍
Functions
4,119
◇
Types & classes
939
↳
Endpoints
4
↓ 285 callers
Method
to
Send all values to device by calling v.to(device)
src/transformers/tokenization_utils_base.py:522
↓ 255 callers
Function
model
r""" # Using torch.hub ! import torch model = torch.hub.load('huggingface/transformers', 'model', 'bert-base-unca
hubconf.py:57
↓ 223 callers
Method
from_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 callers
Method
items
(self)
src/transformers/tokenization_utils_base.py:205
↓ 126 callers
Method
keys
(self)
src/transformers/tokenization_utils_base.py:199
↓ 88 callers
Method
init_weights
Initialize and prunes weights if needed.
src/transformers/modeling_utils.py:446
↓ 81 callers
Function
get_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 callers
Function
is_torch_available
()
src/transformers/file_utils.py:131
↓ 76 callers
Method
load
(module: nn.Module, prefix="")
src/transformers/modeling_utils.py:726
↓ 76 callers
Method
update
Updates attributes of this class with attributes from `config_dict`. Args: :obj:`Dict[str, any]`: Dictionary of
src/transformers/configuration_utils.py:399
↓ 75 callers
Function
shape_list
Deal with dynamic shape in tensorflow cleanly.
src/transformers/modeling_tf_utils.py:1794
↓ 72 callers
Method
save
Save the provided data object with the representation for the current `DataFormat`. :param data: data to store :return:
src/transformers/pipelines.py:189
↓ 63 callers
Method
encode
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 callers
Function
is_tf_available
()
src/transformers/file_utils.py:135
↓ 58 callers
Method
save_pretrained
Save the pipeline's model and tokenizer to the specified save_directory
src/transformers/pipelines.py:404
↓ 47 callers
Function
ids_tensor
(shape, vocab_size, rng=None, name=None)
tests/test_modeling_common.py:821
↓ 43 callers
Method
generate
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 callers
Method
convert_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 callers
Method
decode
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 callers
Method
tokenize
Tokenize the provided input and eventually returns corresponding tokens id: - **text_input**: String to tokenize - **return_i
src/transformers/commands/serving.py:162
↓ 38 callers
Method
detach
Need to document this
examples/seq2seq/bertabs/modeling_bertabs.py:541
↓ 38 callers
Method
prepare_config_and_inputs_for_common
(self)
tests/test_modeling_bart.py:77
↓ 34 callers
Method
_read_tsv
Reads a tab separated value file.
src/transformers/data/processors/utils.py:118
↓ 32 callers
Method
run_common_tests
(self)
tests/test_configuration_common.py:69
↓ 30 callers
Method
compute_loss
(self, labels, logits)
src/transformers/modeling_tf_utils.py:110
↓ 29 callers
Function
pipeline
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 callers
Method
__init__
(self, feat_size, epsilon=None, **kwargs)
src/transformers/modeling_tf_mobilebert.py:65
↓ 28 callers
Method
get_tokenizers
(self, fast=True, **kwargs)
tests/test_tokenization_common.py:96
↓ 27 callers
Method
__init__
(self, feat_size, eps=None)
src/transformers/modeling_mobilebert.py:129
↓ 27 callers
Function
cast_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 callers
Method
run
(self)
src/transformers/commands/run.py:81
↓ 26 callers
Method
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:1672
↓ 25 callers
Method
values
(self)
src/transformers/tokenization_utils_base.py:202
↓ 23 callers
Method
convert_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 callers
Method
__init__
(self, config)
src/transformers/modeling_bert.py:352
↓ 22 callers
Method
zero_grad
(self)
examples/seq2seq/bertabs/modeling_bertabs.py:1015
↓ 21 callers
Method
__init__
(self, config, **kwargs)
src/transformers/modeling_tf_bert.py:365
↓ 21 callers
Method
batch_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 callers
Method
convert_to_tensor
(self, symbols)
src/transformers/tokenization_transfo_xl.py:329
↓ 18 callers
Method
_test_mono_column_pipeline
( self, nlp: Pipeline, valid_inputs: List, output_keys: Iterable[str],
tests/test_pipelines.py:118
↓ 18 callers
Method
device
Get torch.device from module, assuming that the whole module has one device.
src/transformers/modeling_utils.py:126
↓ 17 callers
Function
get_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 callers
Method
__init__
(self, config, **kwargs)
src/transformers/modeling_tf_albert.py:328
↓ 16 callers
Method
backward
(ctx, gradOutput)
examples/movement-pruning/emmental/modules/binarizer.py:107
↓ 16 callers
Method
get_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 callers
Function
is_torch_tpu_available
()
src/transformers/file_utils.py:139
↓ 16 callers
Method
step
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 callers
Method
from_json_file
Constructs a `ModelCard` from a json file of parameters.
src/transformers/modelcard.py:189
↓ 15 callers
Method
model
Only load the model if needed.
tests/test_modeling_bart.py:230
↓ 14 callers
Method
__init__
(self, config, layer_id=0)
src/transformers/modeling_reformer.py:1081
↓ 14 callers
Method
close
(self)
src/transformers/hf_api.py:226
↓ 14 callers
Method
decoder
(self)
src/transformers/tokenization_utils_fast.py:140
↓ 14 callers
Method
step
Performs a single optimization step. Arguments: closure (callable, optional): A closure that reevaluates the model
src/transformers/optimization.py:119
↓ 14 callers
Function
tokenizer
r""" # Using torch.hub ! import torch tokenizer = torch.hub.load('huggingface/transformers', 'tokenizer', 'bert-base-uncased'
hubconf.py:43
↓ 14 callers
Method
train
The real training loop.
examples/distillation/distiller.py:330
↓ 13 callers
Method
__init__
(self, config)
src/transformers/modeling_albert.py:264
↓ 13 callers
Method
__init__
(self, config)
examples/movement-pruning/emmental/modeling_bert_masked.py:290
↓ 13 callers
Method
add_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 callers
Method
parse_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 callers
Method
__init__
(self, config, **kwargs)
src/transformers/modeling_tf_distilbert.py:279
↓ 12 callers
Method
_prepare_for_class
(self, inputs_dict, model_class)
tests/test_modeling_common.py:66
↓ 12 callers
Method
add
Add a new hypothesis to the list.
src/transformers/modeling_utils.py:1736
↓ 12 callers
Method
backward
(ctx, grad_out_vectors, grad_logits)
src/transformers/modeling_reformer.py:761
↓ 12 callers
Method
prepare_config_and_inputs
(self)
tests/test_modeling_reformer.py:124
↓ 12 callers
Method
train
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 callers
Method
__init__
(self, config: BartConfig)
src/transformers/modeling_bart.py:809
↓ 11 callers
Method
key
(self, i)
examples/seq2seq/utils.py:155
↓ 11 callers
Method
pad
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 callers
Method
prepare_config_and_inputs
(self)
tests/test_modeling_bert.py:91
↓ 10 callers
Method
__init__
(self, config)
src/transformers/modeling_distilbert.py:194
↓ 10 callers
Method
__init__
(self, config, **kwargs)
src/transformers/modeling_tf_xlnet.py:333
↓ 10 callers
Method
__init__
(self, config)
src/transformers/modeling_electra.py:242
↓ 10 callers
Function
cached_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 callers
Method
check_results_dict_not_empty
(self, results)
tests/test_benchmark.py:20
↓ 10 callers
Method
get_labels
(self)
examples/adversarial/utils_hans.py:156
↓ 10 callers
Method
is_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 callers
Method
normalize
Cover moses empty string edge case. They return empty list for '' input!
src/transformers/tokenization_marian.py:92
↓ 10 callers
Method
prepare_config_and_inputs
(self)
tests/test_modeling_mobilebert.py:92
↓ 10 callers
Method
to_json_string
Serializes this instance to a JSON string.
src/transformers/modelcard.py:207
↓ 9 callers
Method
__init__
(self, config, *inputs, **kwargs)
src/transformers/modeling_tf_electra.py:382
↓ 9 callers
Method
__init__
(self, config)
src/transformers/modeling_xlnet.py:478
↓ 9 callers
Method
__init__
(self, config)
src/transformers/modeling_xlm.py:317
↓ 9 callers
Method
__init__
(self, config, *inputs, **kwargs)
src/transformers/modeling_tf_roberta.py:200
↓ 9 callers
Method
__init__
(self, config, *inputs, **kwargs)
src/transformers/modeling_tf_xlm.py:613
↓ 9 callers
Method
__init__
(self, config, has_relative_attention_bias=False)
src/transformers/modeling_t5.py:469
↓ 9 callers
Method
__init__
(self, config, has_relative_attention_bias=False, **kwargs)
src/transformers/modeling_tf_t5.py:384
↓ 9 callers
Method
_get_basic_config_and_input
(self)
tests/test_modeling_reformer.py:581
↓ 9 callers
Method
_prepare_for_class
(self, inputs_dict, model_class, return_labels=False)
tests/test_modeling_tf_common.py:78
↓ 9 callers
Method
check_loss_output
(self, result)
tests/test_modeling_bert.py:154
↓ 9 callers
Function
find_pruneable_heads_and_indices
( heads: List, n_heads: int, head_size: int, already_pruned_heads: set )
src/transformers/modeling_utils.py:58
↓ 9 callers
Method
from_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 callers
Method
init_weights
(self)
examples/seq2seq/bertabs/modeling_bertabs.py:92
↓ 9 callers
Method
prepare_config_and_inputs
(self)
tests/test_modeling_tf_mobilebert.py:109
↓ 9 callers
Method
prepare_config_and_inputs
(self)
tests/test_modeling_tf_bert.py:89
↓ 9 callers
Method
prepare_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 callers
Function
prune_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 callers
Method
__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 callers
Method
__init__
( self, model: Union["PreTrainedModel", "TFPreTrainedModel"], tokenizer: PreTrainedTok
src/transformers/pipelines.py:372
↓ 8 callers
Method
__init__
(self, config)
src/transformers/modeling_roberta.py:152
↓ 8 callers
Method
add_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