Rasa train nlu error

I get the following error when I run rasa train nlu:

File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa/nlu/utils/spacy_utils.py”, line 97, in cache_key return cls.name + “-” + spacy_model_name TypeError: can only concatenate str (not “NoneType”) to str

I have the following configuration: language: en

pipeline:

  • name: SpacyNLP
  • name: SpacyTokenizer
  • name: SpacyFeaturizer
  • name: RegexFeaturizer
  • name: LexicalSyntacticFeaturizer
  • name: CountVectorsFeaturizer
  • name: CountVectorsFeaturizer analyzer: “char_wb” min_ngram: 1 max_ngram: 4
  • name: DIETClassifier epochs: 100
  • name: EntitySynonymMapper
  • name: ResponseSelector epochs: 100
  • name: SpacyTokenizer intent_tokenization_flag: True intent_split_symbol: “+”

policies:

# No configuration for policies was provided. The following default policies were used to train your model.

# If you’d like to customize them, uncomment and adjust the policies.

# See Policies for more information.

  • name: AugmentedMemoizationPolicy
  • name: UnexpecTEDIntentPolicy max_history: 5 epochs: 200
  • name: TEDPolicy max_history: None epochs: 200 constrain_similarities: true

I am just getting started with this. I am watching the YouTube series and reading https://rasa.com/docs/ for both rasa open source and rasa x.

I will appreciate your help.

Training NLU model… Traceback (most recent call last): File “/Library/Frameworks/Python.framework/Versions/3.8/bin/rasa”, line 8, in sys.exit(main()) File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa/main.py”, line 118, in main cmdline_arguments.func(cmdline_arguments) File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa/cli/train.py”, line 196, in run_nlu_training return train_nlu( File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa/model_training.py”, line 646, in train_nlu return rasa.utils.common.run_in_loop( File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa/utils/common.py”, line 296, in run_in_loop result = loop.run_until_complete(f) File “uvloop/loop.pyx”, line 1456, in uvloop.loop.Loop.run_until_complete File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa/model_training.py”, line 696, in train_nlu_async return await _train_nlu_with_validated_data( File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa/model_training.py”, line 758, in _train_nlu_with_validated_data await rasa.nlu.train.train( File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa/nlu/train.py”, line 96, in train trainer = Trainer( File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa/nlu/model.py”, line 169, in init self.pipeline = self._build_pipeline(cfg, component_builder) File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa/nlu/model.py”, line 180, in _build_pipeline component = component_builder.create_component(component_cfg, cfg) File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa/nlu/components.py”, line 936, in create_component component, cache_key = self.__get_cached_component( File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa/nlu/components.py”, line 853, in __get_cached_component cache_key = component_class.cache_key(component_meta, model_metadata) File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/rasa/nlu/utils/spacy_utils.py”, line 97, in cache_key return cls.name + “-” + spacy_model_name TypeError: can only concatenate str (not “NoneType”) to str

1 Like

@AzizDiallo Hello, I can see there is no model in your pipeline for Spacy? Ref: Components please even check the other components also such as SpacyTokenizer and SpacyFeaturizer Ref: Components

@AzizDiallo I hope you install the dependencies spacy in the environment?

pip install rasa[spacy]
python -m spacy download en_core_web_md

Ref: Installation

I hope these pointers will help you! Good Luck!

@nik202 Thank you for replying. Before running rasa train nlu, I followed what is mentioned at Installing Rasa Spacy error - #2 by Arjaan and ran pip install -U “rasa[spacy]” then pip3 install -U “rasa[spacy]” and python3 -m space download en_core_web_md.

I am using a MacBook. the command you mentioned didn’t work for me.

It only works when I use default pipeline setting (empty).

@AzizDiallo share your config.yml file again to me.

+1.

I am facing the same error with rasa 2.8.10 myself. @nik202 Here’s the config file I am using, if that helps

language: en

pipeline:
# # If you'd like to customize it, uncomment and adjust the pipeline.
# # See https://rasa.com/docs/rasa/tuning-your-model for more information.
   - name: SpacyNLP
   - name: SpacyTokenizer
   - name: SpacyFeaturizer
   - name: RegexFeaturizer
   - name: LexicalSyntacticFeaturizer
   - name: CountVectorsFeaturizer
   - name: CountVectorsFeaturizer
     analyzer: char_wb
     min_ngram: 1
     max_ngram: 4
   - name: DIETClassifier
     epochs: 100
   - name: EntitySynonymMapper
   - name: ResponseSelector
     epochs: 100
   - name: FallbackClassifier
     threshold: 0.3
     ambiguity_threshold: 0.1

# Configuration for Rasa Core.
# https://rasa.com/docs/rasa/core/policies/
policies:
# # No configuration for policies was provided. The following default policies were used to train your model.
# # If you'd like to customize them, uncomment and adjust the policies.
# # See https://rasa.com/docs/rasa/policies for more information.
#   - name: MemoizationPolicy
#   - name: RulePolicy
#   - name: UnexpecTEDIntentPolicy
#     max_history: 5
#     epochs: 100
#   - name: TEDPolicy
#     max_history: 5
#     epochs: 100
#     constrain_similarities: true

@shalabhsingh Hope you seen this?

pipeline:
- name: "SpacyNLP"
  # language model to load
  model: "en_core_web_md"

Ref: Components Please see

1 Like

@AzizDiallo Did you seen a complete post of mine or only command?

pipeline:
- name: "SpacyNLP"
  # language model to load
  model: "en_core_web_md"

Thanks, this solved the problem. There is some documentation inconsistency I guess. I was referring to this and no model parameter was added there for some reason.

@shalabhsingh Thanks for the feedback and glad this solved your issue!

Thank you @nik202. Putting the quotes works. my config.yml

Configuration for Rasa NLU.

Components

language: en

pipeline: - name: “SpacyNLP” model: “en_core_web_md” - name: “SpacyTokenizer” intent_tokenization_flag: True intent_split_symbol: “+” - name: “SpacyFeaturizer” - name: “RegexFeaturizer” - name: “LexicalSyntacticFeaturizer” - name: “CountVectorsFeaturizer” - name: “CountVectorsFeaturizer” analyzer: “char_wb” min_ngram: 1 max_ngram: 4 - name: “DIETClassifier” epochs: 100 - name: “EntitySynonymMapper” - name: “ResponseSelector” epochs: 100

Configuration for Rasa Core.

Policies

policies:

# No configuration for policies was provided. The following default policies were used to train your model.

# If you’d like to customize them, uncomment and adjust the policies.

# See Policies for more information.

  • name: “AugmentedMemoizationPolicy”
  • name: “UnexpecTEDIntentPolicy” epochs: 100
  • name: “TEDPolicy” epochs: 200 constrain_similarities: true

I am trying to do sentiment analysis and identifying values (eg: rasa is important to me).