当前位置: 首页 > 工具软件 > rasa-ui > 使用案例 >

RASA命令-原文

盖雪峰
2023-12-01

目录

Command Line Interface

Cheat Sheet#

rasa init#

rasa train#

rasa interactive#

rasa shell#

rasa run#

rasa run actions#

rasa visualize#

rasa test#

rasa data split#

rasa data convert nlu#

rasa data convert core#

rasa data convert nlg#

rasa data validate#

rasa x#


Command Line Interface

命令行接口(CLI)为常见任务提供了易于记住的命令。这一页描述了命令的行为和你可以传递给它们的参数。

Cheat Sheet#

CommandEffect
rasa initCreates a new project with example training data, actions, and config files.
rasa trainTrains a model using your NLU data and stories, saves trained model in ./models.
rasa interactiveStarts an interactive learning session to create new training data by chatting to your assistant.
rasa shellLoads your trained model and lets you talk to your assistant on the command line.
rasa runStarts a server with your trained model.
rasa run actionsStarts an action server using the Rasa SDK.
rasa visualizeGenerates a visual representation of your stories.
rasa testTests a trained Rasa model on any files starting with test_.
rasa data split nluPerforms a 80/20 split of your NLU training data.
rasa data convertConverts training data between different formats.
rasa data validateChecks the domain, NLU and conversation data for inconsistencies.
rasa exportExports conversations from a tracker store to an event broker.
rasa xLaunches Rasa X in local mode.
rasa -hShows all available commands.

rasa init#

这个命令用一些示例训练数据为您设置了一个完整的助手:

rasa init

It creates the following files:

.
├── actions
│   ├── __init__.py
│   └── actions.py
├── config.yml
├── credentials.yml
├── data
│   ├── nlu.yml
│   └── stories.yml
├── domain.yml
├── endpoints.yml
├── models
│   └── <timestamp>.tar.gz
└── tests
   └── test_stories.yml

它会问你是否想用这些数据训练一个初始模型。如果您回答no, models目录将是空的。

任何默认的CLI命令都需要这样的项目设置,所以这是开始的最佳方式。您可以运行rasa train, rasa shell和rasa test,而无需任何额外的配置。

rasa train#

下面的命令训练一个Rasa开源模型:

rasa train

如果您的目录中有现有的模型(默认情况下在models/下),那么只有模型中已更改的部分将被重新培训。例如,如果您只编辑您的NLU训练数据而不做其他,则只会训练NLU部分。

如果你想单独训练一个NLU或对话模型,你可以runrasa train NLU或rasa train core。如果您仅为其中一个命令提供训练数据,则rasa train默认将退回到这些命令中的一个。

rasa train将把训练过的模型存储在——out定义的目录中,默认情况下是models/。模型的名称默认为<timestamp>.tar.gz。</timestamp>如果想用不同的方式命名模型,可以使用——fixed-model-name标志指定名称。

可以使用以下参数来配置训练过程:

usage: rasa train [-h] [-v] [-vv] [--quiet] [--data DATA [DATA ...]]
                  [-c CONFIG] [-d DOMAIN] [--out OUT] [--dry-run]
                  [--augmentation AUGMENTATION] [--debug-plots]
                  [--num-threads NUM_THREADS]
                  [--fixed-model-name FIXED_MODEL_NAME] [--persist-nlu-data]
                  [--force] [--finetune [FINETUNE]]
                  [--epoch-fraction EPOCH_FRACTION]
                  {core,nlu} ...

positional arguments:
  {core,nlu}
    core                Trains a Rasa Core model using your stories.
    nlu                 Trains a Rasa NLU model using your NLU data.

optional arguments:
  -h, --help            show this help message and exit
  --data DATA [DATA ...]
                        Paths to the Core and NLU data files. (default:
                        ['data'])
  -c CONFIG, --config CONFIG
                        The policy and NLU pipeline configuration of your bot.
                        (default: config.yml)
  -d DOMAIN, --domain DOMAIN
                        Domain specification. This can be a single YAML file,
                        or a directory that contains several files with domain
                        specifications in it. The content of these files will
                        be read and merged together. (default: domain.yml)
  --out OUT             Directory where your models should be stored.
                        (default: models)
  --dry-run             If enabled, no actual training will be performed.
                        Instead, it will be determined whether a model should
                        be re-trained and this information will be printed as
                        the output. The return code is a 4-bit bitmask that
                        can also be used to determine what exactly needs to be
                        retrained: - 1 means Core needs to be retrained - 2
                        means NLU needs to be retrained - 4 means responses in
                        the domain should be updated - 8 means the training
                        was forced (--force argument is specified) (default:
                        False)
  --augmentation AUGMENTATION
                        How much data augmentation to use during training.
                        (default: 50)
  --debug-plots         If enabled, will create plots showing checkpoints and
                        their connections between story blocks in a file
                        called `story_blocks_connections.html`. (default:
                        False)
  --num-threads NUM_THREADS
                        Maximum amount of threads to use when training.
                        (default: 1)
  --fixed-model-name FIXED_MODEL_NAME
                        If set, the name of the model file/directory will be
                        set to the given name. (default: None)
  --persist-nlu-data    Persist the NLU training data in the saved model.
                        (default: False)
  --force               Force a model training even if the data has not
                        changed. (default: False)
  --finetune [FINETUNE]
                        Fine-tune a previously trained model. If no model path
                        is provided, Rasa Open Source will try to finetune the
                        latest trained model from the model directory
                        specified via '--out'. (default: None)
  --epoch-fraction EPOCH_FRACTION
                        Fraction of epochs which are currently specified in
                        the model configuration which should be used when
                        finetuning a model. (default: 1.0)

