3. Rasa2.0 学习笔记:版本迁移指南(下):1.10 to 2.0

5.Response Selectors

从2.0版开始,响应选择器是一项稳定的功能。
conversion command将自动将response.md文件,stories和nlu训练数据转换为新的yaml格式。 此外,我们还需要在stories文件中重命名response_actions,以改为使用utter_前缀。 例如:

stories:
  - story: chitchat
    steps:
    - intent: chitchat
    - action: respond_chitchat

变成

stories:
  - story: chitchat
    steps:
    - intent: chitchat
    - action: utter_chitchat

并且还需要在response.md中的response names中添加utter_前缀。 例如:

responses:
  chitchat/ask_name:
    - text: Oh yeah, I am called the retrieval bot.

  chitchat/ask_weather:
    - text: Oh, it does look sunny right now in Berlin.

变成

responses:
  utter_chitchat/ask_name:
    - text: Oh yeah, I am called the retrieval bot.

  utter_chitchat/ask_weather:
    - text: Oh, it does look sunny right now in Berlin.

最后,我们要从domain中的actions list中删除所有带有response_前缀的actions。

当定义为story时,这么做会很好,但按规则定义时,甚至会更好。 我们应该考虑将 retrieval stories转换为规则。 chitchat and FAQs documentation中有更多与此相关的信息。

现在,默认情况下对Response Selectors进行了关于检索意图标签的训练,而不是实际的响应文本。 对于大多数模型,这应该可以改善训练时间和ResponseSelector的准确性。

如果要恢复到2.0之前的默认behavior,请在ResponseSelector组件中添加use_text_as_label:true参数:

pipeline:
  # other components
  - name: ResponseSelector
    use_text_as_label: true

ResponseSelector的输出架构已更改。 输出示例如下所示:

{
  "response_selector": {
    "all_retrieval_intents": [
      "faq"
    ],
    "default": {
      "response": {
        "id": 1388783286124362000,
        "confidence": 1,
        "intent_response_key": "faq/is_legit",
        "response_templates": [
          {
            "text": "absolutely",
            "image": "https://i.imgur.com/nGF1K8f.jpg"
          },
          {
            "text": "I think so."
          }
        ]
        "template_name": "utter_faq/is_legit"
      },
      "ranking": [
        {
          "id": 1388783286124362000,
          "confidence": 1,
          "intent_response_key": "faq/is_legit"
        }
      ]
    }
  }
}

结果就是如果以前按照以下方式查询键full_retrieval_intent

response_selector_output.get("default")
                        .get("full_retrieval_intent")

现在应该执行以下操作:

response_selector_output.get("default")
                        .get("response")
                        .get("intent_response_key")

6.Unfeaturized Slots

unfeaturized类型的slots已弃用,并将在3.0版中删除。 要在对话期间忽略slot values,请将slot的Impact_conversation属性设置为false

以下代码段是不推荐使用的unfeaturized slot 的示例:

slots:
  username:
    type: unfeaturized

要将其更新为新格式,可以指定所需的数据类型text,并定义在对话期间应忽略该slot。

slots:
  username:
    type: text
    # Set `influence_conversation` to `false`
    # to ignore the slot value during the conversation.
    influence_conversation: false

如果不要求slot具有特定的数据类型,则可以使用any新的slot类型。 在对话期间,始终会忽略此slot类型,并且不会对slot值的数据类型进行任何assumptions 。

slots:
  username:
    type: any

请参阅更新的 [slotsdocumentation(https://rasa.com/docs/rasa/domain#slots) 以获取更多信息。

7. Conversation sessions

如果Domain 中不包含会话配置,则默认情况下会启用Conversation sessions 。 以前,a missing会话配置被视为禁用了conversation sessions。我们可以使用以下代码段明确禁用conversation sessions:

domain.yml
session_config:
  # A session expiration time of `0`
  # disables conversation sessions
  session_expiration_time: 0

8. Dialogue Featurization

仅当在policy configuration中明确定义了featurizers时,此部分才有意义。

不推荐使用LabelTokenizerSingleStateFeaturizer,将来会将其删除。 应该用SingleStateFeaturizer替换它,并且应该对NLU管道进行一些更改。 将带有选项intent_tokenization_flag:TrueCountVectorsFeaturizerTokenizer添加到NLU管道。

例如:

language: en
pipeline:
  - name: WhitespaceTokenizer
    intent_tokenization_flag: True
  - name: CountVectorsFeaturizer
  # other components
policies:
  # other policies
  - name: TEDPolicy
    featurizer:
    - name: SingleStateFeaturizer

BinarySingleStateFeaturizer已弃用,以后将被删除。 应该将其替换为SingleStateFeaturizer和NLU管道,其中Tokenizerintent_tokenization_flag设置为False

例如:

language: en
pipeline:
  - name: WhitespaceTokenizer
    intent_tokenization_flag: False
  # other components
policies:
  # other policies
  - name: TEDPolicy
    featurizer:
    - name: SingleStateFeaturizer

8. Deprecations

不推荐使用的event brokers FileProducer,KafkaProducer,PikaProducer和SQLProducer已被删除。 如果在endpoints.yml中使用了这些brokers,请确保使用重命名的变体:

  • FileProducer 成为 FileEventBroker
  • KafkaProducer 成为 KafkaEventBroker
  • PikaProducer 成为 PikaEventBroker
  • SQLProducer 成为 SQLEventBroker

不推荐使用的EmbeddingIntentClassifier已被删除。 如果在管道配置(config.yml)中使用了此组件,则可以将其替换为DIETClassifier。 它接受相同的配置参数。

不推荐使用的KerasPolicy已被删除。 如果在策略配置(config.yml)中使用了此组件,则可以将其替换为TEDPolicy。 它接受相同的配置参数。

你可能感兴趣的:(3. Rasa2.0 学习笔记:版本迁移指南(下):1.10 to 2.0)