Rasa Transformers are not working

Hi all,

I’m trying to do custom entity with lookup, I tried to configure the nlu pipeline with the following config

language: en pipeline:

  • name: HFTransformersNLP model_weights: “bert-base-uncased” model_name: “bert”
  • name: LanguageModelTokenizer
  • name: LanguageModelFeaturizer
  • name: DIETClassifier
  • epochs: 200

However, I install rasa by the below command as per docs

pip install rasa transformers

but I’m running into the below errors while attempt to train nlu

Training NLU model… 2020-06-11 17:23:36 INFO transformers.file_utils - PyTorch version 1.5.0 available. 2020-06-11 17:23:36 INFO transformers.file_utils - TensorFlow version 2.1.1 available. Traceback (most recent call last): File “/home/msaravanan/.conda/envs/sentbert/bin/rasa”, line 8, in sys.exit(main()) File “/home/msaravanan/.conda/envs/sentbert/lib/python3.6/site-packages/rasa/main.py”, line 91, in main cmdline_arguments.func(cmdline_arguments) File “/home/msaravanan/.conda/envs/sentbert/lib/python3.6/site-packages/rasa/cli/train.py”, line 140, in train_nlu persist_nlu_training_data=args.persist_nlu_data, File “/home/msaravanan/.conda/envs/sentbert/lib/python3.6/site-packages/rasa/train.py”, line 414, in train_nlu persist_nlu_training_data, File “uvloop/loop.pyx”, line 1456, in uvloop.loop.Loop.run_until_complete File “/home/msaravanan/.conda/envs/sentbert/lib/python3.6/site-packages/rasa/train.py”, line 453, in _train_nlu_async persist_nlu_training_data=persist_nlu_training_data, File “/home/msaravanan/.conda/envs/sentbert/lib/python3.6/site-packages/rasa/train.py”, line 482, in _train_nlu_with_validated_data persist_nlu_training_data=persist_nlu_training_data, File “/home/msaravanan/.conda/envs/sentbert/lib/python3.6/site-packages/rasa/nlu/train.py”, line 75, in train trainer = Trainer(nlu_config, component_builder) File “/home/msaravanan/.conda/envs/sentbert/lib/python3.6/site-packages/rasa/nlu/model.py”, line 142, in init components.validate_requirements(cfg.component_names) File “/home/msaravanan/.conda/envs/sentbert/lib/python3.6/site-packages/rasa/nlu/components.py”, line 51, in validate_requirements component_class = registry.get_component_class(component_name) File “/home/msaravanan/.conda/envs/sentbert/lib/python3.6/site-packages/rasa/nlu/registry.py”, line 173, in get_component_class return class_from_module_path(component_name) File “/home/msaravanan/.conda/envs/sentbert/lib/python3.6/site-packages/rasa/utils/common.py”, line 196, in class_from_module_path if “.” in module_path: TypeError: argument of type ‘NoneType’ is not iterable

@akelad can you please provide any help on this ?

Could you please paste the log here, also let us know the versions of RASA/Rasa NLU/CORE you are using.

You can try : pip list | grep rasa

@mishra-atul5001 - below is the log

