notice
This is unreleased documentation for Rasa Documentation Main/Unreleased version.
For the latest released documentation, see the latest version (3.x).
rasa.engine.training.components
PrecomputedValueProvider Objects
Holds the precomputed values of a GraphNode
from a previous training.
Pre-computed values can either be
- values loaded from cache
- values which were provided during the fingerprint run by input nodes
__init__
Initializes a PrecomputedValueProvider
.
Arguments:
output
- The precomputed output to return.
create
Creates instance (see parent class for full docstring).
get_value
Returns the precomputed output.
replace_schema_node
Updates a SchemaNode
to use a PrecomputedValueProvider
.
This is for when we want to use the precomputed output value of a node from a
previous training in a subsequent training. We replace the class in the uses
of the node to a be a PrecomputedValueProvider
configured to return the
precomputed value.
Arguments:
node
- The node to update.output
- precomputed cached output that thePrecomputedValueProvider
will return.
FingerprintStatus Objects
Holds the output of a FingerprintComponent
and is used to prune the graph.
Attributes:
output_fingerprint
- A fingerprint of the node's output value.is_hit
-True
if node's fingerprint key exists in the cache,False
otherwise.
fingerprint
Returns the internal fingerprint.
If there is no fingerprint returns a random string that will never match.
FingerprintComponent Objects
Replaces non-input nodes during a fingerprint run.
__init__
Initializes a FingerprintComponent
.
Arguments:
cache
- Training cache used to determine if the run is a hit or not.config_of_replaced_component
- Needed to generate the fingerprint key.class_of_replaced_component
- Needed to generate the fingerprint key.
create
Creates a FingerprintComponent
(see parent class for full docstring).
run
Calculates the fingerprint key to determine if cached output can be used.
If the fingerprint key matches an entry in the cache it means that there has been a previous node execution which matches the same component class, component config and input values. This means that we can potentially prune this node from the schema, or replace it with a cached value before the next graph run.
Arguments:
**kwargs
- Inputs from all parent nodes.
Returns:
A FingerprintStatus
determining if the run was a hit, and if it was a hit
also the output fingerprint from the cache.
replace_schema_node
Updates a SchemaNode
to use a FingerprintComponent
.
This is for when we want to do a fingerprint run. During the fingerprint run we
replace all non-input nodes with FingerprintComponent
s so we can determine
whether they are able to be pruned or cached before the next graph run without
running the actual components.
Arguments:
node
- The node to update.cache
- The cache is needed to determine of there is cache hit for the fingerprint key.