This is unreleased documentation for Rasa & Rasa Pro Documentation Main/Unreleased version.
For the latest released documentation, see the latest version (3.x).
Graph recipes provide a more fine tuned configuration for your executable graphs.
Default Recipe or Graph Recipe?
You will probably only need graph recipes if you're running ML experiments or ablation studies on an existing model. We recommend starting with the default recipe and for many applications that will be all that's needed.
We now support graph recipes in addition to the default recipe. Graph recipes provide more granular control over how execution graph schemas are built.
New in 3.1
This feature is experimental. We introduce experimental features to get feedback from our community, so we encourage you to try it out! However, the functionality might be changed or removed in the future. If you have feedback (positive or negative) please share it with us on the Rasa Forum.
Differences with Default Recipe
There are some differences between the default recipe and the new graph recipe. Main differences are:
- Default recipe is named
default.v1in the config file whereas graph recipes are named
- Default recipes provide an easy to use recipe structure whereas graph recipes are more advanced and powerful.
- Default recipes are very opinionated and provide various defaults whereas graph recipes are more explicit.
- Default recipes can auto-configure themselves and dump the defaults used to the file if some sections in
config.ymlare missing, whereas graph recipes do none of this and assume what you see is what you get. There are no surprises with graph recipes.
- Default recipe divides graph configuration into mainly two parts:
policies. These can also be described as NLU and core (dialogue management) parts. For graph recipe on the other hand, the separation is between training (ie.
train_schema) and prediction (ie.
Starting from scratch?
If you don't know which recipe to choose, use the default recipe to bootstrap your project fast. If later you find that you need more fine-grained control, you can always change your recipe to be a graph recipe.
Graph Configuration File Structure
Graph recipes share
language keys with the same meaning. Similarities end there as graph recipes do not have
policies keys but they do have
predict_schema keys for determining the graph nodes during train and predict runs respectively. In addition to this, target nodes for NLU and core can be specified explicitly with graph recipes, these can be declared with
core_target. If targets are omitted, node names used by default recipe will take over, and these are
select_prediction for nlu and core respectively.
Here's an example graph recipe:
For NLU, default target name of
run_RegexMessageHandler will be used, while for core (dialogue management) the target will be called
select_prediction if omitted. Make sure you have graph nodes with relevant names in your schema definitions.
In a similar fashion, note that the default resource needed by the first graph node is fixed to be
__importer__ (representing configuration, training data etc.) for training task and it is
__message__ (representing the message received) for prediction task. Make sure your first nodes make use of these dependencies.
Graph Node Configuration
As you can see in the example above, graph recipes are very much explicit and you can configure each graph node as you would like. Here is an explanation of what some of the keys mean:
needs: You can define here what data your graph node requires and from which parent node. Key is the data name, whereas the value would refer to the node name.
Current graph node needs
messages which is provided by
uses: You can provide the class used to instantiate this node with this key. Please provide the full path in Python path syntax, eg.
You are not required to use Rasa internal graph component classes and you can use your own components here. Refer to custom graph components pages to find out how to write your own graph components.
constructor_name: This is the constructor used to instantiate your component. Example:
fn: This is the function used in executing the graph component. Example:
config: You can provide any configuration parameters for your components using this key.
eager: This determines if your component should be eagerly loaded when the graph is constructed or if it should wait until the runtime (this is called lazy instantiation). Usually we always instantiate lazily during training and eagerly during inference (to avoid slow first prediction).
resource: If given, graph node is loaded from this resource instead of instantiated from scratch. This is e.g. used to load a trained component for predictions.
is_target: Boolean value, if
Truethen this node can't be pruned during fingerprinting (it might be replaced with a cached value though). This is e.g. used for all components which train as their result always needs to be added to the model archive so that the data is available during inference.
is_input: Boolean value; nodes with
is_inputare always run (also during the fingerprint run). This makes sure that we e.g. detect changes in file contents.