Python Logging Options:
  -v, --verbose         Be verbose. Sets logging level to INFO. (default:
                        None)
  -vv, --debug          Print lots of debugging statements. Sets logging level
                        to DEBUG. (default: None)
  --quiet               Be quiet! Sets logging level to WARNING. (default:
                        None)

为了提高助手的性能,练习CDD并根据用户与助手的对话方式添加新的训练示例是很有帮助的。您可以使用rasa train—finetune用一个已经训练过的模型初始化管道,并在包含额外训练示例的新训练数据集上进一步微调它。这将有助于减少新模型的训练时间。

默认情况下,该命令会选取models/目录中的最新模型。如果你有一个想要改进的特定模型,你可以通过运行rasa train来指定它的路径——finetune 。</path>与从零开始训练相比,调整模型训练DIETClassifier、ResponseSelector和tedpolicy等机器学习组件所需的时间通常更少。要么使用模型配置进行微调,它定义的纪元比以前少,要么使用标志——epoch-fraction。epoch-fraction将使用模型配置文件中为每个机器学习组件指定的epoch的一部分。例如,如果DIETClassifier被配置为使用100个epoch,则指定——epoch-fraction 0.5将只使用50个epoch进行微调。

您还可以通过分别使用rasa train nlu -finetune和rasa train core - finetunet来微调nlu -only或对话管理模型。

为了能够对模型进行微调,必须满足以下条件:

提供的配置应该与用于训练正在调整的模型的配置完全相同。唯一可以改变的参数是单个机器学习组件和策略的时代。

基础模型所训练的标签集(意图、动作、实体和槽)应该与用于微调的训练数据中呈现的标签集完全相同。这意味着在增量训练期间,您不能向训练数据添加新的意图、动作、实体或插槽标签。您仍然可以为每个现有标签添加新的训练示例。如果在培训数据中添加/删除了标签,则需要从头对管道进行培训。

要调优的模型使用当前安装的rasa版本的MINIMUM_COMPATIBLE_VERSION进行训练。

查看countvectorsfeataturizer和regexfeataturizer的文档,了解如何为增量培训适当地配置它们。

rasa interactive#

你可以在本地模式下使用Rasa X在UI中进行交互学习,查看文档了解更多细节。

如果你更喜欢使用命令行,你可以运行以下命令来启动一个交互式学习会话:

 

rasa interactive

这将首先训练模型,然后启动交互式shell会话。然后,你可以一边跟它说话,一边纠正助手的预测。

如果您使用——model参数提供了一个训练过的模型,那么训练将被跳过,而该模型将被加载。

在互动学习中,Rasa将从训练数据中绘制当前对话和一些类似的对话,以帮助您跟踪您所处的位置。一旦会话开始,您就可以在http://localhost:5005/visualization.html上查看可视化。这个图表需要一些时间来生成。要跳过可视化,运行rasa interactive——skip-visualization。

可以使用以下参数配置交互式学习会话:

usage: rasa interactive [-h] [-v] [-vv] [--quiet] [--e2e] [-p PORT] [-m MODEL]
                        [--data DATA [DATA ...]] [--skip-visualization]
                        [--conversation-id CONVERSATION_ID]
                        [--endpoints ENDPOINTS] [-c CONFIG] [-d DOMAIN]
                        [--out OUT] [--augmentation AUGMENTATION]
                        [--debug-plots] [--finetune [FINETUNE]]
                        [--epoch-fraction EPOCH_FRACTION] [--force]
                        [--persist-nlu-data]
                        {core} ... [model-as-positional-argument]

positional arguments:
  {core}
    core                Starts an interactive learning session model to create
                        new training data for a Rasa Core model by chatting.
                        Uses the 'RegexInterpreter', i.e. `/<intent>` input
                        format.
  model-as-positional-argument
                        Path to a trained Rasa model. If a directory is
                        specified, it will use the latest model in this
                        directory. (default: None)

optional arguments:
  -h, --help            show this help message and exit
  --e2e                 Save story files in e2e format. In this format user
                        messages will be included in the stories. (default:
                        False)
  -p PORT, --port PORT  Port to run the server at. (default: 5005)
  -m MODEL, --model MODEL
                        Path to a trained Rasa model. If a directory is
                        specified, it will use the latest model in this
                        directory. (default: None)
  --data DATA [DATA ...]
                        Paths to the Core and NLU data files. (default:
                        ['data'])
  --skip-visualization  Disable plotting the visualization during interactive
                        learning. (default: False)
  --conversation-id CONVERSATION_ID
                        Specify the id of the conversation the messages are
                        in. Defaults to a UUID that will be randomly
                        generated. (default: f41b89fc9d1943e08c0f419b4bb2cb0f)
  --endpoints ENDPOINTS
                        Configuration file for the model server and the
                        connectors as a yml file. (default: None)

Python Logging Options:
  -v, --verbose         Be verbose. Sets logging level to INFO. (default:
                        None)
  -vv, --debug          Print lots of debugging statements. Sets logging level
                        to DEBUG. (default: None)
  --quiet               Be quiet! Sets logging level to WARNING. (default:
                        None)

Train Arguments:
  -c CONFIG, --config CONFIG
                        The policy and NLU pipeline configuration of your bot.
                        (default: config.yml)
  -d DOMAIN, --domain DOMAIN
                        Domain specification. This can be a single YAML file,
                        or a directory that contains several files with domain
                        specifications in it. The content of these files will
                        be read and merged together. (default: domain.yml)
  --out OUT             Directory where your models should be stored.
                        (default: models)
  --augmentation AUGMENTATION
                        How much data augmentation to use during training.
                        (default: 50)
  --debug-plots         If enabled, will create plots showing checkpoints and
                        their connections between story blocks in a file
                        called `story_blocks_connections.html`. (default:
                        False)
  --finetune [FINETUNE]
                        Fine-tune a previously trained model. If no model path
                        is provided, Rasa Open Source will try to finetune the
                        latest trained model from the model directory
                        specified via '--out'. (default: None)
  --epoch-fraction EPOCH_FRACTION
                        Fraction of epochs which are currently specified in
                        the model configuration which should be used when
                        finetuning a model. (default: 1.0)
  --force               Force a model training even if the data has not
                        changed. (default: False)
  --persist-nlu-data    Persist the NLU training data in the saved model.
                        (default: False)

rasa shell#

您可以在本地模式下使用Rasa X在UI中与您的助手对话。查看Rasa X文档了解更多细节。

如果你更喜欢使用命令行,你可以运行以下命令来启动聊天会话:

rasa shell

默认情况下,这将加载最新的训练模型。您可以使用——model标志指定要加载的不同模型。

如果您使用仅nlu模型启动shell,那么rasa shell将输出您输入的任何消息的预期意图和实体。

如果您已经训练了一个组合的Rasa模型,但是只希望看到您的模型从文本中提取的意图和实体,那么您可以使用命令Rasa shell nlu。

要增加用于调试的日志级别,可以执行以下命令:

Copy

rasa shell --debug

可以使用以下参数来配置该命令:

usage: rasa shell [-h] [-v] [-vv] [--quiet]
                  [--conversation-id CONVERSATION_ID] [-m MODEL]
                  [--log-file LOG_FILE] [--endpoints ENDPOINTS] [-p PORT]
                  [-t AUTH_TOKEN] [--cors [CORS [CORS ...]]] [--enable-api]
                  [--response-timeout RESPONSE_TIMEOUT]
                  [--remote-storage REMOTE_STORAGE]
                  [--ssl-certificate SSL_CERTIFICATE]
                  [--ssl-keyfile SSL_KEYFILE] [--ssl-ca-file SSL_CA_FILE]
                  [--ssl-password SSL_PASSWORD] [--credentials CREDENTIALS]
                  [--connector CONNECTOR] [--jwt-secret JWT_SECRET]
                  [--jwt-method JWT_METHOD]
                  {nlu} ... [model-as-positional-argument]

positional arguments:
  {nlu}
    nlu                 Interprets messages on the command line using your NLU
                        model.
  model-as-positional-argument
                        Path to a trained Rasa model. If a directory is
                        specified, it will use the latest model in this
                        directory. (default: None)

optional arguments:
  -h, --help            show this help message and exit
  --conversation-id CONVERSATION_ID
                        Set the conversation ID. (default:
                        14f6a63f1aca421194dec8652b6308eb)
  -m MODEL, --model MODEL
                        Path to a trained Rasa model. If a directory is
                        specified, it will use the latest model in this
                        directory. (default: models)
  --log-file LOG_FILE   Store logs in specified file. (default: None)
  --endpoints ENDPOINTS
                        Configuration file for the model server and the
                        connectors as a yml file. (default: None)

Python Logging Options:
  -v, --verbose         Be verbose. Sets logging level to INFO. (default:
                        None)
  -vv, --debug          Print lots of debugging statements. Sets logging level
                        to DEBUG. (default: None)
  --quiet               Be quiet! Sets logging level to WARNING. (default:
                        None)

Server Settings:
  -p PORT, --port PORT  Port to run the server at. (default: 5005)
  -t AUTH_TOKEN, --auth-token AUTH_TOKEN
                        Enable token based authentication. Requests need to
                        provide the token to be accepted. (default: None)
  --cors [CORS [CORS ...]]
                        Enable CORS for the passed origin. Use * to whitelist
                        all origins. (default: None)
  --enable-api          Start the web server API in addition to the input
                        channel. (default: False)
  --response-timeout RESPONSE_TIMEOUT
                        Maximum time a response can take to process (sec).
                        (default: 3600)
  --remote-storage REMOTE_STORAGE
                        Set the remote location where your Rasa model is
                        stored, e.g. on AWS. (default: None)
  --ssl-certificate SSL_CERTIFICATE
                        Set the SSL Certificate to create a TLS secured
                        server. (default: None)
  --ssl-keyfile SSL_KEYFILE
                        Set the SSL Keyfile to create a TLS secured server.
                        (default: None)
  --ssl-ca-file SSL_CA_FILE
                        If your SSL certificate needs to be verified, you can
                        specify the CA file using this parameter. (default:
                        None)
  --ssl-password SSL_PASSWORD
                        If your ssl-keyfile is protected by a password, you
                        can specify it using this paramer. (default: None)

Channels:
  --credentials CREDENTIALS
                        Authentication credentials for the connector as a yml
                        file. (default: None)
  --connector CONNECTOR
                        Service to connect to. (default: None)

JWT Authentication:
  --jwt-secret JWT_SECRET
                        Public key for asymmetric JWT methods or shared
                        secretfor symmetric methods. Please also make sure to
                        use --jwt-method to select the method of the
                        signature, otherwise this argument will be ignored.
                        (default: None)
  --jwt-method JWT_METHOD
                        Method used for the signature of the JWT
                        authentication payload. (default: HS256)

rasa run#

To start a server running your trained model, run:

rasa run

默认情况下,Rasa服务器使用HTTP进行通信。为了保证与SSL的通信安全,并在HTTPS上运行服务器,您需要提供有效的证书和相应的私钥文件。您可以将这些文件指定为rasa run命令的一部分。如果在创建过程中使用密码加密了密钥文件,那么还需要添加——ssl-password。

rasa run --ssl-certificate myssl.crt --ssl-keyfile myssl.key --ssl-password mypassword

下面的参数可以用来配置你的Rasa服务器:

usage: rasa run [-h] [-v] [-vv] [--quiet] [-m MODEL] [--log-file LOG_FILE]
                [--endpoints ENDPOINTS] [-p PORT] [-t AUTH_TOKEN]
                [--cors [CORS [CORS ...]]] [--enable-api]
                [--response-timeout RESPONSE_TIMEOUT]
                [--remote-storage REMOTE_STORAGE]
                [--ssl-certificate SSL_CERTIFICATE]
                [--ssl-keyfile SSL_KEYFILE] [--ssl-ca-file SSL_CA_FILE]
                [--ssl-password SSL_PASSWORD] [--credentials CREDENTIALS]
                [--connector CONNECTOR] [--jwt-secret JWT_SECRET]
                [--jwt-method JWT_METHOD]
                {actions} ... [model-as-positional-argument]

positional arguments:
  {actions}
    actions             Runs the action server.
  model-as-positional-argument
                        Path to a trained Rasa model. If a directory is
                        specified, it will use the latest model in this
                        directory. (default: None)

optional arguments:
  -h, --help            show this help message and exit
  -m MODEL, --model MODEL
                        Path to a trained Rasa model. If a directory is
                        specified, it will use the latest model in this
                        directory. (default: models)
  --log-file LOG_FILE   Store logs in specified file. (default: None)
  --endpoints ENDPOINTS
                        Configuration file for the model server and the
                        connectors as a yml file. (default: None)

