Transformers documentation

通用工具

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

通用工具

此页面列出了在utils.py文件中找到的所有Transformers通用实用函数。

其中大多数仅在您研究库中的通用代码时才有用。

Enums和namedtuples(命名元组)

class transformers.utils.ExplicitEnum

< >

( valuenames = Nonemodule = Nonequalname = Nonetype = Nonestart = 1 )

Enum with more explicit error message for missing values.

class transformers.utils.PaddingStrategy

< >

( valuenames = Nonemodule = Nonequalname = Nonetype = Nonestart = 1 )

Possible values for the padding argument in PreTrainedTokenizerBase.call(). Useful for tab-completion in an IDE.

class transformers.TensorType

< >

( valuenames = Nonemodule = Nonequalname = Nonetype = Nonestart = 1 )

Possible values for the return_tensors argument in PreTrainedTokenizerBase.call(). Useful for tab-completion in an IDE.

特殊的装饰函数

transformers.add_start_docstrings

< >

( *docstr )

transformers.utils.add_start_docstrings_to_model_forward

< >

( *docstr )

transformers.add_end_docstrings

< >

( *docstr )

transformers.utils.add_code_sample_docstrings

< >

( *docstrprocessor_class = Nonecheckpoint = Noneoutput_type = Noneconfig_class = Nonemask = '[MASK]'qa_target_start_index = 14qa_target_end_index = 15model_cls = Nonemodality = Noneexpected_output = Noneexpected_loss = Nonereal_checkpoint = Nonerevision = None )

transformers.utils.replace_return_docstrings

< >

( output_type = Noneconfig_class = None )

其他实用程序

class transformers.utils._LazyModule

< >

( name: strmodule_file: strimport_structure: dictmodule_spec: _frozen_importlib.ModuleSpec | None = Noneextra_objects: dict[str, object] | None = Noneexplicit_import_shortcut: dict[str, list[str]] | None = None )

Module class that surfaces all objects but only performs associated imports when the objects are requested.

Update on GitHub