【问题标题】:Rasa `RegexEntityExtractor` extracting non entities as entitiesRasa`RegexEntityExtractor`将非实体提取为实体
【发布时间】:2021-11-22 18:41:34
【问题描述】:

我试图从输入中提取用户名。这是相关的训练数据(我没有提供完整的数据,因为这会使问题变得臃肿):

nlu:

- intent: greet
  examples: |
    - hey
    - hello
    - hi
    - hello there

- intent: en_name
  examples: |
    - my name is [adarsh](name)
    - name is [suma](name)
    - I am [sourav](name)

- regex: name
  examples: |
    - \w{2,40}
stories:

- story: Start conversation
  - intent: greet
  - action: utter_greet
  - action: utter_help
  - intent: seek_scheme
  - action: user_info_form
  - active_loop: user_info_form
rules:

- rule: activate form
  steps:
    - intent: seek_scheme
    - action : user_info_form
    - active_loop: user_info_form

- rule : submit form
  condition:
    - active_loop: user_info_form
  steps:
    - action : user_info_form
    - active_loop: null
    - slot_was_set:
        - requested_slot : null
    - action: utter_submit
    - action: utter_slot_values

- rule : Deviated form path
  condition:
    - active_loop: user_info_form
  steps:
    - intent: bot_challenge
    - action: utter_iamabot
    - action : user_info_form
    - active_loop: user_info_form

在这里,由于我使用的是正则表达式,因此我必须为我的管道添加 RegexEntityExtractor。但是添加它之后,即使是“hi”作为输入,也会被视为实体 name。这是 rasa 交互式会话的示例:

? Your input -> hi
? Is the intent 'greet' correct for '[hi](name)' and are all entities labeled correctly? No
? What intent is it? 1.00 greet
? Please mark the entities using [value](type) notation hi

像这样,对于我提供的任何单词,它都将其标记为实体 name。我想这是因为RegexEntityExtractor 在提取实体时没有考虑意图。如何解决这个问题?

【问题讨论】:

    标签: rasa rasa-nlu named-entity-extraction


    【解决方案1】:

    我认为根据您的 name 正则表达式定义为 \w{2,40} 任何介于 2 到 40 个字符之间的单词都将被匹配并标记为实体。

    根据documentation,RegexEntityExtractor 将使用定义的正则表达式和查找表。因此,如果您有想要提取的名称列表,可以将它们添加到查找表中。

    如果您想从训练数据中学习实体,您可以使用可训练的提取器,如 DIETClassifier 或 CRFEntityExtractor,或提取人名的预训练模型,如 SpacyEntityExtractor。

    您还可以查看Rasa Community Forum 以获取相关线程和建议的管道配置。

    【讨论】:

    • 我想建立这是卡纳达语,所以没有 Spacy 管道。无法根据响应的上下文提取实体?
    • 在这种情况下,您可以使用DIETClassifier 根据训练数据学习实体。对于特征化,您可以仅使用稀疏特征(例如CountVectorsFeaturizer、LexicalSyntacticFeaturizer),或者尝试来自rasa-nlu-examples 的字节对嵌入,我认为它具有预训练的Kannada model。有关如何将其添加到 NLU 管道的示例,请参见 here。
    猜你喜欢
    • 1970-01-01
    • 2019-09-04
    • 1970-01-01
    • 2019-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-11
    相关资源
    最近更新 更多