Rasa 1.4.6 - Python code to Train - Test manually

Python version : 3.6 OS - MacOS Rasa installed in virtual environment

Used the below code to train the model from rasa.train import train_nlu import os

module_directory = os.path.join("/Users/kishorekumarg/Desktop/models")
module_name = "20191124-210721.tar.gz"
config_file = '/Users/kishorekumarg/Downloads/Rasa/nlu_model_config.json'
nlu_data = '/Users/kishorekumarg/Downloads/rasa_training_en.json'

train_nlu(
    config=config_file,
    nlu_data=nlu_data,
    output=module_directory,
    fixed_model_name=module_name
)
print('done')

Inside the Virtual environment executed the above code and got the model trained as below. (venv) kishorekumarg@KISHOREs-MacBook-Pro programs % python traincopy.py

Training NLU model...

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensor2tensor/utils/expert_utils.py:68: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

WARNING:tensorflow:

The TensorFlow contrib module will not be included in TensorFlow 2.0.

For more information, please see:

* https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md

* https://github.com/tensorflow/addons

* https://github.com/tensorflow/io (for I/O related ops)

If you depend on functionality not listed there, please file an issue.

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensor2tensor/utils/adafactor.py:27: The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.train.Optimizer instead.

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensor2tensor/utils/multistep_optimizer.py:32: The name tf.train.AdamOptimizer is deprecated. Please use tf.compat.v1.train.AdamOptimizer instead.

WARNING:tensorflow:Failed to load tensor2tensor

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensor2tensor/models/research/glow_init_hook.py:25: The name tf.train.SessionRunHook is deprecated. Please use tf.estimator.SessionRunHook instead.

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensor2tensor/models/research/neural_stack.py:38: The name tf.nn.rnn_cell.RNNCell is deprecated. Please use tf.compat.v1.nn.rnn_cell.RNNCell instead.

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensor2tensor/rl/gym_utils.py:235: The name tf.logging.info is deprecated. Please use tf.compat.v1.logging.info instead.

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensor2tensor/utils/trainer_lib.py:111: The name tf.OptimizerOptions is deprecated. Please use tf.compat.v1.OptimizerOptions instead.

WARNING:tensorflow:From /Users/kishorekumarg/Desktop/venv/lib/python3.6/site-packages/tensorflow_gan/python/estimator/tpu_gan_estimator.py:42: The name tf.estimator.tpu.TPUEstimator is deprecated. Please use tf.compat.v1.estimator.tpu.TPUEstimator instead.

Fitting 5 folds for each of 6 candidates, totalling 30 fits

[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.

[Parallel(n_jobs=1)]: Done 30 out of 30 | elapsed: 2.5min finished

NLU model training completed.

Your Rasa model is trained and saved at '/Users/kishorekumarg/Desktop/models/20191124-210721.tar.gz.tar.gz'.

done

Now tried to test the same by passing a set of statement using the below code.

from rasa_nlu.model import Metadata, Interpreter

import json

# where `model_directory points to the folder the model is persisted in
interpreter = Interpreter.load('/Users/kishorekumarg/Desktop/models/20191124-210721.tar.gz')

The Error I have got is below.

rasa_nlu.model.InvalidProjectError: Failed to load model metadata from '/Users/kishorekumarg/Desktop/models/20191124-210721.tar.gz/metadata.json'. [Errno 20] Not a directory: '/Users/kishorekumarg/Desktop/models/20191124-210721.tar.gz/metadata.json'

My objective is to train a model in RASA Spacy_sklearn as config and to test the same with set of statements as a kind of benchmarking activity. I am stuck with the below - can you please help me in this regard. I understand a lot has changed with rasa 0.14 to 1.4.6. Even for the training the model with python code - I have got the code from the rasa blog. It would be great if you could help on the testing the same model with python.

Thanks Kishore

Any updates on the above please??

Were you able to fix it??

Can you suggest something? @souvikg10 @Emma @Juste

Hey @rohitnairtech. Which Rasa version are you running? I would suggest updating to the latest release - 1.8

Thanks for the reply @Juste I’m on 1.1.1.

However, I managed to fix the error by extracting the tar.gz and pointing to that directory. Agent.load("…/models/demo") Interpreter.load("…/models/demo/nlu")

I can’t upgrade to the latest version because of some issue from the latest tensorflow library which doesn’t support my CPU architecture.

I have installed RASA in an virtual environment it installs 1.5. Ideally its expected to install 1.8 or later now is 1.9. I have used the command as pip install rasa