pytext.config package¶
Submodules¶
pytext.config.component module¶
-
class
pytext.config.component.
ComponentType
[source]¶ Bases:
enum.Enum
An enumeration.
-
BATCHER
= 'batcher'¶
-
BATCH_SAMPLER
= 'batch_sampler'¶
-
COLUMN
= 'column'¶
-
DATA_HANDLER
= 'data_handler'¶
-
DATA_SOURCE
= 'data_source'¶
-
DATA_TYPE
= 'data_type'¶
-
EXPORTER
= 'exporter'¶
-
FEATURIZER
= 'featurizer'¶
-
LOSS
= 'loss'¶
-
MASKING_FUNCTION
= 'masking_function'¶
-
METRIC_REPORTER
= 'metric_reporter'¶
-
MODEL
= 'model'¶
-
MODEL2
= 'model2'¶
-
MODULE
= 'module'¶
-
OPTIMIZER
= 'optimizer'¶
-
PREDICTOR
= 'predictor'¶
-
PRIVACY_ENGINE
= 'privacy_engine'¶
-
SCHEDULER
= 'scheduler'¶
-
SPARSIFIER
= 'sparsifier'¶
-
TASK
= 'task'¶
-
TENSORIZER
= 'tensorizer'¶
-
TOKENIZER
= 'tokenizer'¶
-
TRAINER
= 'trainer'¶
-
-
class
pytext.config.component.
Registry
[source]¶ Bases:
object
-
classmethod
add
(component_type: pytext.config.component.ComponentType, cls_to_add: Type[CT_co], config_cls: Type[CT_co])[source]¶
-
classmethod
configs
(component_type: pytext.config.component.ComponentType) → Tuple[Type[CT_co], ...][source]¶
-
classmethod
-
pytext.config.component.
create_component
(component_type: pytext.config.component.ComponentType, config: Any, *args, **kwargs)[source]¶
-
pytext.config.component.
create_optimizer
(optimizer_config, model: torch.nn.modules.module.Module, *args, **kwargs)[source]¶
-
pytext.config.component.
create_trainer
(trainer_config, model: torch.nn.modules.module.Module, *args, **kwargs)[source]¶
pytext.config.config_adapter module¶
-
pytext.config.config_adapter.
doc_model_deprecated
(json_config)[source]¶ Rename DocModel to DocModel_Deprecated.
-
pytext.config.config_adapter.
ensemble_task_deprecated
(json_config)[source]¶ Rename tasks with new API consistently
-
pytext.config.config_adapter.
fix_fl_local_optimizer_and_trainer
(json_config)[source]¶ a) Change FL local optimizer from optimizer:{SGD:{lr=0.1, momentum=0.2}} to optimizer:{lr=0.1, momentum=0.2} b) Replace trainer:{FLSyncTrainer:{foo}} by trainer:{fl_trainer:{foo, type:SyncTrainer}} Same for FLAsyncTrainer
-
pytext.config.config_adapter.
get_name_from_options
(export_config)[source]¶ Reverse engineer which model is which based on recognized export configurations. If the export configurations don’t adhere to the set of recognized backends, then set target name to unknown
-
pytext.config.config_adapter.
is_type_specifier
(json_dict)[source]¶ If a config object is a class, it might have a level which is a type specifier, with one key corresponding to the name of whichever type it is. These types should not be explicitly named in the path.
-
pytext.config.config_adapter.
lm_model_deprecated
(json_config)[source]¶ Rename LM model to _Deprecated (LMTask is already deprecated in v5)
-
pytext.config.config_adapter.
new_tasks_rename
(json_config)[source]¶ Rename tasks with new API consistently
-
pytext.config.config_adapter.
old_tasks_deprecated
(json_config)[source]¶ Rename tasks with data_handler config to _Deprecated
-
pytext.config.config_adapter.
rename_bitransformer_inputs
(json_config)[source]¶ In “BiTransformer” model, rename input “characters” -> “bytes” and update subfields.
-
pytext.config.config_adapter.
rename_parameter
(config, old_path, new_path, transform=<function <lambda>>)[source]¶ A powerful tool for writing config adapters, this allows you to specify a JSON-style path for an old and new config parameter. For instance
rename_parameter(config, “task.data.epoch_size”, “task.trainer.batches_per_epoch”)
will look through the config for task.data.epoch_size, including moving through explicitly specified types. If it’s specified, it will delete the value and set it in task.trainer.num_batches_per_epoch instead, creating trainer as an empty dictionary if necessary.
-
pytext.config.config_adapter.
upgrade_export_config
(json_config)[source]¶ Upgrade model export related config fields to the new “export” section.
-
pytext.config.config_adapter.
upgrade_if_xlm
(json_config)[source]¶ Make XLMModel Union changes for encoder and tokens config. Since they are now unions, insert the old class into the config if no class name is mentioned.
-
pytext.config.config_adapter.
upgrade_padding
(json_config)[source]¶ Upgrade config option padding_control to seq_padding_control.
-
pytext.config.config_adapter.
v12_to_v13
(json_config)[source]¶ remove_output_encoded_layers(json_config)
-
pytext.config.config_adapter.
v22_to_v23
(json_config)[source]¶ Upgrade by adding read_chunk_size option
-
pytext.config.config_adapter.
v23_to_v22
(json_config)[source]¶ Upgrade by removing read_chunk_size option
-
pytext.config.config_adapter.
v24_to_v23
(json_config)[source]¶ Downgrade by removing export_list option
-
pytext.config.config_adapter.
v24_to_v25
(json_config)[source]¶ Upgrade by adding max_input_text_length option and default to None
-
pytext.config.config_adapter.
v25_to_v24
(json_config)[source]¶ Downgrade by removing max_input_text_length option for SentencePieceTokenizer
-
pytext.config.config_adapter.
v26_to_v25
(json_config)[source]¶ Downgrade by removing target option from all exports in export_list
-
pytext.config.config_adapter.
v2_to_v3
(json_config)[source]¶ Optimizer and Scheduler configs used to be part of the task config, they now live in the trainer’s config.
pytext.config.contextual_intent_slot module¶
-
class
pytext.config.contextual_intent_slot.
ExtraField
[source]¶ Bases:
object
-
DOC_WEIGHT
= 'doc_weight'¶
-
RAW_WORD_LABEL
= 'raw_word_label'¶
-
TOKEN_RANGE
= 'token_range'¶
-
UTTERANCE
= 'utterance'¶
-
WORD_WEIGHT
= 'word_weight'¶
-
-
class
pytext.config.contextual_intent_slot.
ModelInput
[source]¶ Bases:
object
-
CHAR
= 'char_feat'¶
-
CONTEXTUAL_TOKEN_EMBEDDING
= 'contextual_token_embedding'¶
-
DENSE
= 'dense_feat'¶
-
DICT
= 'dict_feat'¶
-
SEQ
= 'seq_word_feat'¶
-
TEXT
= 'word_feat'¶
-
-
class
pytext.config.contextual_intent_slot.
ModelInputConfig
(**kwargs)[source]¶ Bases:
pytext.config.module_config.Module.Config
-
char_feat
= None¶
-
contextual_token_embedding
= None¶
-
dense_feat
= None¶
-
dict_feat
= None¶
-
seq_word_feat
= <pytext.config.field_config.WordFeatConfig object>¶
-
word_feat
= <pytext.config.field_config.WordFeatConfig object>¶
-
pytext.config.doc_classification module¶
pytext.config.field_config module¶
-
pytext.config.field_config.
ContextualTokenEmbeddingConfig
[source]¶ alias of
pytext.config.field_config.ContextualTokenEmbeddingConfig
-
class
pytext.config.field_config.
DocLabelConfig
(**kwargs)[source]¶ Bases:
pytext.config.pytext_config.ConfigBase
-
export_output_names
= ['doc_scores']¶
-
label_weights
= {}¶
-
target_prob
= False¶
-
-
class
pytext.config.field_config.
EmbedInitStrategy
[source]¶ Bases:
enum.Enum
An enumeration.
-
RANDOM
= 'random'¶
-
ZERO
= 'zero'¶
-
-
class
pytext.config.field_config.
FeatureConfig
(**kwargs)[source]¶ Bases:
pytext.config.module_config.Module.Config
-
char_feat
= None¶
-
contextual_token_embedding
= None¶
-
dense_feat
= None¶
-
dict_feat
= None¶
-
seq_word_feat
= None¶
-
word_feat
= <pytext.config.field_config.WordFeatConfig object>¶
-
-
class
pytext.config.field_config.
FloatVectorConfig
(**kwargs)[source]¶ Bases:
pytext.config.pytext_config.ConfigBase
-
dim
= 0¶
-
dim_error_check
= False¶
-
export_input_names
= ['float_vec_vals']¶
-
-
class
pytext.config.field_config.
Target
[source]¶ Bases:
object
-
DOC_LABEL
= 'doc_label'¶
-
TARGET_LABEL_FIELD
= 'target_label'¶
-
TARGET_LOGITS_FIELD
= 'target_logit'¶
-
TARGET_PROB_FIELD
= 'target_prob'¶
-
-
class
pytext.config.field_config.
WordLabelConfig
(**kwargs)[source]¶ Bases:
pytext.config.pytext_config.ConfigBase
-
export_output_names
= ['word_scores']¶
-
use_bio_labels
= False¶
-
pytext.config.module_config module¶
-
class
pytext.config.module_config.
Activation
[source]¶ Bases:
enum.Enum
An enumeration.
-
GELU
= 'gelu'¶
-
GLU
= 'glu'¶
-
LEAKYRELU
= 'leakyrelu'¶
-
RELU
= 'relu'¶
-
TANH
= 'tanh'¶
-
-
class
pytext.config.module_config.
CNNParams
(**kwargs)[source]¶ Bases:
pytext.config.pytext_config.ConfigBase
-
causal
= False¶
-
dilated
= False¶
-
kernel_num
= 100¶
-
kernel_sizes
= [3, 4]¶
-
weight_norm
= False¶
-
-
class
pytext.config.module_config.
ExporterType
[source]¶ Bases:
enum.Enum
An enumeration.
-
INIT_PREDICT
= 'init_predict'¶
-
PREDICTOR
= 'predictor'¶
-
-
class
pytext.config.module_config.
PerplexityType
[source]¶ Bases:
enum.Enum
An enumeration.
-
EOS
= 'eos'¶
-
MAX
= 'max'¶
-
MEAN
= 'mean'¶
-
MEDIAN
= 'median'¶
-
MIN
= 'min'¶
-
pytext.config.pair_classification module¶
-
class
pytext.config.pair_classification.
ExtraField
[source]¶ Bases:
object
-
UTTERANCE_PAIR
= 'utterance'¶
-
pytext.config.pytext_config module¶
-
class
pytext.config.pytext_config.
ExportConfig
(**kwargs)[source]¶ Bases:
pytext.config.pytext_config.ConfigBase
-
accelerate
= []¶
-
batch_padding_control
= None¶
-
export_caffe2_path
= None¶
-
export_lite_path
= None¶
-
export_onnx_path
= '/tmp/model.onnx'¶
-
export_torchscript_path
= None¶
-
inference_interface
= None¶
-
seq_padding_control
= None¶
-
target
= ''¶
-
torchscript_quantize
= False¶
-
-
class
pytext.config.pytext_config.
LogitsConfig
(**kwargs)[source]¶ Bases:
pytext.config.pytext_config.TestConfig
-
batch_size
= 16¶
-
dump_raw_input
= False¶
-
fp16
= False¶
-
gpus
= 1¶
-
ndigits_precision
= 0¶
-
output_columns
= None¶
-
use_gzip
= False¶
-
-
class
pytext.config.pytext_config.
PyTextConfig
(**kwargs)[source]¶ Bases:
pytext.config.pytext_config.ConfigBase
-
accelerate
¶
-
auto_resume_from_snapshot
= False¶
-
batch_padding_control
¶
-
debug_path
= '/tmp/model.debug'¶
-
distributed_world_size
= 1¶
-
export
= <pytext.config.pytext_config.ExportConfig object>¶
-
export_caffe2_path
¶
-
export_list
= []¶
-
export_onnx_path
¶
-
export_torchscript_path
¶
-
gpu_streams_for_distributed_training
= 1¶
-
include_dirs
= None¶
-
inference_interface
¶
-
load_snapshot_path
= ''¶
-
modules_save_dir
= ''¶
-
random_seed
= 0¶ Seed value to seed torch, python, and numpy random generators.
-
read_chunk_size
= 1000000000¶
-
report_eval_results
= False¶
-
report_test_results
= True¶
-
save_all_checkpoints
= False¶
-
save_module_checkpoints
= False¶
-
save_snapshot_path
= '/tmp/model.pt'¶
-
seq_padding_control
¶
-
target
¶
-
test_out_path
= '/tmp/test_out.txt'¶
-
torchscript_quantize
¶
-
use_config_from_snapshot
= True¶
-
use_cuda_for_testing
= True¶
-
use_cuda_if_available
= True¶
-
use_deterministic_cudnn
= False¶ Whether to allow CuDNN to behave deterministically.
-
use_fp16
= False¶
-
use_tensorboard
= True¶
-
-
class
pytext.config.pytext_config.
TestConfig
(**kwargs)[source]¶ Bases:
pytext.config.pytext_config.ConfigBase
-
field_names
= None¶ Field names for the TSV. If this is not set, the first line of each file will be assumed to be a header containing the field names.
-
test_out_path
= ''¶
-
test_path
= 'test.tsv'¶
-
use_cuda_if_available
= True¶
-
use_fp16
= False¶
-
use_tensorboard
= True¶
-
pytext.config.query_document_pairwise_ranking module¶
-
class
pytext.config.query_document_pairwise_ranking.
ModelInput
[source]¶ Bases:
object
-
NEG_RESPONSE
= 'neg_response'¶
-
POS_RESPONSE
= 'pos_response'¶
-
QUERY
= 'query'¶
-
-
class
pytext.config.query_document_pairwise_ranking.
ModelInputConfig
(**kwargs)[source]¶ Bases:
pytext.config.module_config.Module.Config
-
neg_response
= <pytext.config.field_config.WordFeatConfig object>¶
-
pos_response
= <pytext.config.field_config.WordFeatConfig object>¶
-
query
= <pytext.config.field_config.WordFeatConfig object>¶
-
pytext.config.serialize module¶
-
pytext.config.serialize.
component_config_type_from_type_name
(cls, type_name: str) → Type[CT_co][source]¶