Training a model i

Hello, I am new to coding and I am working on a bot from scratch, I have read the documentation but I am missing how I can train a model. I understood the two options “Markdown” and “JSON” but I am not sure where to train the model. Should I create a file (not sure which would be the extension for that file) and then call it within Python? I am sure it is a very basic question but I have not been able to find the answer in the documentation. Thanks in advance.

Hey Juan. To train NLU model from scratch you will need two files:

  • nlu training data file (markdown or json which will have .md or .json extensions respectively)
  • a configuration file (with .yml extension)

So let’s say you create a directory for you project called rasa_bot. Inside that directory you should put those two files (let’s say you saved your configuration file as nlu_config.yml and training data file as nlu.md and then in your terminal you can train the model using this function:

python -m rasa_nlu.train -c nlu_config.yml --data nlu.md -o models --fixed_model_name nlu --project current --verbose

This function trains the model by calling rasa nlu train function and passes configuration file as well as data file. Aslo, with fixed_model_name parameter you can set a fixed name for your model (in this example we call it nlu) and also we set the name for our project current. Parameters verbose prints our the training results as the training functions does its job.

I would also suggest you going through the quickstart on Rasa nlu docs, this shows the process step by step and you can try it all out there or save the code and run it locally on your machine: http://rasa.com/docs/nlu/quickstart/

@Juste Thank you very much for your answer I was indeed looking someplace else! will try the docs exercises. Best regards,

Juan Sandino

@Juste thanks again, I tired the exercises but got an error in step 3. Train your Machine Learning NLU model. when using the line:

python -m rasa_nlu.train -c nlu_config.yml --data nlu.md -o models --fixed_model_name nlu --project current --verbose

The error is the following:

Juans-MacBook-Air-2:rasa_bot juansandino$ python -m rasa_nlu.train -c nlu_config.yml --data nlu.md -o models --fixed_model_name nlu --project current --verbose Traceback (most recent call last): File “/Users/juansandino/anaconda3/lib/python3.6/runpy.py”, line 193, in _run_module_as_main “main”, mod_spec) File “/Users/juansandino/anaconda3/lib/python3.6/runpy.py”, line 85, in _run_code exec(code, run_globals) File “/Users/juansandino/anaconda3/lib/python3.6/site-packages/rasa_nlu/train.py”, line 174, in num_threads=cmdline_args.num_threads) File “/Users/juansandino/anaconda3/lib/python3.6/site-packages/rasa_nlu/train.py”, line 143, in do_train trainer = Trainer(cfg, component_builder) File “/Users/juansandino/anaconda3/lib/python3.6/site-packages/rasa_nlu/model.py”, line 152, in init components.validate_requirements(cfg.component_names) File “/Users/juansandino/anaconda3/lib/python3.6/site-packages/rasa_nlu/components.py”, line 63, in validate_requirements “Please install {}”.format(", ".join(failed_imports))) Exception: Not all required packages are installed. To use this pipeline, you need to install the missing dependencies. Please install tensorflow

I had already installed the following:

pip install rasa_nlu

pip install rasa_nlu[tensorflow]

And also did this:

pip install --upgrade --force-reinstall rasa_nlu[tensorflow]

but got this errors:

Successfully built pyyaml greenlet

tensorflow 1.10.1 has requirement numpy<=1.14.5,>=1.13.3, but you’ll have numpy 1.15.1 which is incompatible.

Found existing installation: docutils 0.14

Cannot uninstall ‘docutils’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

Could you please help? Thanks in advance.

Juan Sandino

Hmm. Seems like tensorflow doesn’t get installed for some reason. Does the issue persists if you run a pip install of tensorflow?

pip install tensorflow

Thanks for the quick reply. Not working when running a pip tensorflow, saying the requirement is already satisfied as is Tensorflow is already installed.

Any other clue?

Thank you very much for your help and support!

tensorflow 1.10.1 has requirement numpy<=1.14.5,>=1.13.3, but you’ll have numpy 1.15.1

You have incompatible versions - upgrade your tensorflow. If you are using anaconda then just run the navigator and it should allow you to upgrade from gui else use --upgrade with pip command

Yeah, it looks like it’s an issue between tensorflow and numpy versions. I would try downgrading numpy to 1.14.5 which I think is the latest compatible version with tensorflow. A bit weird though that installing tensorflow doesn’t downgrade numpy automatically.

@JuanSandino, instead of messing around with version numbers for packages, just use anaconda. You should have a much better time creating an anaconda environment and installing the needed packages within there.

Thanks for your response, I am using anaconda and got the navigator open, however I do not have Tensorflow there. Where should I found it! Thanks again.

@Juste thanks for the response. Should I downgrade within the terminal? Thanks in advance!

@sirusss Thanks for your help I did within an Anaconda environment and it worked fine Thanks again!

1 Like

Hi, i already did pip3.4 install -r requirements.txt and start with: python3.4 -m rasa_nlu.server --config /home/ptin_admin/rasa_nlu-0.14.3/config.yml --path /home/ptin_admin/rasa_nlu-0.14.3/projects --port 5000 --max_training_processes 5 --num_threads 2

my pipeline:

and when i execute http://10.113.134.44:5000/train?project=justTesting i got this error:

“error”: “Not all required packages are installed. To use this pipeline, you need to install the missing dependencies. Please install tensorflow”

but i already have tensorflow version according to the requirements

Can you help me? Thanks

Hey @sfurao. Any chance you have both python 2.7 and python 3 on your machine?

yes. I have a centOS6 machine that have python 2.7, but i installed the 3.4 on the rasa nlu folder. Im using 0.14.0 rasa nlu version. And /config is deprecated.

I did this HTTP post to train but with no success.

Hi Juste, After release of RASA-X “python -m rasa_nlu.train -c nlu_config.yml --data nlu.md -o models --fixed_model_name nlu --project current --verbose” command seems to be not supported. Please help.

Just now solved the issue, in rasa-x it is “python -m rasa_nlu.train -c nlu_config.yml --data nlu.md -o models --fixed-model-name nlu --project current --verbose”. In fixed model name replace _ by -