Rasa: why I only able to parse intent greet and bye?

Created on 10 Jul 2018  ยท  6Comments  ยท  Source: RasaHQ/rasa

Rasa NLU version:
0.12
Operating system (windows, osx, ...):
centOS 7
Content of model configuration file:
config.yml

language: "en"

pipeline:
 - name: "tokenizer_whitespace"
 - name: "intent_featurizer_count_vectors"
 - name: "intent_classifier_tensorflow_embedding"
   intent_tokenization_flag: true
   intent_split_symbol: "+"

domain.yml

intents:
   - greet
   - goodbye
   - claimreport

templates:
   utter_greet:
     - text: "Hey, I m Bot"
   utter_goodbye:
     - text: "Thank you, bye :)"
   utter_claimreport:
     - text: "For claim reporting, I would ask you some questions blah blah blah"

actions:
   - utter_greet
   - utter_goodbye
   - utter_claimreport

data/nlu_data.md

## intent:greet
   - hi
   - hey
   - hallo
   - halo
   - hello
## intent:goodbye
   - bye
   - goodbye
   - good bye
## intent:claimreport
   - accident
   - lost
   - theft

data/stories.md

## story 1
  * greet
     - utter_greet
  * claim_report
      - utter_claim_report
  * goodbye
     - utter_goodbye

Issue:

why I only able to parse intent greet and bye?

when parsing greet and bye intent, it returns correctly (name of the intent shown), but if I parse claimreport intnet the name of intent shown null..

== trying to parse greet and bye intent ==