Training NLU model… 2020-06-12 00:00:38 INFO transformers.file_utils - PyTorch version 1.0.0 available. 2020-06-12 00:00:38 INFO transformers.file_utils - TensorFlow version 2.1.1 available. Traceback (most recent call last): File “/Users/malarvizhisaravanan/opt/anaconda3/bin/rasa”, line 10, in sys.exit(main()) File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/main.py”, line 91, in main cmdline_arguments.func(cmdline_arguments) File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/cli/train.py”, line 140, in train_nlu persist_nlu_training_data=args.persist_nlu_data, File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/train.py”, line 414, in train_nlu persist_nlu_training_data, File “uvloop/loop.pyx”, line 1456, in uvloop.loop.Loop.run_until_complete File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/train.py”, line 453, in _train_nlu_async persist_nlu_training_data=persist_nlu_training_data, File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/train.py”, line 482, in _train_nlu_with_validated_data persist_nlu_training_data=persist_nlu_training_data, File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/nlu/train.py”, line 75, in train trainer = Trainer(nlu_config, component_builder) File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/nlu/model.py”, line 142, in init components.validate_requirements(cfg.component_names) File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/nlu/components.py”, line 51, in validate_requirements component_class = registry.get_component_class(component_name) File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/nlu/registry.py”, line 173, in get_component_class return class_from_module_path(component_name) File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/utils/common.py”, line 196, in class_from_module_path if “.” in module_path: TypeError: argument of type ‘NoneType’ is not iterable (rasa_new) [email protected] demo % rasa train nlu --config config/config-hf.yml . usage: rasa [-h] [–version] {init,run,shell,train,interactive,test,visualize,data,export,x} … rasa: error: unrecognized arguments: . (rasa_new) [email protected] demo % rasa train nlu --config config/config-hf.yml
Training NLU model… 2020-06-12 00:02:29 INFO transformers.file_utils - PyTorch version 1.0.0 available. 2020-06-12 00:02:29 INFO transformers.file_utils - TensorFlow version 2.1.1 available. Traceback (most recent call last): File “/Users/malarvizhisaravanan/opt/anaconda3/bin/rasa”, line 10, in sys.exit(main()) File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/main.py”, line 91, in main cmdline_arguments.func(cmdline_arguments) File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/cli/train.py”, line 140, in train_nlu persist_nlu_training_data=args.persist_nlu_data, File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/train.py”, line 414, in train_nlu persist_nlu_training_data, File “uvloop/loop.pyx”, line 1456, in uvloop.loop.Loop.run_until_complete File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/train.py”, line 453, in _train_nlu_async persist_nlu_training_data=persist_nlu_training_data, File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/train.py”, line 482, in _train_nlu_with_validated_data persist_nlu_training_data=persist_nlu_training_data, File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/nlu/train.py”, line 75, in train trainer = Trainer(nlu_config, component_builder) File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/nlu/model.py”, line 142, in init components.validate_requirements(cfg.component_names) File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/nlu/components.py”, line 51, in validate_requirements component_class = registry.get_component_class(component_name) File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/nlu/registry.py”, line 173, in get_component_class return class_from_module_path(component_name) File “/Users/malarvizhisaravanan/opt/anaconda3/lib/python3.7/site-packages/rasa/utils/common.py”, line 196, in class_from_module_path if “.” in module_path: TypeError: argument of type ‘NoneType’ is not iterable

Rasa version

rasa 1.10.2
rasa-sdk 1.10.1

NLU Pipeline

language: en pipeline:

  • name: HFTransformersNLP

    model_name: “bert”

    model_weights: “bert-base-uncased”

  • name: “LanguageModelTokenizer”

  • name: “LanguageModelFeaturizer”

  • name: “RegexFeaturizer”

  • name: LexicalSyntacticFeaturizer features: [ [“low”, “title”, “upper”], [“BOS”, “EOS”, “low”, “upper”, “title”, “digit”], [“low”, “title”, “upper”], ]

  • name: DIETClassifier epochs: 100

  • epochs: 100

For any NLU config which has ConveRT or HFTransformer, this is the error.

I installed rasa using

pip install rasa[transformers]

Thanks in Advance!

@dakshvar22

I tried with virtualenv and latest rasa version

