简体   繁体   中英

Cannot train new model using Rasa NLU/Sklearn

I am building a middleware between my application and Rasa NLU server that can simplify different tasks like creating a model or updating ...

I mainly aim to build a model and update it each time using a function that adds one example to the old model so it just take the old data update it by adding only one example and submit it again to Rasa server.

Here's the scenario :
First I start by creating an empty model so I send a post request to localhost:5000/train?project=defaults&fixed_model_name=model1
with this data

{
  "rasa_nlu_data": {
    "common_examples": [], 
    "entity_synonyms": [], 
    "regex_features": []
  }
}

so I get this response :

"info": "new model trained: model1"

then I start the training with the same request but with new data that contain a new class greet

{
  "rasa_nlu_data": {
    "common_examples": [
      {
        "text": "hey", 
        "intent": "greet"
      }
    ], 
    "entity_synonyms": [], 
    "regex_features": []
  }
}

which works like I expected and if I add an example from the same class the training always works fine

{
  "rasa_nlu_data": {
    "common_examples": [
      {
        "text": "hey", 
        "intent": "greet"
      },{
        "text": "heyy", 
        "intent": "greet"
      }
    ], 
    "entity_synonyms": [], 
    "regex_features": []
  }
}

but when I try to post an other data with new different intend bye like this

{
  "rasa_nlu_data": {
    "common_examples": [
      {
        "text": "hey", 
        "intent": "greet"
      },
       {
        "text": "heyy", 
        "intent": "greet"
      },
      {
        "text": "goodbye", 
        "intent": "bye"
      }
    ], 
    "entity_synonyms": [], 
    "regex_features": []
  }
}

I get this error :

"error": "The number of classes has to be greater than one; got 1"

and also if I redo the same scenario by skipping the second step so my data will look like that:

{
  "rasa_nlu_data": {
    "common_examples": [
      {
        "text": "hey", 
        "intent": "greet"
      },
      {
        "text": "goodbye", 
        "intent": "bye"
      }
    ], 
    "entity_synonyms": [], 
    "regex_features": []
  }
}

and after submitting it I get this error:

"error": "n_splits=2 cannot be greater than the number of members in each class."

My Rasa NLU server configuration :

I have already checked those questions that maybe similar to my question but those aren't what I am looking for
ValueError: The number of classes has to be greater than one (python)
ValueError: Cannot have number of splits n_splits=3 greater than the number of samples: 1

I know that Rasa model require a number of entities to run the parse but I am far away from that I just want to build a clean model first

Rasa NLU imposes that you have at least two examples of each intent. Though for any kind of good performance you should have much more than that anyway :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM