Train Rasa NLU without having to restart the server

Hi, I’m using only RASA nlu and not the core part. Everytime I have to make a change in nlu.md file, I need to retrain and run the model which leads to downtime of server. Is it possible to train and create the model in the background and then execute the new model without having to restart the server?

I’m testing out a few things with our API to see what you might could accomplish there, HTTP API. Is there a need to use the Rasa Core piece? If so you could check out Rasa X and maybe install it and test it.

It would allow you to learn from conversations if you used the core piece and be able to update your training via the UI and then make the new model active.

Just something else to think about, I’ll let you know more about the API calls I just need to test a few things on it.

@Farheen-J I believe HTTP API should work for what you want. You would just supply it the new model file location on the server or from a remote location and update it that way.

@btotharye, I’m using only RASA NLU part and not the CORE one. also:

  1. I tried training the model using HTTP API using /model/train. In JSON body, the attributes like config, nlu, etc has to be passed in the form of string. They could not be loaded from a file. Also, the model is generated in .tar.gz format which doesn’t seem compatible with below replace API call
  2. I used /model/ to replace the current model, I got the response message as “An unexpected error occured, Error: File is not a Zip file”

Ok I’m traveling for the next day but I’ll check into this for you and see what we can get going.

I think the best approach since you don’t really have a CI/CD pipeline atm I’m assuming would be to do the following below, I"ll give both approaches in case you have something like Jenkins and are curious how that might look:

No CI/CD(Jenkins, Travis,etc)

  1. Train your model data somewhere, locally wherever and get your model zip file.
  2. Then you should be able to call the /model endpoint with a put and specify the remote storage option maybe and pull it in that way. Otherwise you could probably use ssh or something to upload the model zip file to the server in the models dir as well.
  3. Run the API call to update the model to the new file.

CI/CD Used

If you have CI/CD like Jenkins, Travis, Bamboo, etc you can follow this flow

  1. Run your job and have it run whatever tests you want etc, then have it run the rasa train command which would create a new model file, you could then upload this to remote storage like AWS, etc.
  2. Then in the same job have it run the API command to pull that model from the remote storage and make it active, etc.

Hope this is more clear atm, let me know if it isn’t. You could also look at using Rasa X which has an option for uploading models and data and such via the browser.

@btotharye, But when I call /model endpoint, it says file is not a zip file. Error code 500 internal server error. Below is the Request body I used. Please find my comments inline.

{ “model_file”: “/models/.tar.gz”, “model_server”: { “url”: “http://localhost:5005”, //this is where my new model is present, I also tried using openshift url where my rasa nlu is deployed…still no luck “params”: {}, “headers”: {}, “basic_auth”: {}, “token”: “string”, “token_name”: “string”, “wait_time_between_pulls”: 0 }, “remote_storage”: “aws” //don’t have a remote storage, I’m training on exisiting server. }

just to verify you are giving it the full name of the file right cause there there is only showing .tar.gz as the model file.

@btotharye Yeah I did give the full name while calling the API. The above comment has a typo.

What is the error message or response data it gives when it fails?

@btotharye, Response body: { version: “1.3.9”, “status”: “failure”, “message”: “An unexpected error occured. Error: file is not a zip file.” “reason”: “LoadingError”, “details”: {}, “help”: null, “code”: 500 }

Error code: 500 internal server error.

Ah that is right you posted that before, ok let me see if I can reproduce this here on my setup then.

@btotharye Hi, did you get a chance to look into this?

Sorry was on vacation and the holiday so was pretty busy. I’ll try get you something by tomorrow on this.

Thanks

Thank you :slight_smile:

I’m still having issues as well with the not a zip file error so I’m working with it, will let you know when I get it working.

Sure. Thank you :slight_smile:

So the issue we were both hitting was we don’t need to actually provide the model_server in this case since we are wanting it to pull from the local API instance of Rasa we are calling. So just update your payload to be something like the below and it should work:

{
	"model_file": "models/20191206-105544.tar.gz"
}
1 Like

@btotharye Yep, that worked. :smiley: So, correct me if I’m wrong, model_server is required if RASA is using a model stored on some remote storage right?

I believe so, I don’t think you need it for remote storage like AWS, etc. I’m still looking into the code base to see more about it just haven’t had time myself yet.