Python Logging Options:
  -v, --verbose         Be verbose. Sets logging level to INFO. (default:
                        None)
  -vv, --debug          Print lots of debugging statements. Sets logging level
                        to DEBUG. (default: None)
  --quiet               Be quiet! Sets logging level to WARNING. (default:
                        None)

Server Settings:
  -p PORT, --port PORT  Port to run the server at. (default: 5005)
  -t AUTH_TOKEN, --auth-token AUTH_TOKEN
                        Enable token based authentication. Requests need to
                        provide the token to be accepted. (default: None)
  --cors [CORS [CORS ...]]
                        Enable CORS for the passed origin. Use * to whitelist
                        all origins. (default: None)
  --enable-api          Start the web server API in addition to the input
                        channel. (default: False)
  --response-timeout RESPONSE_TIMEOUT
                        Maximum time a response can take to process (sec).
                        (default: 3600)
  --remote-storage REMOTE_STORAGE
                        Set the remote location where your Rasa model is
                        stored, e.g. on AWS. (default: None)
  --ssl-certificate SSL_CERTIFICATE
                        Set the SSL Certificate to create a TLS secured
                        server. (default: None)
  --ssl-keyfile SSL_KEYFILE
                        Set the SSL Keyfile to create a TLS secured server.
                        (default: None)
  --ssl-ca-file SSL_CA_FILE
                        If your SSL certificate needs to be verified, you can
                        specify the CA file using this parameter. (default:
                        None)
  --ssl-password SSL_PASSWORD
                        If your ssl-keyfile is protected by a password, you
                        can specify it using this paramer. (default: None)

Channels:
  --credentials CREDENTIALS
                        Authentication credentials for the connector as a yml
                        file. (default: None)
  --connector CONNECTOR
                        Service to connect to. (default: None)

JWT Authentication:
  --jwt-secret JWT_SECRET
                        Public key for asymmetric JWT methods or shared
                        secretfor symmetric methods. Please also make sure to
                        use --jwt-method to select the method of the
                        signature, otherwise this argument will be ignored.
                        (default: None)
  --jwt-method JWT_METHOD
                        Method used for the signature of the JWT
                        authentication payload. (default: HS256)

For more information on the additional parameters, see Model Storage. See the Rasa HTTP API page for detailed documentation of all the endpoints.

rasa run actions#

To start an action server with the Rasa SDK, run:

 

rasa run actions

The following arguments can be used to adapt the server settings:

usage: rasa run actions [-h] [-v] [-vv] [--quiet] [-p PORT]
                        [--cors [CORS [CORS ...]]] [--actions ACTIONS]
                        [--ssl-keyfile SSL_KEYFILE]
                        [--ssl-certificate SSL_CERTIFICATE]
                        [--ssl-password SSL_PASSWORD] [--auto-reload]

optional arguments:
  -h, --help            show this help message and exit
  -p PORT, --port PORT  port to run the server at (default: 5055)
  --cors [CORS [CORS ...]]
                        enable CORS for the passed origin. Use * to whitelist
                        all origins (default: None)
  --actions ACTIONS     name of action package to be loaded (default: None)
  --ssl-keyfile SSL_KEYFILE
                        Set the SSL certificate to create a TLS secured
                        server. (default: None)
  --ssl-certificate SSL_CERTIFICATE
                        Set the SSL certificate to create a TLS secured
                        server. (default: None)
  --ssl-password SSL_PASSWORD
                        If your ssl-keyfile is protected by a password, you
                        can specify it using this paramer. (default: None)
  --auto-reload         Enable auto-reloading of modules containing Action
                        subclasses. (default: False)

Python Logging Options:
  -v, --verbose         Be verbose. Sets logging level to INFO. (default:
                        None)
  -vv, --debug          Print lots of debugging statements. Sets logging level
                        to DEBUG. (default: None)
  --quiet               Be quiet! Sets logging level to WARNING. (default:
                        None)

rasa visualize#

To generate a graph of your stories in the browser, run:

 

rasa visualize

If your stories are located somewhere other than the default location data/, you can specify their location with the --stories flag.

The following arguments can be used to configure this command:

usage: rasa visualize [-h] [-v] [-vv] [--quiet] [-d DOMAIN] [-s STORIES]
                      [-c CONFIG] [--out OUT] [--max-history MAX_HISTORY]
                      [-u NLU]

