ModelSpec
- class ctranslate2.specs.ModelSpec
The top level layer specification.
Inherits from:
ctranslate2.specs.LayerSpec
Extended by:
Attributes:
Methods:
- __init__()
Initializes the model specification.
- get_default_config()
Returns the default configuration used by this 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.
- 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).