WhisperSpec
- class ctranslate2.specs.WhisperSpec
Describes a Whisper model.
Inherits from:
ctranslate2.specs.LanguageModelSpec
Attributes:
Methods:
- __init__(num_layers, num_heads)
Initializes the model specification.
- Parameters
num_layers – The number of encoder and decoder layers.
num_heads – The number of attention heads.
- get_default_config()
Returns the default configuration used by this model.
- get_vocabulary_size()
Returns the 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_float16, int16, float16).
- register_vocabulary(tokens: List[str]) None
Registers the vocabulary of tokens.
- Parameters
tokens – List of tokens.
- 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).