TypeError: 'NoneType' object is not iterable - spacy

Hi All,

The following error is being encountered during NLU training related to spacy. I have followed the installation procedure of spacy and it’s models as detailed in RASA documentation.

2020-04-07 11:07:07 INFO     rasa.nlu.utils.spacy_utils  - Trying to load spacy model with name 'en'
2020-04-07 11:07:07 INFO     rasa.nlu.components  - Added 'SpacyNLP' to component cache. Key 'SpacyNLP-en'.
Traceback (most recent call last):
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\sandi\anaconda3\envs\chatbot\Scripts\rasa.exe\__main__.py", line 7, in <module>
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\__main__.py", line 91, in main
    cmdline_arguments.func(cmdline_arguments)
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\cli\train.py", line 76, in train
    additional_arguments=extract_additional_arguments(args),
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\train.py", line 50, in train
    additional_arguments=additional_arguments,
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\asyncio\base_events.py", line 488, in run_until_complete
    return future.result()
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\train.py", line 101, in train_async
    additional_arguments,
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\train.py", line 188, in _train_async_internal
    additional_arguments=additional_arguments,
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\train.py", line 245, in _do_training
    persist_nlu_training_data=persist_nlu_training_data,
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\train.py", line 474, in _train_nlu_with_validated_data
    persist_nlu_training_data=persist_nlu_training_data,
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\nlu\train.py", line 74, in train
    trainer = Trainer(nlu_config, component_builder)
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\nlu\model.py", line 145, in __init__
    self.pipeline = self._build_pipeline(cfg, component_builder)
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\nlu\model.py", line 157, in _build_pipeline
    component = component_builder.create_component(component_cfg, cfg)
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\nlu\components.py", line 680, in create_component
    component = registry.create_component_by_config(component_config, cfg)
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\nlu\registry.py", line 246, in create_component_by_config
    return component_class.create(component_config, config)
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\nlu\components.py", line 394, in create
    return cls(component_config)
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\nlu\classifiers\diet_classifier.py", line 274, in __init__
    super().__init__(component_config)
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\nlu\components.py", line 317, in __init__
    self.component_config = override_defaults(self.defaults, component_config)
  File "c:\users\sandi\anaconda3\envs\chatbot\lib\site-packages\rasa\nlu\config.py", line 64, in override_defaults
    cfg[key].update(custom[key])
TypeError: 'NoneType' object is not iterable

The following is my NLU pipeline:

pipeline:
  - name: SpacyNLP
    case_sensitive: False
  - name: WhitespaceTokenizer
  - name: CountVectorsFeaturizer
    analyzer: "char_wb"
    min_ngram: 1
    max_ngram: 4
  - name: DIETClassifier
    hidden_layers_sizes:
    text: [256, 128]
    number_of_transformer_layers: 0
    weight_sparsity: 0
    intent_classification: True
    entity_recognition: False
    use_masked_language_model: False
    BILOU_flag: False
    epochs: 50
  - name: EntitySynonymMapper

Hi there! It looks like you’re missing an indent before the text: [256,128], like this:

...
  - name: DIETClassifier
    hidden_layers_sizes:
      text:[256, 128]
    number_of_transformer_layers: 0
...

You also appear to be missing a CountVectorsFeaturizer in your pipeline (there should be another one right after the WhitespaceTokenizer, with no parameters, so it defaults to analyzer: "word"). A lot of people think this is a mistake and that the line is repeated, and so remove it.

Apologies for the late response.

Yes, it’s an indentation error. I started using sublime text editor for a better view and it served the purpose.

Yes, i have treated it as a redundant one and deleted it without knowing. I have put it back later. Thanks for your effort in answering the problem.