notice
This is unreleased documentation for Rasa Documentation Main/Unreleased version.
For the latest released documentation, see the latest version (3.x).
rasa.engine.caching
TrainingCache Objects
Stores training results in a persistent cache.
Used to minimize re-retraining when the data / config didn't change in between training runs.
cache_output
Adds the output to the cache.
If the output is of type Cacheable the output is persisted to disk in addition
to its fingerprint.
Arguments:
fingerprint_key- The fingerprint key serves as key for the cache. Graph components can use their fingerprint key to lookup fingerprints of previous training runs.output- The output. The output is only cached to disk if it's of typeCacheable.output_fingerprint- The fingerprint of their output. This can be used to lookup potentially persisted outputs on disk.model_storage- Required for cachingResourceinstances. E.g.Resources use that to copy data from the model storage to the cache.
get_cached_output_fingerprint
Retrieves fingerprint of output based on fingerprint key.
Arguments:
fingerprint_key- The fingerprint serves as key for the lookup of output fingerprints.
Returns:
The fingerprint of a matching output or None in case no cache entry was
found for the given fingerprint key.
get_cached_result
Returns a potentially cached output result.
Arguments:
output_fingerprint_key- The fingerprint key of the output serves as lookup key for a potentially cached version of this output.node_name- The name of the graph node which wants to use this cached result.model_storage- The current model storage (e.g. used when restoringResourceobjects so that they can fill the model storage with data).
Returns:
None if no matching result was found or restored Cacheable.
Cacheable Objects
Protocol for cacheable graph component outputs.
We only cache graph component outputs which are Cacheable. We only store the
output fingerprint for everything else.
to_cache
Persists Cacheable to disk.
Arguments:
directory- The directory where theCacheablecan persist itself to.model_storage- The current model storage (e.g. used when cachingResourceobjects.
from_cache
Loads Cacheable from cache.
Arguments:
node_name- The name of the graph node which wants to use this cached result.directory- Directory containing the persistedCacheable.model_storage- The current model storage (e.g. used when restoringResourceobjects so that they can fill the model storage with data).output_fingerprint- The fingerprint of the cached result (e.g. used when restoringResourceobjects as the fingerprint can not be easily calculated from the object itself).
Returns:
Instantiated Cacheable.
LocalTrainingCache Objects
Caches training results on local disk (see parent class for full docstring).
CacheEntry Objects
Stores metadata about a single cache entry.
__init__
Creates cache.
The Cache setting can be configured via environment variables.
cache_output
Adds the output to the cache (see parent class for full docstring).
get_cached_output_fingerprint
Returns cached output fingerprint (see parent class for full docstring).
get_cached_result
Returns a potentially cached output (see parent class for full docstring).
