pytext.torchscript package¶
Subpackages¶
- pytext.torchscript.seq2seq package
- Submodules
- pytext.torchscript.seq2seq.beam_decode module
- pytext.torchscript.seq2seq.beam_search module
- pytext.torchscript.seq2seq.decoder module
- pytext.torchscript.seq2seq.encoder module
- pytext.torchscript.seq2seq.export_model module
- pytext.torchscript.seq2seq.scripted_seq2seq_generator module
- pytext.torchscript.seq2seq.seq2seq_rnn_decoder_utils module
- Module contents
- pytext.torchscript.tensorizer package
- pytext.torchscript.tokenizer package
Submodules¶
pytext.torchscript.batchutils module¶
-
pytext.torchscript.batchutils.
clip_list
(input: Optional[List[str]], max_batch: int) → Optional[List[str]][source]¶
-
pytext.torchscript.batchutils.
clip_listlist
(input: Optional[List[List[str]]], max_batch: int) → Optional[List[List[str]]][source]¶
-
pytext.torchscript.batchutils.
clip_listlist_float
(input: Optional[List[List[float]]], max_batch: int) → Optional[List[List[float]]][source]¶
-
pytext.torchscript.batchutils.
destructure_any_list
(client_batch: List[int], result_any_list: List[Any])[source]¶
-
pytext.torchscript.batchutils.
destructure_dict_list
(client_batch: List[int], result_input_list: List[Dict[str, float]]) → List[List[Dict[str, float]]][source]¶
-
pytext.torchscript.batchutils.
destructure_dictlist_list
(client_batch: List[int], result_input_list: List[List[Dict[str, float]]]) → List[List[List[Dict[str, float]]]][source]¶
-
pytext.torchscript.batchutils.
destructure_tensor
(client_batch: List[int], result_tensor: torch.Tensor) → List[torch.Tensor][source]¶
-
pytext.torchscript.batchutils.
destructure_tensor_list
(client_batch: List[int], result_tensor_list: List[torch.Tensor]) → List[List[torch.Tensor]][source]¶
-
pytext.torchscript.batchutils.
input_size
(texts: Optional[List[str]] = None, multi_texts: Optional[List[List[str]]] = None, tokens: Optional[List[List[str]]] = None) → int[source]¶
-
pytext.torchscript.batchutils.
limit_list
(input: Optional[List[str]], max_batch: int) → Optional[List[str]][source]¶
-
pytext.torchscript.batchutils.
limit_listlist
(input: Optional[List[List[str]]], max_batch: int) → Optional[List[List[str]]][source]¶
-
pytext.torchscript.batchutils.
limit_listlist_float
(input: Optional[List[List[float]]], max_batch: int) → Optional[List[List[float]]][source]¶
-
pytext.torchscript.batchutils.
make_batch_texts
(tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, mega_batch: List[Tuple[List[str], int]], goals: Dict[str, str]) → List[List[Tuple[List[str], int]]][source]¶
-
pytext.torchscript.batchutils.
make_batch_texts_dense
(tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, mega_batch: List[Tuple[List[str], List[List[float]], int]], goals: Dict[str, str]) → List[List[Tuple[List[str], List[List[float]], int]]][source]¶
-
pytext.torchscript.batchutils.
make_prediction_texts
(batch: List[Tuple[List[str]]]) → List[str][source]¶
-
pytext.torchscript.batchutils.
make_prediction_texts_dense
(batch: List[Tuple[List[str], List[List[float]]]]) → Tuple[List[str], List[List[float]]][source]¶
-
pytext.torchscript.batchutils.
make_prediction_tokens
(batch: List[Tuple[List[List[str]]]]) → List[List[str]][source]¶
-
pytext.torchscript.batchutils.
max_tokens
(per_sentence_tokens: List[List[Tuple[str, int, int]]]) → int[source]¶ receive the tokenize output for a batch per_sentence_tokens, return the max token length of any sentence
-
pytext.torchscript.batchutils.
nonify_listlist_float
(input: List[List[float]]) → Optional[List[List[float]]][source]¶
-
pytext.torchscript.batchutils.
validate_batch_element
(e: Tuple[Optional[List[str]], Optional[List[List[str]]], Optional[List[List[str]]], Optional[List[str]], Optional[List[List[float]]]])[source]¶
-
pytext.torchscript.batchutils.
validate_dense_feat
(batch_element_dense_feat: Optional[List[List[float]]], length: int, uses_dense_feat: bool) → List[List[float]][source]¶
-
pytext.torchscript.batchutils.
validate_make_prediction_batch_element
(be: Tuple[Optional[List[str]], Optional[List[List[str]]], Optional[List[List[str]]], Optional[List[str]], Optional[List[List[float]]]])[source]¶
pytext.torchscript.module module¶
-
class
pytext.torchscript.module.
PyTextEmbeddingModule
(model: torch.jit._script.ScriptModule, tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer)[source]¶ Bases:
torch.jit._script.ScriptModule
-
class
pytext.torchscript.module.
PyTextEmbeddingModuleIndex
(model: torch.jit._script.ScriptModule, tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, index: int = 0)[source]¶
-
class
pytext.torchscript.module.
PyTextEmbeddingModuleWithDense
(model: torch.jit._script.ScriptModule, tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, normalizer: pytext.torchscript.tensorizer.normalizer.VectorNormalizer, concat_dense: bool = False)[source]¶
-
class
pytext.torchscript.module.
PyTextEmbeddingModuleWithDenseIndex
(model: torch.jit._script.ScriptModule, tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, normalizer: pytext.torchscript.tensorizer.normalizer.VectorNormalizer, index: int = 0, concat_dense: bool = True)[source]¶ Bases:
pytext.torchscript.module.PyTextEmbeddingModuleWithDense
-
class
pytext.torchscript.module.
PyTextLayerModule
(model: torch.jit._script.ScriptModule, output_layer: torch.jit._script.ScriptModule, tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer)[source]¶
-
class
pytext.torchscript.module.
PyTextLayerModuleWithDense
(model: torch.jit._script.ScriptModule, output_layer: torch.jit._script.ScriptModule, tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, normalizer: pytext.torchscript.tensorizer.normalizer.VectorNormalizer)[source]¶ Bases:
pytext.torchscript.module.PyTextEmbeddingModuleWithDense
-
class
pytext.torchscript.module.
PyTextTwoTowerEmbeddingModule
(model: torch.jit._script.ScriptModule, right_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, left_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer)[source]¶ Bases:
torch.jit._script.ScriptModule
-
class
pytext.torchscript.module.
PyTextTwoTowerEmbeddingModuleWithDense
(model: torch.jit._script.ScriptModule, right_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, left_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, right_normalizer: pytext.torchscript.tensorizer.normalizer.VectorNormalizer, left_normalizer: pytext.torchscript.tensorizer.normalizer.VectorNormalizer)[source]¶ Bases:
pytext.torchscript.module.PyTextTwoTowerEmbeddingModule
-
class
pytext.torchscript.module.
PyTextTwoTowerLayerModule
(model: torch.jit._script.ScriptModule, output_layer: torch.jit._script.ScriptModule, right_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, left_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer)[source]¶ Bases:
pytext.torchscript.module.PyTextTwoTowerEmbeddingModule
-
class
pytext.torchscript.module.
PyTextTwoTowerLayerModuleWithDense
(model: torch.jit._script.ScriptModule, output_layer: torch.jit._script.ScriptModule, right_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, left_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, right_normalizer: pytext.torchscript.tensorizer.normalizer.VectorNormalizer, left_normalizer: pytext.torchscript.tensorizer.normalizer.VectorNormalizer)[source]¶
-
class
pytext.torchscript.module.
PyTextVariableSizeEmbeddingModule
(model: torch.jit._script.ScriptModule, tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer)[source]¶ Bases:
pytext.torchscript.module.PyTextEmbeddingModule
Assumes model returns a tuple of representations and sequence lengths, then slices each example’s representation according to length. Returns a list of tensors. The slicing is easier to do outside a traced model.
-
class
pytext.torchscript.module.
ScriptPyTextEmbeddingModule
(model: torch.jit._script.ScriptModule, tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer)[source]¶ Bases:
torch.jit._script.ScriptModule
-
class
pytext.torchscript.module.
ScriptPyTextEmbeddingModuleIndex
(model: torch.jit._script.ScriptModule, tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, index: int = 0)[source]¶ Bases:
pytext.torchscript.module.ScriptPyTextEmbeddingModule
-
class
pytext.torchscript.module.
ScriptPyTextEmbeddingModuleWithDense
(model: torch.jit._script.ScriptModule, tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, normalizer: pytext.torchscript.tensorizer.normalizer.VectorNormalizer, concat_dense: bool = False)[source]¶ Bases:
pytext.torchscript.module.ScriptPyTextEmbeddingModule
-
class
pytext.torchscript.module.
ScriptPyTextEmbeddingModuleWithDenseIndex
(model: torch.jit._script.ScriptModule, tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, normalizer: pytext.torchscript.tensorizer.normalizer.VectorNormalizer, index: int = 0, concat_dense: bool = True)[source]¶ Bases:
pytext.torchscript.module.ScriptPyTextEmbeddingModuleWithDense
-
class
pytext.torchscript.module.
ScriptPyTextModule
(model: torch.jit._script.ScriptModule, output_layer: torch.jit._script.ScriptModule, tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer)[source]¶ Bases:
pytext.torchscript.module.ScriptPyTextEmbeddingModule
-
class
pytext.torchscript.module.
ScriptPyTextModuleWithDense
(model: torch.jit._script.ScriptModule, output_layer: torch.jit._script.ScriptModule, tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, normalizer: pytext.torchscript.tensorizer.normalizer.VectorNormalizer)[source]¶ Bases:
pytext.torchscript.module.ScriptPyTextEmbeddingModuleWithDense
-
class
pytext.torchscript.module.
ScriptPyTextTwoTowerEmbeddingModule
(model: torch.jit._script.ScriptModule, right_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, left_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer)[source]¶
-
class
pytext.torchscript.module.
ScriptPyTextTwoTowerEmbeddingModuleWithDense
(model: torch.jit._script.ScriptModule, right_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, left_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, right_normalizer: pytext.torchscript.tensorizer.normalizer.VectorNormalizer, left_normalizer: pytext.torchscript.tensorizer.normalizer.VectorNormalizer)[source]¶ Bases:
pytext.torchscript.module.ScriptPyTextTwoTowerEmbeddingModule
-
class
pytext.torchscript.module.
ScriptPyTextTwoTowerModule
(model: torch.jit._script.ScriptModule, output_layer: torch.jit._script.ScriptModule, right_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, left_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer)[source]¶
-
class
pytext.torchscript.module.
ScriptPyTextTwoTowerModuleWithDense
(model: torch.jit._script.ScriptModule, output_layer: torch.jit._script.ScriptModule, right_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, left_tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer, right_normalizer: pytext.torchscript.tensorizer.normalizer.VectorNormalizer, left_normalizer: pytext.torchscript.tensorizer.normalizer.VectorNormalizer)[source]¶
-
class
pytext.torchscript.module.
ScriptPyTextVariableSizeEmbeddingModule
(model: torch.jit._script.ScriptModule, tensorizer: pytext.torchscript.tensorizer.tensorizer.ScriptTensorizer)[source]¶ Bases:
pytext.torchscript.module.ScriptPyTextEmbeddingModule
Assumes model returns a tuple of representations and sequence lengths, then slices each example’s representation according to length. Returns a list of tensors. The slicing is easier to do outside a traced model.
pytext.torchscript.utils module¶
-
class
pytext.torchscript.utils.
ScriptBatchInput
[source]¶ Bases:
tuple
A batch of inputs for TorchScript Module(bundle of Tensorizer and Model) texts or tokens is required but multually exclusive :param texts: a batch of raw text inputs :param tokens: a batch of pre-tokenized inputs :param languages: language for each input in the batch
-
languages
¶ Alias for field number 2
-
texts
¶ Alias for field number 0
-
tokens
¶ Alias for field number 1
-