Rasa 3.0 /model/train not working for me

I am trying to test the Rasa 3.0 model /train endpoint and it does not seem to work for me.

I started the server using:

rasa run     -m models     --enable-api     --log-file out.log     --auth-token thisismysecret

After testing out different variations of the endpoint call and different yaml training data configuration, the best I could come up with is the following:

curl -XPOST "localhost:5005/model/train?save_to_default_model_directory=false&force_training=true&token=thisismysecret" -d '{version: \"3.0\", pipeline: [], policies: [], intents: [greet, goodbye, bot_challenge], entities: [], slots: {}, actions: [], forms: {}, e2e_actions: [], responses: {utter_greet: [{text: "Hello, this is the callback bot service powered by Rasa. How could I help"}], utter_goodbye: [{text: "Goodbye"}], utter_iamabot: [{text: "I am a bot powered by Rasa. How can I help"}]}, session_config: {version: 3, session_expiration_time: 60, carry_over_slots_to_new_session: true}, nlu: [{intent: greet, examples: "- hi\n- hello\n- how are you\n- good morning\n- good evening\n"}, {intent: goodbye, examples: "- bye\n- goodbye\n- ciao\n- cu\n- cya\n"}, {intent: bot_challenge, examples: "- are you a bot\n- are you a human\n- am I talking to a bot\n- am I talking to a human\n- I want pizza\n- what time is it\n"}], rules: [{rule: say hi, steps: [{intent: greet}, {action: utter_greet}]}], stories: [{story: challenge the bot, steps: [{intent: bot_challenge}, {action: utter_iamabot}]}]}'

The error I am getting back in my terminal:

{"version":"3.0.4","status":"failure","message":"Ran training, but it finished without a trained model.","reason":"TrainingError","details":{},"help":null,"code":500}

The error in the out.log

2022-02-01 15:59:17,737 [ERROR]  Ran training, but it finished without a trained model.

And lastly, the error from the server shell:

UserWarning: Training data file /tmp/tmpbm133fl1/data.yml must specify 'version' as string, for example:
version: '3.0'
Rasa Open Source will read the file as a version '3.0' file.
  More info at https://rasa.com/docs/rasa/training-data-format
No training data given. Please provide stories and NLU data in order to train a Rasa model using the '--data' argument.
2022-02-01 16:15:47 ERROR    rasa.server  - Ran training, but it finished without a trained model.

Can someone please point out what my mistake is? Or show me your own working example of the /model/train endpoint ?

@anne576 Thank you for your query - we only support yaml for the model/train endpoint, I’ve modified your curl command to the below which works:

curl -X POST http://localhost:5005/model/train?save_to_default_model_directory=false&force_training=true -H 'Content-Type: application/yaml' -d 'version: "3.0"
pipeline: []

policies: []

intents:
  - greet
  - goodbye

entities: []
slots: {}
actions: []
forms: {}
e2e_actions: []

responses:
  utter_greet:
  - text: "Hey! How are you?"

  utter_goodbye:
  - text: "Bye"

session_config:
  session_expiration_time: 60
  carry_over_slots_to_new_session: true

nlu:
- intent: greet
  examples: |
    - hey
    - hello

- intent: goodbye
  examples: |
    - bye
    - goodbye

rules:

- rule: Say goodbye anytime the user says goodbye
  steps:
  - intent: goodbye
  - action: utter_goodbye

stories:

- story: happy path
  steps:
  - intent: greet
  - action: utter_greet
  - intent: goodbye
  - action: utter_goodbye
' -o output.tar.gz
1 Like

Thank you for your answer.

I tried it out, but I keep getting an error still on the server shell:

The output.log:

2022-02-02 14:01:22,185 [ERROR]  You must provide training data in the request body in order to train your model.

And the shell with the curl command returns this

[1] 4903
{"version":"3.0.4","status":"failure","message":"You must provide training data in the request body in order to train your model.","reason":"BadRequest","details":{},"help":null,"code":400}Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 27, in <module>
    from CommandNotFound.util import crash_guard
ModuleNotFoundError: No module named 'CommandNotFound'

Do you happen to know why this is? I directly pasted your curl command in the shell.

@anne576 Not sure why you’re getting a 400 response without knowing more about your environment and also python version. I would suggest creating a fresh new virtual environment where you’ve re-installed rasa. Then attempt running rasa run --enable-api only and the curl command.

I just created a new pyenv for testing the APIs, that uses:

Python 3.7.12
pip 21.3.1
Rasa Version : 3.0.4

Which version are you using/ should I be using? I have been stuck on this for quite some time now and can’t seem to make it work.