optional arguments:
  -h, --help            show this help message and exit
  -d DOMAIN, --domain DOMAIN
                        Domain specification. This can be a single YAML file,
                        or a directory that contains several files with domain
                        specifications in it. The content of these files will
                        be read and merged together. (default: domain.yml)
  -s STORIES, --stories STORIES
                        File or folder containing your training stories.
                        (default: data)
  -c CONFIG, --config CONFIG
                        The policy and NLU pipeline configuration of your bot.
                        (default: config.yml)
  --out OUT             Filename of the output path, e.g. 'graph.html'.
                        (default: graph.html)
  --max-history MAX_HISTORY
                        Max history to consider when merging paths in the
                        output graph. (default: 2)
  -u NLU, --nlu NLU     File or folder containing your NLU data, used to
                        insert example messages into the graph. (default:
                        None)

Python Logging Options:
  -v, --verbose         Be verbose. Sets logging level to INFO. (default:
                        None)
  -vv, --debug          Print lots of debugging statements. Sets logging level
                        to DEBUG. (default: None)
  --quiet               Be quiet! Sets logging level to WARNING. (default:
                        None)

rasa test#

To evaluate a model on your test data, run:

 

rasa test

This will test your latest trained model on any end-to-end stories you have defined in files with the test_ prefix. If you want to use a different model, you can specify it using the --model flag.

If you want to evaluate the dialogue and NLU models separately, you can use the commands below:

 

rasa test core

and

 

rasa test nlu

You can find more details in Evaluating an NLU Model and Evaluating a Core Model.

The following arguments are available for rasa test:

usage: rasa test [-h] [-v] [-vv] [--quiet] [-m MODEL] [-s STORIES]
                 [--max-stories MAX_STORIES] [--endpoints ENDPOINTS]
                 [--fail-on-prediction-errors] [--url URL]
                 [--evaluate-model-directory] [-u NLU]
                 [-c CONFIG [CONFIG ...]] [--cross-validation] [-f FOLDS]
                 [-r RUNS] [-p PERCENTAGES [PERCENTAGES ...]] [--no-plot]
                 [--successes] [--no-errors] [--out OUT]
                 {core,nlu} ...

positional arguments:
  {core,nlu}
    core                Tests Rasa Core models using your test stories.
    nlu                 Tests Rasa NLU models using your test NLU data.

optional arguments:
  -h, --help            show this help message and exit
  -m MODEL, --model MODEL
                        Path to a trained Rasa model. If a directory is
                        specified, it will use the latest model in this
                        directory. (default: models)
  --no-plot             Don't render evaluation plots. (default: False)
  --successes           If set successful predictions will be written to a
                        file. (default: False)
  --no-errors           If set incorrect predictions will NOT be written to a
                        file. (default: False)
  --out OUT             Output path for any files created during the
                        evaluation. (default: results)

Python Logging Options:
  -v, --verbose         Be verbose. Sets logging level to INFO. (default:
                        None)
  -vv, --debug          Print lots of debugging statements. Sets logging level
                        to DEBUG. (default: None)
  --quiet               Be quiet! Sets logging level to WARNING. (default:
                        None)

Core Test Arguments:
  -s STORIES, --stories STORIES
                        File or folder containing your test stories. (default:
                        tests)
  --max-stories MAX_STORIES
                        Maximum number of stories to test on. (default: None)
  --endpoints ENDPOINTS
                        Configuration file for the connectors as a yml file.
                        (default: None)
  --fail-on-prediction-errors
                        If a prediction error is encountered, an exception is
                        thrown. This can be used to validate stories during
                        tests, e.g. on travis. (default: False)
  --url URL             If supplied, downloads a story file from a URL and
                        trains on it. Fetches the data by sending a GET
                        request to the supplied URL. (default: None)
  --evaluate-model-directory
                        Should be set to evaluate models trained via 'rasa
                        train core --config <config-1> <config-2>'. All models
                        in the provided directory are evaluated and compared
                        against each other. (default: False)

NLU Test Arguments:
  -u NLU, --nlu NLU     File or folder containing your NLU data. (default:
                        data)
  -c CONFIG [CONFIG ...], --config CONFIG [CONFIG ...]
                        Model configuration file. If a single file is passed
                        and cross validation mode is chosen, cross-validation
                        is performed, if multiple configs or a folder of
                        configs are passed, models will be trained and
                        compared directly. (default: None)

rasa data split#

To create a train-test split of your NLU training data, run:

 

rasa data split nlu

This will create a 80/20 split of train/test data by default. You can specify the training data, the fraction, and the output directory using the following arguments:

usage: rasa data split nlu [-h] [-v] [-vv] [--quiet] [-u NLU]
                           [--training-fraction TRAINING_FRACTION]
                           [--random-seed RANDOM_SEED] [--out OUT]

optional arguments:
  -h, --help            show this help message and exit
  -u NLU, --nlu NLU     File or folder containing your NLU data. (default:
                        data)
  --training-fraction TRAINING_FRACTION
                        Percentage of the data which should be in the training
                        data. (default: 0.8)
  --random-seed RANDOM_SEED
                        Seed to generate the same train/test split. (default:
                        None)
  --out OUT             Directory where the split files should be stored.
                        (default: train_test_split)

