SequenceToSequenceModelSpec
- class ctranslate2.specs.SequenceToSequenceModelSpec
Base specification for sequence to sequence models.
Inherits from:
ctranslate2.specs.ModelSpec
Extended by:
Attributes:
Methods:
- __init__()
Initializes a sequence to sequence model specification.
- get_default_config()
Returns the default configuration used by this model.
- abstract get_source_vocabulary_size()
Returns the source vocabulary size expected by the model.
- abstract get_target_vocabulary_size()
Returns the target vocabulary size expected by the model.
- optimize(quantization: Optional[str] = None) None
Recursively applies some optimizations to this layer:
Alias variables with the same shape and value.
Quantize weights.
- Parameters
quantization – Weight quantization scheme (possible values are: int8, int8_float32, int8_float16, int8_bfloat16, int16, float16, bfloat16, float32).
- register_file(path: str, filename: Optional[str] = None) None
Registers a file to be saved in the model directory.
- register_source_vocabulary(tokens: List[str]) None
Registers a source vocabulary of tokens.
- Parameters
tokens – List of source tokens.
- register_target_vocabulary(tokens: List[str]) None
Registers a target vocabulary of tokens.
- Parameters
tokens – List of target tokens.
- register_vocabulary_mapping(path: str) None
Registers a vocabulary mapping file.
- Parameters
path – Path to the vocabulary mapping file.
- save(output_dir: str) None
Saves this model on disk.
- Parameters
output_dir – Output directory where the model is saved.
- validate() None
Verify that the required weights are set.
- Raises
ValueError – If a required weight is not set in the specification.
- variables(prefix: str = '', ordered: bool = False) Dict[str, ndarray]
Recursively returns the weights from this layer and its children.
- Parameters
prefix – Prefix to prepend to all variable names.
ordered – If set, an ordered list is returned instead.
- Returns
Dictionary mapping variables name to value.
- property config
The model configuration.
- property name
The name of the model specification.
- property revision
The model specification revision.
This value is incremented each time the weights layout of the model is changed (e.g. a weight is renamed).