Training NLU model… 2020-06-15 14:02:17 INFO transformers.file_utils - TensorFlow version 2.1.1 available. Traceback (most recent call last): File “/Users/malarvizhisaravanan/Desktop/rasa sample/rasa/bin/rasa”, line 10, in sys.exit(main()) File “/Users/malarvizhisaravanan/Desktop/rasa sample/rasa/lib/python3.6/site-packages/rasa/main.py”, line 92, in main cmdline_arguments.func(cmdline_arguments) File “/Users/malarvizhisaravanan/Desktop/rasa sample/rasa/lib/python3.6/site-packages/rasa/cli/train.py”, line 140, in train_nlu persist_nlu_training_data=args.persist_nlu_data, File “/Users/malarvizhisaravanan/Desktop/rasa sample/rasa/lib/python3.6/site-packages/rasa/train.py”, line 414, in train_nlu persist_nlu_training_data, File “uvloop/loop.pyx”, line 1456, in uvloop.loop.Loop.run_until_complete File “/Users/malarvizhisaravanan/Desktop/rasa sample/rasa/lib/python3.6/site-packages/rasa/train.py”, line 453, in _train_nlu_async persist_nlu_training_data=persist_nlu_training_data, File “/Users/malarvizhisaravanan/Desktop/rasa sample/rasa/lib/python3.6/site-packages/rasa/train.py”, line 482, in _train_nlu_with_validated_data persist_nlu_training_data=persist_nlu_training_data, File “/Users/malarvizhisaravanan/Desktop/rasa sample/rasa/lib/python3.6/site-packages/rasa/nlu/train.py”, line 75, in train trainer = Trainer(nlu_config, component_builder) File “/Users/malarvizhisaravanan/Desktop/rasa sample/rasa/lib/python3.6/site-packages/rasa/nlu/model.py”, line 142, in init components.validate_requirements(cfg.component_names) File “/Users/malarvizhisaravanan/Desktop/rasa sample/rasa/lib/python3.6/site-packages/rasa/nlu/components.py”, line 51, in validate_requirements component_class = registry.get_component_class(component_name) File “/Users/malarvizhisaravanan/Desktop/rasa sample/rasa/lib/python3.6/site-packages/rasa/nlu/registry.py”, line 173, in get_component_class return class_from_module_path(component_name) File “/Users/malarvizhisaravanan/Desktop/rasa sample/rasa/lib/python3.6/site-packages/rasa/utils/common.py”, line 208, in class_from_module_path if “.” in module_path: TypeError: argument of type ‘NoneType’ is not iterable

At first I was working fine ,when I tried to rerun the model, it throws the same error again

I resolved the issue after some changes in the config.yml

language: en pipeline:

  • name: HFTransformersNLP

    model_name: “bert”

    model_weights: “bert-base-uncased”

    cache_dir: null

  • name: LanguageModelTokenizer

  • name: LanguageModelFeaturizer

  • name: RegexFeaturizer

  • name: CRFEntityExtractor BILOU_flag: True features: [ [“low”, “title”, “upper”], [“bias”, “low”, “prefix5”, “prefix2”, “suffix5”, “suffix3”, “suffix2”, “upper”, “title”, “digit”, “pattern”], [“low”, “title”, “upper”] ] analyzer: “char_wb” min_ngram: 1 max_ngram: 4 epochs: 500 max_iterations: 50 L1_c: 0.1 L2_c: 0.1

  • name: DIETClassifier intent_classification: False epochs: 500

  • name: SpacyNLP

  • name: SpacyEntityExtractor

    dimensions: [“PERSON”, “LOC”, “ORG”, “GPE”]

  • name: “DucklingHTTPExtractor”

    url: “http://localhost:8000

    dimensions: [“time”, “distance”, “duration”]

Now , I’m getting a log as below

2020-06-16 21:14:29 INFO transformers.modeling_tf_utils - loading weights file https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-tf_model.h5 from cache at /Users/malarvizhisaravanan/.cache/torch/transformers/d667df51ec24c20190f01fb4c20a21debc4c4fc12f7e2f5441ac0a99690e3ee9.4733ec82e81d40e9cf5fd04556267d8958fb150e9339390fc64206b7e5a79c83.h5 2020-06-16 21:14:32 INFO transformers.modeling_tf_utils - Layers from pretrained model not used in TFBertModel: [‘nsp___cls’, ‘mlm___cls’] 2020-06-16 21:14:32 INFO rasa.nlu.utils.spacy_utils - Trying to load spacy model with name ‘en’ 2020-06-16 21:14:46 INFO rasa.nlu.components - Added ‘SpacyNLP’ to component cache. Key ‘SpacyNLP-en’. 2020-06-16 21:14:46 INFO rasa.nlu.training_data.training_data - Training data stats: 2020-06-16 21:14:46 INFO rasa.nlu.training_data.training_data - Number of intent examples: 174 (1 distinct intents)

Can explain what is this statement means which is highlighted in the logs? @dakshvar22 / @mishra-atul5001

Was the fix just about adding cache_dir:null to the config? Regarding the logging statement, that’s completely normal. It’s one of the fine-tuning layers that shouldn’t actually be used and hence the statement.