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
↓ 4 callers
Method
_get_hidden_states
(self)
tests/test_modeling_reformer.py:615
↓ 4 callers
Method
_get_resized_embeddings
Build a resized Embedding Module from a provided token Embedding Module. Increasing the size will add newly initialized vectors at the en
src/transformers/modeling_utils.py:408
↓ 4 callers
Function
_is_control
Checks whether `chars` is a control character.
src/transformers/tokenization_utils.py:59
↓ 4 callers
Function
_is_punctuation
Checks whether `chars` is a punctuation character.
src/transformers/tokenization_utils.py:71
↓ 4 callers
Function
_is_whitespace
Checks whether `chars` is a whitespace character.
src/transformers/tokenization_utils.py:47
↓ 4 callers
Function
_make_linear_from_emb
(emb)
src/transformers/modeling_bart.py:164
↓ 4 callers
Method
_split_seq_length_dim_to
splits sequence length dim of vectors into `dim_factor_1` and `dim_factor_2` dims
src/transformers/modeling_reformer.py:282
↓ 4 callers
Method
_test_distiller_cli
(self, updates, check_contents=True)
examples/seq2seq/test_seq2seq_examples.py:153
↓ 4 callers
Function
build_mask
Builds the mask. The attention mechanism will only attend to positions with value 1.
examples/seq2seq/bertabs/utils_summarization.py:121
↓ 4 callers
Method
check_loss_output
(self, result)
templates/adding_a_new_model/tests/test_modeling_xxx.py:131
↓ 4 callers
Method
check_loss_output
(self, result)
tests/test_modeling_roberta.py:103
↓ 4 callers
Method
evaluate
Prediction/evaluation loop, shared by `evaluate()` and `predict()`.
src/transformers/trainer_tf.py:266
↓ 4 callers
Function
floats_tensor
Creates a random float32 tensor
tests/test_modeling_common.py:837
↓ 4 callers
Function
generic_train
( model: BaseTransformer, args: argparse.Namespace, early_stopping_callback=False, logger=True
examples/lightning_base.py:276
↓ 4 callers
Method
get_decoder
(self)
src/transformers/modeling_t5.py:880
↓ 4 callers
Method
get_dev_examples
See base class.
examples/multiple-choice/utils_multiple_choice.py:408
↓ 4 callers
Method
get_output_embeddings
(self)
templates/adding_a_new_model/modeling_xxx.py:428
↓ 4 callers
Method
get_train_examples
See base class.
examples/multiple-choice/utils_multiple_choice.py:403
↓ 4 callers
Function
glue_compute_metrics
(task_name, preds, labels)
src/transformers/data/metrics/__init__.py:53
↓ 4 callers
Function
h
(e,t,o)
docs/source/_static/js/custom.js:246
↓ 4 callers
Function
invert_mask
Turns 1->0, 0->1, False->True, True-> False
src/transformers/modeling_bart.py:109
↓ 4 callers
Function
is_psutil_available
()
src/transformers/file_utils.py:143
↓ 4 callers
Method
login
Call HF API to sign in a user and get a token if credentials are valid. Outputs: token if credentials are valid
src/transformers/hf_api.py:102
↓ 4 callers
Method
model_list
Get the public list of all the models on huggingface, including the community models
src/transformers/hf_api.py:195
↓ 4 callers
Method
prepare_config_and_inputs
(self)
tests/test_modeling_openai.py:63
↓ 4 callers
Method
prepare_config_and_inputs
(self)
tests/test_modeling_tf_openai_gpt.py:64
↓ 4 callers
Function
process_story
Extract the story and summary from a story file. Arguments: raw_story (str): content of the story file as an utf-8 encoded string.
examples/seq2seq/bertabs/utils_summarization.py:62
↓ 4 callers
Function
r
(n)
docs/source/_static/js/custom.js:246
↓ 4 callers
Method
reset
Resets the accumulated gradients on the current replica.
src/transformers/optimization_tf.py:262
↓ 4 callers
Function
s
(e,t,o)
docs/source/_static/js/custom.js:246
↓ 4 callers
Method
save_model
Save the pretrained model.
src/transformers/trainer_tf.py:492
↓ 4 callers
Function
separate_process_wrapper_fn
This function wraps another function into its own separated process. In order to ensure accurate memory measurements it is important
src/transformers/benchmark/benchmark_utils.py:64
↓ 4 callers
Function
set_param
(torch_layer, weight, bias=None)
src/transformers/convert_reformer_trax_checkpoint_to_pytorch.py:31
↓ 4 callers
Method
set_seed
(self)
tests/test_modeling_tf_xlnet.py:129
↓ 4 callers
Method
to_json_file
Save this instance to a json file.
src/transformers/modelcard.py:211
↓ 4 callers
Method
train
Train method to train the model.
src/transformers/trainer_tf.py:283
↓ 4 callers
Method
transform
Scikit / Keras interface to transformers' pipelines. This method will forward to __call__().
src/transformers/pipelines.py:418
↓ 4 callers
Function
truncate_or_pad
Adapt the source and target sequences' lengths to the block size. If the sequence is shorter we append padding token to the right of the sequence
examples/seq2seq/bertabs/utils_summarization.py:110
↓ 4 callers
Function
whitespace_tokenize
Runs basic whitespace cleaning and splitting on a piece of text.
src/transformers/tokenization_bert.py:111
↓ 3 callers
Function
Body
(*x, **y)
src/transformers/commands/serving.py:21
↓ 3 callers
Method
__init__
(self, config)
src/transformers/modeling_ctrl.py:299
↓ 3 callers
Method
__init__
TFConv1D layer as defined by Radford et al. for OpenAI GPT (and also used in GPT-2) Basically works like a Linear layer but the weights a
src/transformers/modeling_tf_utils.py:1590
↓ 3 callers
Method
__init__
(self, *args, **kwargs)
src/transformers/tokenization_transfo_xl.py:708
↓ 3 callers
Function
_config_zero_init
(config)
tests/test_modeling_common.py:45
↓ 3 callers
Method
_create_and_check_torchscript
(self, config, inputs_dict)
tests/test_modeling_common.py:238
↓ 3 callers
Method
_create_examples
Creates examples for the training, dev and test sets.
src/transformers/data/processors/glue.py:196
↓ 3 callers
Method
_create_examples
Creates examples for the training, dev and test sets.
src/transformers/data/processors/glue.py:238
↓ 3 callers
Method
_create_examples
Creates examples for the training, dev and test sets.
src/transformers/data/processors/glue.py:292
↓ 3 callers
Method
_create_examples
Creates examples for the training, dev and test sets.
src/transformers/data/processors/glue.py:335
↓ 3 callers
Method
_create_examples
Creates examples for the training, dev and test sets.
src/transformers/data/processors/glue.py:377
↓ 3 callers
Method
_create_examples
Creates examples for the training, dev and test sets.
src/transformers/data/processors/glue.py:467
↓ 3 callers
Method
_create_examples
Creates examples for the training, dev and test sets.
src/transformers/data/processors/glue.py:509
↓ 3 callers
Method
_create_examples
Creates examples for the training, dev and test sets.
src/transformers/data/processors/glue.py:551
↓ 3 callers
Method
_create_examples
Creates examples for the training and dev sets.
examples/multiple-choice/utils_multiple_choice.py:280
↓ 3 callers
Method
_create_examples
Creates examples for the training and dev sets.
examples/multiple-choice/utils_multiple_choice.py:330
↓ 3 callers
Method
_create_examples
Creates examples for the training and dev sets.
examples/multiple-choice/utils_multiple_choice.py:379
↓ 3 callers
Method
_create_examples
Creates examples for the training and dev sets.
examples/multiple-choice/utils_multiple_choice.py:426
↓ 3 callers
Method
_get_padding_truncation_strategies
Find the correct padding/truncation strategy with backward compatibility for old arguments (truncation_strategy and pad_to_max_length) an
src/transformers/tokenization_utils_base.py:1433
↓ 3 callers
Method
_log
(self, logs: Dict[str, float], iterator: Optional[tqdm] = None)
src/transformers/trainer.py:542
↓ 3 callers
Method
_look_adjacent
Used to implement attention between consecutive chunks. Args: vectors: array of shape [batch_size, num_attention_heads,
src/transformers/modeling_reformer.py:244
↓ 3 callers
Function
_prepare_bart_decoder_inputs
Prepare masks that ignore padding tokens in the decoder and a causal mask for the decoder if none are provided. This mimics the default behavior i
src/transformers/modeling_bart.py:115
↓ 3 callers
Method
_read_csv
(self, input_file)
examples/multiple-choice/utils_multiple_choice.py:326
↓ 3 callers
Method
_read_csv
(self, input_file)
examples/multiple-choice/utils_multiple_choice.py:375
↓ 3 callers
Method
_read_json
(self, input_file)
examples/multiple-choice/utils_multiple_choice.py:421
↓ 3 callers
Method
_read_txt
(self, input_dir)
examples/multiple-choice/utils_multiple_choice.py:270
↓ 3 callers
Method
_test_export
(self, model, framework, opset, tokenizer=None)
tests/test_onnx.py:52
↓ 3 callers
Function
add_generic_args
(parser, root_dir)
examples/lightning_base.py:235
↓ 3 callers
Method
assertListAlmostEqual
(self, list1, list2, tol)
tests/test_optimization_tf.py:17
↓ 3 callers
Method
assert_dump_and_restore
(self, be_original: BatchEncoding, equal_op: Optional[Callable] = None)
tests/test_tokenization_utils.py:39
↓ 3 callers
Method
avg_representation
(self, x)
examples/text-generation/pplm/run_pplm_discrim_train.py:65
↓ 3 callers
Method
build
(self, input_shape)
src/transformers/modeling_tf_transfo_xl.py:763
↓ 3 callers
Function
compute_heads_importance
This method shows how to compute: - head attention entropy - head importance scores according to http://arxiv.org/abs/1905.10650
examples/bertology/run_bertology.py:66
↓ 3 callers
Function
compute_predictions_log_probs
XLNet write prediction logic (more complex than Bert's). Write final predictions to the json file and log-odds of null if needed. Re
src/transformers/data/metrics/squad_metrics.py:576
↓ 3 callers
Function
compute_predictions_logits
Write final predictions to the json file and log-odds of null if needed.
src/transformers/data/metrics/squad_metrics.py:371
↓ 3 callers
Function
convert
(source_dir: Path, dest_dir)
src/transformers/convert_marian_to_pytorch.py:494
↓ 3 callers
Function
convert_examples_to_features
Loads a data file into a list of `InputFeatures`
examples/multiple-choice/utils_multiple_choice.py:491
↓ 3 callers
Function
convert_opus_name_to_hf_name
(x)
src/transformers/convert_marian_to_pytorch.py:136
↓ 3 callers
Method
convert_tokens_to_string
Converts a sequence of tokens (string) in a single string.
src/transformers/tokenization_t5.py:191
↓ 3 callers
Function
copy_layers
(teacher_layers: nn.ModuleList, student_layers: nn.ModuleList, layers_to_copy: List)
examples/seq2seq/initialization_utils.py:17
↓ 3 callers
Function
default_data_collator
Very simple data collator that: - simply collates batches of dict-like objects - Performs special handling for potential keys named:
src/transformers/data/data_collator.py:19
↓ 3 callers
Function
embed_passages_for_retrieval
(passages, tokenizer, qa_embedder, max_length=128, device="cuda:0")
examples/longform-qa/eli5_utils.py:533
↓ 3 callers
Function
embed_questions_for_retrieval
(q_ls, tokenizer, qa_embedder, device="cuda:0")
examples/longform-qa/eli5_utils.py:544
↓ 3 callers
Method
get_dataloader
(self, type_path: str, batch_size: int, shuffle: bool = False)
examples/seq2seq/finetune.py:192
↓ 3 callers
Method
get_examples_from_dataset
Creates a list of :class:`~transformers.data.processors.squad.SquadExample` using a TFDS dataset. Args: dataset: The tfd
src/transformers/data/processors/squad.py:482
↓ 3 callers
Function
get_labels
(path: str)
examples/token-classification/utils_ner.py:390
↓ 3 callers
Function
get_masks
Generate hidden states mask, and optionally an attention mask.
src/transformers/modeling_xlm.py:68
↓ 3 callers
Method
get_test_examples
(self, data_dir)
examples/multiple-choice/utils_multiple_choice.py:413
↓ 3 callers
Method
get_tokenizer
(self, **kwargs)
tests/test_tokenization_common.py:101
↓ 3 callers
Function
glue_convert_examples_to_features
Loads a data file into a list of ``InputFeatures`` Args: examples: List of ``InputExamples`` or ``tf.data.Dataset`` containing the e
src/transformers/data/processors/glue.py:34
↓ 3 callers
Function
grad_status
(model: nn.Module)
examples/seq2seq/utils.py:244
↓ 3 callers
Function
infer_shapes
(nlp: Pipeline, framework: str)
src/transformers/convert_graph_to_onnx.py:69
↓ 3 callers
Function
make_test_data_dir
(**kwargs)
examples/seq2seq/test_seq2seq_examples.py:96
↓ 3 callers
Function
merge_model_tokenizer_mappings
( model_mapping: Dict["PretrainedConfig", Union["PreTrainedModel", "TFPreTrainedModel"]], tokenizer_ma
tests/test_tokenization_common.py:37
↓ 3 callers
Function
normalize_answer
Lower text and remove punctuation, articles and extra whitespace.
src/transformers/data/metrics/squad_metrics.py:24
↓ 3 callers
Function
prepare_bart_inputs_dict
( config, input_ids, attention_mask=None, )
tests/test_modeling_bart.py:101
↓ 3 callers
Method
prepare_config_and_inputs
(self)
tests/test_modeling_transfo_xl.py:57
↓ 3 callers
Method
prepare_config_and_inputs
(self)
tests/test_modeling_tf_transfo_xl.py:61
↓ 3 callers
Method
prepare_config_and_inputs
(self)
tests/test_modeling_tf_ctrl.py:59
↓ 3 callers
Method
prepare_config_and_inputs
(self)
tests/test_modeling_ctrl.py:58
↓ 3 callers
Function
prune_conv1d_layer
Prune a Conv1D layer (a model parameters) to keep only entries in index. A Conv1D work as a Linear layer (see e.g. BERT) but the weights are
src/transformers/modeling_utils.py:2122
← previous
next →
201–300 of 4,119, ranked by callers