Python Logging Options:
  -v, --verbose         Be verbose. Sets logging level to INFO. (default:
                        None)
  -vv, --debug          Print lots of debugging statements. Sets logging level
                        to DEBUG. (default: None)
  --quiet               Be quiet! Sets logging level to WARNING. (default:
                        None)

If you have NLG data for retrieval actions, this will be saved to seperate files:

ls train_test_split

      nlg_test_data.yml     test_data.yml
      nlg_training_data.yml training_data.yml

rasa data convert nlu#

You can convert NLU data from

  • LUIS data format,
  • WIT data format,
  • Dialogflow data format,
  • JSON, or
  • Markdown

to

  • YAML or
  • JSON or
  • Markdown.

You can start the converter by running:

 

rasa data convert nlu

You can specify the input file or directory, output file or directory, and the output format with the following arguments:

usage: rasa data convert nlu [-h] [-v] [-vv] [--quiet] [-f {json,md,yaml}]
                             --data DATA [--out OUT] [-l LANGUAGE]

optional arguments:
  -h, --help            show this help message and exit
  -f {json,md,yaml}, --format {json,md,yaml}
                        Output format the training data should be converted
                        into. Note: currently training data can be converted
                        to 'yaml' format only from 'md' format (default: yaml)
  --data DATA           Path to the file or directory containing Rasa NLU
                        data. (default: data)
  --out OUT             File (for `json` and `md`) or existing path (for
                        `yaml`) where to save training data in Rasa format.
                        (default: converted_data)
  -l LANGUAGE, --language LANGUAGE
                        Language of data. (default: en)

Python Logging Options:
  -v, --verbose         Be verbose. Sets logging level to INFO. (default:
                        None)
  -vv, --debug          Print lots of debugging statements. Sets logging level
                        to DEBUG. (default: None)
  --quiet               Be quiet! Sets logging level to WARNING. (default:
                        None)

rasa data convert core#

You can convert Core data from Markdown to YAML.

You can specify the input file or directory, output directory with the following arguments:

 

rasa data convert core --help

rasa data convert nlg#

You can convert NLG data from Markdown to YAML.

You can specify the input file or directory, output directory with the following arguments:

 

rasa data convert nlg --help

rasa data validate#

You can check your domain, NLU data, or story data for mistakes and inconsistencies. To validate your data, run this command:

 

rasa data validate

验证器搜索数据中的错误,例如,两个意图有一些相同的训练示例。验证器还会检查您是否有任何故事,在这些故事中,不同的助手操作来自相同的对话历史记录。故事之间的冲突会阻碍一个模型学习对话的正确模式。

如果您将max_history值传递给配置中的一个或多个策略。在验证器命令中使用——max-history <max_history>标志提供这些值中的最小值。</max_history>

你也可以通过运行这个命令来验证故事结构:

Copy

rasa data validate stories

You can use rasa data validate with additional arguments, e.g. to specify the location of your data and domain files:

usage: rasa data validate [-h] [-v] [-vv] [--quiet]
                          [--max-history MAX_HISTORY] [-c CONFIG]
                          [--fail-on-warnings] [-d DOMAIN] [--data DATA]
                          {stories} ...

positional arguments:
  {stories}
    stories             Checks for inconsistencies in the story files.

optional arguments:
  -h, --help            show this help message and exit
  --max-history MAX_HISTORY
                        Number of turns taken into account for story structure
                        validation. (default: None)
  -c CONFIG, --config CONFIG
                        The policy and NLU pipeline configuration of your bot.
                        (default: config.yml)
  --fail-on-warnings    Fail validation on warnings and errors. If omitted
                        only errors will result in a non zero exit code.
                        (default: False)
  -d DOMAIN, --domain DOMAIN
                        Domain specification. This can be a single YAML file,
                        or a directory that contains several files with domain
                        specifications in it. The content of these files will
                        be read and merged together. (default: domain.yml)
  --data DATA           Path to the file or directory containing Rasa data.
                        (default: data)

Python Logging Options:
  -v, --verbose         Be verbose. Sets logging level to INFO. (default:
                        None)
  -vv, --debug          Print lots of debugging statements. Sets logging level
                        to DEBUG. (default: None)
  --quiet               Be quiet! Sets logging level to WARNING. (default:
                        None)

rasa x#

Rasa X is a tool for practicing Conversation-Driven Development. You can find more information about it here.You can start Rasa X in local mode by executing

 

rasa x

