通用工具
此页面列出了在utils.py
文件中找到的所有Transformers通用实用函数。
其中大多数仅在您研究库中的通用代码时才有用。
Enums和namedtuples(命名元组)
class transformers.utils.ExplicitEnum
< source >( value names = None module = None qualname = None type = None start = 1 )
Enum with more explicit error message for missing values.
class transformers.utils.PaddingStrategy
< source >( value names = None module = None qualname = None type = None start = 1 )
Possible values for the padding
argument in PreTrainedTokenizerBase.call(). Useful for tab-completion in an
IDE.
class transformers.TensorType
< source >( value names = None module = None qualname = None type = None start = 1 )
Possible values for the return_tensors
argument in PreTrainedTokenizerBase.call(). Useful for
tab-completion in an IDE.
特殊的装饰函数
transformers.utils.add_code_sample_docstrings
< source >( *docstr processor_class = None checkpoint = None output_type = None config_class = None mask = '[MASK]' qa_target_start_index = 14 qa_target_end_index = 15 model_cls = None modality = None expected_output = None expected_loss = None real_checkpoint = None revision = None )
特殊的属性
class transformers.utils.cached_property
< source >( fget = None fset = None fdel = None doc = None )
Descriptor that mimics @property but caches output in member variable.
From tensorflow_datasets
Built-in in functools from Python 3.8.
其他实用程序
class transformers.utils._LazyModule
< source >( name: str module_file: str import_structure: Dict module_spec: ModuleSpec = None extra_objects: Dict = None )
Module class that surfaces all objects but only performs associated imports when the objects are requested.