[root@ai learn04]# curl -XPOST localhost:5000/parse -d '{"q":"hey"}'
{
  "project": "default",
  "entities": [],
  "model": "fallback",
  "intent": {
    "confidence": 1.0,
    "name": "greet"
  },
  "text": "hey"
}[root@ai learn04]# curl -XPOST localhost:5000/parse -d '{"q":"bye"}'
{
  "project": "default",
  "entities": [],
  "model": "fallback",
  "intent": {
    "confidence": 1.0,
    "name": "goodbye"
  },
  "text": "bye"

== trying to parse claimreport intent ==
}[root@ai learn04]# curl -XPOST localhost:5000/parse -d '{"q":"accident"}'
{
  "project": "default",
  "entities": [],
  "model": "fallback",
  "intent": {
    "confidence": 1.0,
    "name": null
  },
  "text": "accident"
}[root@ai learn04]# curl -XPOST localhost:5000/parse -d '{"q":"lost"}'
{
  "project": "default",
  "entities": [],
  "model": "fallback",
  "intent": {
    "confidence": 1.0,
    "name": null
  },
  "text": "lost"
}[root@ai learn04]# curl -XPOST localhost:5000/parse -d '{"q":"theft"}'
{
  "project": "default",
  "entities": [],
  "model": "fallback",
  "intent": {
    "confidence": 1.0,
    "name": null
  },
  "text": "theft"
[root@ai learn04]#
type

Most helpful comment

I had exactly the same problem and it took me a lot of time to figure out what I'm doing wrong. Essentially I set wrong value to --path parameter when starting rasa_nlu.server.

Example
Let's say we have the following structure of project:

โ”œโ”€โ”€ data
โ”‚ย ย  โ””โ”€โ”€ nlu.json
โ”œโ”€โ”€ projects
โ”‚ย ย  โ””โ”€โ”€ default
โ”‚ย ย      โ””โ”€โ”€ nlu
โ”‚ย ย          โ”œโ”€โ”€ crf_model.pkl
โ”‚ย ย          โ”œโ”€โ”€ intent_classifier_sklearn.pkl
โ”‚ย ย          โ”œโ”€โ”€ metadata.json
โ”‚ย ย          โ””โ”€โ”€ training_data.json
โ”œโ”€โ”€ domain.yml
โ””โ”€โ”€ nlu_config.yml

then we train NLU model with the following code:

from rasa_nlu import config
from rasa_nlu.model import Trainer
from rasa_nlu.training_data import load_data
from rasa_core import utils

NLU_DATA_PATH = "data/nlu.json"
NLU_CONFIG = "nlu_config.yml"
NLU_MODEL_NAME = "nlu"
PROJECTS_PATH = "projects/"
PROJECT_NAME = "default"

training_data = load_data(resource_name=NLU_DATA_PATH)
trainer = Trainer(config.load(NLU_CONFIG))
trainer.train(training_data)
trainer.persist(
    path=PROJECTS_PATH,
    project_name=PROJECT_NAME,
    fixed_model_name=NLU_MODEL_NAME
)

and start rasa_nlu server:

python -m rasa_nlu.server --path projects/

If I set wrong --path parameter e.g.:

python -m rasa_nlu.server --path projects/default

I'll be able to recognize intents only for greet and goodbye and the confidence will be always 1. If wrong value of --path parameter is your case then your rasa_nlu server should log the following message to your console:

WARNING rasa_nlu.project - Invalid model requested. Using default

I guess that this "default" model is responsible for recognizing greet and goodbye intents. Unfortunately I don't remember documentation mentioning such behavior so I can't explain it.

  • From my point of view it would be better to quit with error if the --path is wrong.
  • Besides that description of --path parameter may be misleading as it states:

    _"working directory of the server. Models are loaded from this directory and trained models will be
    saved here."_

    and users my try to set it to projects/default/nlu/ or projects/default/.

All 6 comments

Have you cross-checked the intent title? In data/nlu_data.md it appears to be claimreport and in the story it is claim_report.

@auzair92 thanks and yes. I updated and retrained it but the same problem still occurs :(

Could you post all the files of your project here by any chance? The fact you're getting a confidence of 1.0 for NLU is odd.

@akelad

learn04.zip

I had exactly the same problem and it took me a lot of time to figure out what I'm doing wrong. Essentially I set wrong value to --path parameter when starting rasa_nlu.server.

Example
Let's say we have the following structure of project:

โ”œโ”€โ”€ data
โ”‚ย ย  โ””โ”€โ”€ nlu.json
โ”œโ”€โ”€ projects
โ”‚ย ย  โ””โ”€โ”€ default
โ”‚ย ย      โ””โ”€โ”€ nlu
โ”‚ย ย          โ”œโ”€โ”€ crf_model.pkl
โ”‚ย ย          โ”œโ”€โ”€ intent_classifier_sklearn.pkl
โ”‚ย ย          โ”œโ”€โ”€ metadata.json
โ”‚ย ย          โ””โ”€โ”€ training_data.json
โ”œโ”€โ”€ domain.yml
โ””โ”€โ”€ nlu_config.yml

then we train NLU model with the following code:

from rasa_nlu import config
from rasa_nlu.model import Trainer
from rasa_nlu.training_data import load_data
from rasa_core import utils

NLU_DATA_PATH = "data/nlu.json"
NLU_CONFIG = "nlu_config.yml"
NLU_MODEL_NAME = "nlu"
PROJECTS_PATH = "projects/"
PROJECT_NAME = "default"

training_data = load_data(resource_name=NLU_DATA_PATH)
trainer = Trainer(config.load(NLU_CONFIG))
trainer.train(training_data)
trainer.persist(
    path=PROJECTS_PATH,
    project_name=PROJECT_NAME,
    fixed_model_name=NLU_MODEL_NAME
)

and start rasa_nlu server:

python -m rasa_nlu.server --path projects/

If I set wrong --path parameter e.g.:

python -m rasa_nlu.server --path projects/default

I'll be able to recognize intents only for greet and goodbye and the confidence will be always 1. If wrong value of --path parameter is your case then your rasa_nlu server should log the following message to your console:

WARNING rasa_nlu.project - Invalid model requested. Using default

I guess that this "default" model is responsible for recognizing greet and goodbye intents. Unfortunately I don't remember documentation mentioning such behavior so I can't explain it.

  • From my point of view it would be better to quit with error if the --path is wrong.
  • Besides that description of --path parameter may be misleading as it states:

    _"working directory of the server. Models are loaded from this directory and trained models will be
    saved here."_

    and users my try to set it to projects/default/nlu/ or projects/default/.

@Primtek does this solve your problem?

Was this page helpful?
0 / 5 - 0 ratings