在 rasa 中训练模型后查找表不起作用

时间:2021-01-08 02:47:44

标签: rasa-nlu rasa rasa-core

我是 rasa 的新手。我正在训练一个模型来使用查找表识别某些实体。我在一个句子中有多个实体,我正在尝试提取它们。

nlu.yml

version: "2.0"
nlu:
- intent: intent_1
  examples : |
    - how many deaths were there last year in [Ohio](Filter-State)?
    - death count of [Florida](Filter-State) this year
    - death count of [Texas](Filter-State) this year
    - what's the death count for this quarter in [CA](Filter-State)?
- lookup: Filter-State
  examples: |
    - Alabama
    - AL
    - Alaska
    - AK
    - Arizona
    - AZ
    - Arkansas
    - AR
    - California
    - CA
    - Colorado
    - CO
    - Connecticut
    - CT
    - Delaware
    - DE
    - District of Columbia
    - DC
    - Florida
    - FL
    - Georgia
    - GA

config.yml

language: en
pipeline:
  - name: WhitespaceTokenizer
  - name: RegexFeaturizer
  - name: LexicalSyntacticFeaturizer
  - name: CountVectorsFeaturizer
  - name: CountVectorsFeaturizer
    analyzer: "char_wb"
    min_ngram: 1
    max_ngram: 4
  - name: DIETClassifier
    epochs: 150
    random_seed: 1
  - name: FallbackClassifier
    threshold: 0.7
  - name: DucklingEntityExtractor
    url: http://duckling.rasa.com:8000
    dimensions:
    - email
    - time
  - name: EntitySynonymMapper
policies:
  - name: AugmentedMemoizationPolicy
    max_history: 4
  - name: TEDPolicy
    max_history: 4
    epochs: 100
  - name: RulePolicy
    core_fallback_threshold: 0.4
    core_fallback_action_name: "action_default_fallback"
    enable_fallback_prediction: True

当我训练模型并尝试使用 api 时,它无法从查找表中的状态识别案例,因此无法将其分配给插槽 filter_state。

谁能告诉我我在这里做错了什么来使查找表正常工作!

2 个答案:

答案 0 :(得分:4)

我是 Rasa 的新手,正在寻找另一个问题,但我昨晚刚遇到并解决了这个问题。

要使查找表起作用,您需要将“RegexEntityExtractor”添加到您的管道中,并可能删除 RegexFeaturizer。您还需要在 RegexEntityExtractor 配置中启用查找表。

config.yml

pipeline:
   - name: WhitespaceTokenizer
   - name: LexicalSyntacticFeaturizer
   - name: CountVectorsFeaturizer

   - name: RegexEntityExtractor
     case_sensitive: False
     use_lookup_tables: True
     use_regexes: True
...

答案 1 :(得分:0)

能否请您在 Rasa forum 上发帖并提供有关您的设置的更多详细信息?特别是,您使用的是哪个版本的 Rasa 开源?以上是您的完整 NLU 数据吗? (我认为您需要至少 2 个意图来训练意图分类器。)我还建议您使用 rasa interactive --debug 测试系统并分享例如截图,这将帮助每个人看到确切的输入消息以及它是如何被 Rasa 处理的。我相信我们会追查到问题的根源:-)