找不到“ supervised_embeddings”的组件类。未知的组件名称

时间:2019-05-30 15:41:45

标签: python chatbot rasa-nlu

我想测试结合了supervised_embeddings的SpacyNLP管道。但是,如果我尝试启动它,则会得到此堆栈跟踪。如果在config.yml中仅保留supervised_embeddings,则不会发生这种情况。 但是,如果我尝试仅离开SpacyNLP管道,则会收到此错误:

InvalidConfigError: No pipeline specified and unknown pipeline template 'SpacyNLP' passed. Known pipeline templates: pretrained_embeddings_spacy, keyword, supervised_embeddings

有什么我想念的吗?

KeyError                                  Traceback (most recent call last)
~\Anaconda3\lib\site-packages\rasa\nlu\registry.py in get_component_class(component_name)
    140             try:
--> 141                 return utils.class_from_module_path(component_name)
    142             except Exception:

~\Anaconda3\lib\site-packages\rasa\nlu\utils\__init__.py in class_from_module_path(module_path)
    143     else:
--> 144         return globals()[module_path]
    145

KeyError: 'supervised_embeddings'

During handling of the above exception, another exception occurred:

Exception                                 Traceback (most recent call last)
<ipython-input-109-971025f984ec> in <module>
      8
      9 # trainer to educate our pipeline
---> 10 trainer = Trainer(config.load("config.yml"))
     11
     12 # train the model!

~\Anaconda3\lib\site-packages\rasa\nlu\model.py in __init__(self, cfg, component_builder, skip_validation)
    146         # required packages are available
    147         if not self.skip_validation:
--> 148             components.validate_requirements(cfg.component_names)
    149
    150         # build pipeline

~\Anaconda3\lib\site-packages\rasa\nlu\components.py in validate_requirements(component_names)
     34     failed_imports = set()
     35     for component_name in component_names:
---> 36         component_class = registry.get_component_class(component_name)
     37         failed_imports.update(
     38             find_unavailable_packages(component_class.required_packages())

~\Anaconda3\lib\site-packages\rasa\nlu\registry.py in get_component_class(component_name)
    148                     "listed as part of the `component_classes` in "
    149                     "`rasa.nlu.registry.py` or is a proper name of a class "
--> 150                     "in a module.".format(component_name)
    151                 )
    152         else:

Exception: Failed to find component class for 'supervised_embeddings'. Unknown component name. Check your configured pipeline and make sure the mentioned component is not misspelled. If you are creating your own component, make sure it is either listed as part of the `component_classes` in `rasa.nlu.registry.py` or is a proper name of a class in a module.

config.yml文件

# https://rasa.com/docs/rasa/nlu/components/
language: it_core_news_sm
pipeline:
  - name: supervised_embeddings
  - name: SpacyNLP

# Configuration for Rasa Core.
# https://rasa.com/docs/rasa/core/policies/
policies:
  - name: MemoizationPolicy
  - name: KerasPolicy
  - name: MappingPolicy

1 个答案:

答案 0 :(得分:1)

我认为您正在将preconfigured pipelines(这些是预定义的模板)与实际的NLU components混淆。

如果您使用的是预配置,则为:

pipeline: supervised_embeddings

相同(有点捷径)
pipeline:
- name: "WhitespaceTokenizer"
- name: "RegexFeaturizer"
- name: "CRFEntityExtractor"
- name: "EntitySynonymMapper"
- name: "CountVectorsFeaturizer"
- name: "EmbeddingIntentClassifier"