@anne576 I’m using Python 3.8.6 and rasa 3.0.6 on my machine, however I’m not sure if the problem lies necessarily in these areas, and since I cannot reproduce your issue and neither can another colleague that I’ve checked this with, you might be safer training models using rasa train command.

I would like to get to the bottom of this and use the endpoint instead, due to the current project I am working on.

I installed the environment with your Python and Rasa version and I still get the same error. I noticed when I call the api through Postman (with the exact call you pasted on here), the call goes through. I do not get the error from above anymore.

Unfortunately, it trains the model suspiciously quick. I checked the model size, and it creates an empty model that doesn’t work. Do you happen to know why this may be the case? Can anyone shed some light on this matter?

Here is a screenshot of the model size below:

@nik202 do you happen to know what I could try to solve this issue? I saw you help some people on other posts. Thought I’d try my luck :slight_smile:

@anne576 Hello Anne, sure I’ll try my best to provide you with all suggestions and solutions, and yes I help many people, thanks for noticing my effort :slight_smile:

Few questions:

  1. Latest rasa --version activating the env?
  2. Current status of error as I can see it really very long and old post or it sticks on the first post error message?
  3. Please share the error screenshot with the tracebacks?
  1. Okay so the versions I am using in my Pyenv are:
Python Version : 3.8.6
Rasa Version : 3.0.6

2&3. To explain the thread conversations from above, I am trying to get the \model\train endpoint to successfully train a new model. When I try the method suggested by @anca, I get the following error in output.log (which can be fully seen just above):

You must provide training data in the request body in order to train your model.

And the shell with the curl command returns this:

[1] 4903
{"version":"3.0.4","status":"failure","message":"You must provide training data in the request body in order to train your model.","reason":"BadRequest","details":{},"help":null,"code":400}Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 27, in <module>
    from CommandNotFound.util import crash_guard
ModuleNotFoundError: No module named 'CommandNotFound'

I proceeded to test this query in postman instead, and it worked a bit better than running the curl command in terminal. Here is my request. In the Body, I pasted word for word the query that @anca provided.

Unfortunately, this train an empty non working model. I can’t quite figure out why that is. Hope this provides some clarity?

Thank you very much for taking the time to help me out with this.

@anne576 ok, in summary you are trying to train the rasa open source model using API or Postman is that right?

Have you seen this blog? : Explore Rasa APIs with Postman | The Rasa Blog | Rasa

@anne576 confirm with me, are you able to train the model on local machine using the command rasa train ?

Yes, that summary is correct.

No I have not, I will give this a try and see if it changes things for me. Does this release work for Rasa 3.0 though? I noticed the api call has the Rasa 2.X format. In addition:

And yes, I can successfully train a model using the command rasa train.

@anne576 Ok (empty collection) :thinking:, try to see the setting of rasa 2.x from the above POST Train a Rasa Model and make a request?

@anne576 just checking have you seen this also: Rasa Open Source Documentation ?

@anne576 can you first run the rasa data validate command and check there is any issue in the data?

@anne576 I’d highly recommend reading all the conversations on this open issue, a lot has been discussed related to your issue only.

I am digging your issue only, that is why late suggestions. Thanks.

Ok, so I tried this out and it takes me to the exact same place. It trains a model, but an empty one. Here is what I did:

The authorisation:

And the body I used was the same one suggested by @anca.

Yep, it is the first thing I have tried. It actually gave me an error because the documentation does not include the version parameter.

I hope this is correct?

When I google this issue, this post I created is what appears first on google. I cannot quite seem to find all that much on Rasa 3.0 /train endpoint issues.

No rush. I appreciate you taking the time to help me out and advise me. Thank you for your kind efforts here and in the Rasa Forum Community.

@anne576 Ok, Can you create a new environment for Rasa 2.x and performed everything?? Will, it will take some time for you? If there is not much code change as based on Rasa 3.x, whist using this we can test the issue is with Rasa 3 or even with Rasa 2?

@anne576 No worries, as I am not yet worked much on the Rasa 3.x that is why it’s really hard for me to comment about your issue, but I am searching for you and providing you with the available suggestions and solutions on the forum and Github open or closed threads.

I can make this API work perfectly in Rasa 2.x. The change to 3.0 is quite significant and it still doesn’t work for me. What I might do, if you do not mind, is tag a few people and see if anyone can lend a hand. I want to get to the bottom of this.

@anne576 So strange its working on 2.x but not on 3.x. I seriously don’t know whom I tag, Vincent left the Rasa, and other I am not sure. You tag whom you know, may be they will see and comment. I tried my best to help you.