notice
This is documentation for Rasa & Rasa Pro Documentation v2.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (3.x).
rasa.model
Section Objects
Specifies which fingerprint keys decide whether this sub-model is retrained.
FingerprintComparisonResult Objects
Container for the results of a fingerprint comparison.
__init__
Creates a FingerprintComparisonResult
instance.
Arguments:
nlu
-True
if the NLU model should be retrained.core
-True
if the Core model should be retrained.nlg
-True
if the responses in the domain should be updated.force_training
-True
if a training of all parts is forced.
is_training_required
Check if anything has to be retrained.
should_retrain_core
Check if the Core model has to be updated.
should_retrain_nlg
Check if the responses have to be updated.
should_retrain_nlu
Check if the NLU model has to be updated.
get_local_model
Returns verified path to local model archive.
Arguments:
model_path
- Path to the zipped model. If it's a directory, the latest trained model is returned.
Returns:
Path to the zipped model. If it's a directory, the latest trained model is returned.
Raises:
ModelNotFound Exception: When no model could be found at the provided path.
get_model
Gets a model and unpacks it.
Arguments:
model_path
- Path to the zipped model. If it's a directory, the latest trained model is returned.
Returns:
Path to the unpacked model.
Raises:
ModelNotFound Exception: When no model could be found at the provided path.
get_latest_model
Get the latest model from a path.
Arguments:
model_path
- Path to a directory containing zipped models.
Returns:
Path to latest model in the given directory.
unpack_model
Unpack a zipped Rasa model.
Arguments:
model_file
- Path to zipped model.working_directory
- Location where the model should be unpacked to. IfNone
a temporary directory will be created.
Returns:
Path to unpacked Rasa model.
get_model_subdirectories
Return paths for Core and NLU model directories, if they exist.
If neither directories exist, a ModelNotFound
exception is raised.
Arguments:
unpacked_model_path
- Path to unpacked Rasa model.
Returns:
Tuple (path to Core subdirectory if it exists or None
otherwise,
path to NLU subdirectory if it exists or None
otherwise).
create_package_rasa
Create a zipped Rasa model from trained model files.
Arguments:
training_directory
- Path to the directory which contains the trained model files.output_filename
- Name of the zipped model file to be created.fingerprint
- A unique fingerprint to identify the model version.
Returns:
Path to zipped model.
project_fingerprint
Create a hash for the project in the current working directory.
Returns:
project hash
model_fingerprint
Create a model fingerprint from its used configuration and training data.
Arguments:
file_importer
- File importer which provides the training data and model config.
Returns:
The fingerprint.
fingerprint_from_path
Load a persisted fingerprint.
Arguments:
model_path
- Path to directory containing the fingerprint.
Returns:
The fingerprint or an empty dict if no fingerprint was found.
persist_fingerprint
Persist a model fingerprint.
Arguments:
output_path
- Directory in which the fingerprint should be saved.fingerprint
- The fingerprint to be persisted.
did_section_fingerprint_change
Check whether the fingerprint of a section has changed.
move_model
Move two model directories.
Arguments:
source
- The original folder which should be merged in another.target
- The destination folder where it should be moved to.
Returns:
True
if the merge was successful, else False
.
should_retrain
Check which components of a model should be retrained.
Arguments:
new_fingerprint
- The fingerprint of the new model to be trained.old_model
- Path to the old zipped model file.train_path
- Path to the directory in which the new model will be trained.has_e2e_examples
- Whether the new training data contains e2e examples.force_training
- Indicates if the model needs to be retrained even if the data has not changed.
Returns:
A FingerprintComparisonResult object indicating whether Rasa Core and/or Rasa NLU needs to be retrained or not.
can_finetune
Checks if components of a model can be finetuned with incremental training.
Arguments:
last_fingerprint
- The fingerprint of the old model to potentially be fine-tuned.new_fingerprint
- The fingerprint of the new model.core
- Check sections for finetuning a core model.nlu
- Check sections for finetuning an nlu model.
Returns:
True
if the old model can be finetuned, False
otherwise.
package_model
Compress a trained model.
Arguments:
fingerprint
- fingerprint of the modeloutput_directory
- path to the directory in which the model should be storedtrain_path
- path to uncompressed modelfixed_model_name
- name of the compressed model filemodel_prefix
- prefix of the compressed model fileReturns
- path to 'tar.gz' model file
update_model_with_new_domain
Overwrites the domain of an unpacked model with a new domain.
Arguments:
importer
- Importer which provides the new domain.unpacked_model_path
- Path to the unpacked model.
get_model_for_finetuning
Gets validated path for model to finetune.
Arguments:
previous_model_file
- Path to model file which should be used for finetuning or a directory in case the latest trained model should be used.
Returns:
Path to model archive. None
if there is no model.