To be able to start Rasa X you need to have Rasa X local mode installedand you need to be in a Rasa project directory.

The following arguments are available for rasa x:

usage: rasa x [-h] [-v] [-vv] [--quiet] [-m MODEL] [--data DATA] [-c CONFIG]
              [-d DOMAIN] [--no-prompt] [--production]
              [--rasa-x-port RASA_X_PORT] [--config-endpoint CONFIG_ENDPOINT]
              [--log-file LOG_FILE] [--endpoints ENDPOINTS] [-p PORT]
              [-t AUTH_TOKEN] [--cors [CORS [CORS ...]]] [--enable-api]
              [--response-timeout RESPONSE_TIMEOUT]
              [--remote-storage REMOTE_STORAGE]
              [--ssl-certificate SSL_CERTIFICATE] [--ssl-keyfile SSL_KEYFILE]
              [--ssl-ca-file SSL_CA_FILE] [--ssl-password SSL_PASSWORD]
              [--credentials CREDENTIALS] [--connector CONNECTOR]
              [--jwt-secret JWT_SECRET] [--jwt-method JWT_METHOD]

optional arguments:
  -h, --help            show this help message and exit
  -m MODEL, --model MODEL
                        Path to a trained Rasa model. If a directory is
                        specified, it will use the latest model in this
                        directory. (default: models)
  --data DATA           Path to the file or directory containing stories and
                        Rasa NLU data. (default: data)
  -c CONFIG, --config CONFIG
                        The policy and NLU pipeline configuration of your bot.
                        (default: config.yml)
  -d DOMAIN, --domain DOMAIN
                        Domain specification. This can be a single YAML file,
                        or a directory that contains several files with domain
                        specifications in it. The content of these files will
                        be read and merged together. (default: domain.yml)
  --no-prompt           Automatic yes or default options to prompts and
                        oppressed warnings. (default: False)
  --production          Run Rasa X in a production environment. (default:
                        False)
  --rasa-x-port RASA_X_PORT
                        Port to run the Rasa X server at. (default: 5002)
  --config-endpoint CONFIG_ENDPOINT
                        Rasa X endpoint URL from which to pull the runtime
                        config. This URL typically contains the Rasa X token
                        for authentication. Example:
                        https://example.com/api/config?token=my_rasa_x_token
                        (default: None)
  --log-file LOG_FILE   Store logs in specified file. (default: None)
  --endpoints ENDPOINTS
                        Configuration file for the model server and the
                        connectors as a yml file. (default: None)

Python Logging Options:
  -v, --verbose         Be verbose. Sets logging level to INFO. (default:
                        None)
  -vv, --debug          Print lots of debugging statements. Sets logging level
                        to DEBUG. (default: None)
  --quiet               Be quiet! Sets logging level to WARNING. (default:
                        None)

Server Settings:
  -p PORT, --port PORT  Port to run the server at. (default: 5005)
  -t AUTH_TOKEN, --auth-token AUTH_TOKEN
                        Enable token based authentication. Requests need to
                        provide the token to be accepted. (default: None)
  --cors [CORS [CORS ...]]
                        Enable CORS for the passed origin. Use * to whitelist
                        all origins. (default: None)
  --enable-api          Start the web server API in addition to the input
                        channel. (default: False)
  --response-timeout RESPONSE_TIMEOUT
                        Maximum time a response can take to process (sec).
                        (default: 3600)
  --remote-storage REMOTE_STORAGE
                        Set the remote location where your Rasa model is
                        stored, e.g. on AWS. (default: None)
  --ssl-certificate SSL_CERTIFICATE
                        Set the SSL Certificate to create a TLS secured
                        server. (default: None)
  --ssl-keyfile SSL_KEYFILE
                        Set the SSL Keyfile to create a TLS secured server.
                        (default: None)
  --ssl-ca-file SSL_CA_FILE
                        If your SSL certificate needs to be verified, you can
                        specify the CA file using this parameter. (default:
                        None)
  --ssl-password SSL_PASSWORD
                        If your ssl-keyfile is protected by a password, you
                        can specify it using this paramer. (default: None)

Channels:
  --credentials CREDENTIALS
                        Authentication credentials for the connector as a yml
                        file. (default: None)
  --connector CONNECTOR
                        Service to connect to. (default: None)

JWT Authentication:
  --jwt-secret JWT_SECRET
                        Public key for asymmetric JWT methods or shared
                        secretfor symmetric methods. Please also make sure to
                        use --jwt-method to select the method of the
                        signature, otherwise this argument will be ignored.
                        (default: None)
  --jwt-method JWT_METHOD
                        Method used for the signature of the JWT
                        authentication payload. (default: HS256)

 

 

 类似资料: