Alexmhack/Django-Rasa-Bot

Not able to customize model.

Kaamlang opened this issue · 9 comments

Traceback (most recent call last):
File "bot.py", line 6, in
agent = Agent.load('models/dialogue', interpreter='models/current/nlu')
File "/home/sushil/Desktop/chatbot/venv/lib/python3.6/site-packages/rasa_core/agent.py", line 265, in load
domain.compare_with_specification(path)
File "/home/sushil/Desktop/chatbot/venv/lib/python3.6/site-packages/rasa_core/domain.py", line 541, in compare_with_specification
"\t - added: {} ".format(missing, additional))
rasa_core.domain.InvalidDomain: Domain specification has changed. You MUST retrain the policy. Detected mismatch in domain specification. The following states have been
- removed:
- added:

I am not able to make any changes in your model. I tried adding a intent and make necessary changes accordingly but I am getting above error. Those policies included inside models are making it difficult for me to understand the workings. Is it really necessary to have custom policies ?? I tried running the code without those policy files but didn't workout. It would be great help if you could help me.

After making the changes in the domain.yml file, have you retrained the model by running the respective codes for rasa core and nlu.

Or if you have made changes in any other file, which file is that ?

Do I need to make changes in every file or is it ok just to make changes in domain.yml file. I tried adding 1 data all over the file. Added a intent: addmission in domain.yml, nlu.md, domain.json and into stories.md as well. Just using hit and trial but nothing seems to work. I just wanted to add a new data for more converstation. Can you tell me in which files do I have to make changes and how ? It shows the same error above if I add just a intent. I didn't get retraining the model; every time I make changes I restart and run bot.py.

Well you need to add data in only nlu.md stories.md and domain.yml files.

And after adding data in any of the files that you have mentioned you need to retrain the models using commands given on this page, since I have made my demo bot from that only.

You need to retrain the models every time you make changes, otherwise changes won't take effect in bot and errors might show up.

For training nlu model that is when you make changes in the nlu.md file and domain.yml, run

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

Here nlu_config.yml file can also be config.yml and --data nlu.md is the path of the nlu.md file, if it is in data folder then use --data data/nlu.md and the rest is for the model and project name

For training core model that is when you make changes in the stories.md and domain.yml files, run

python -m rasa_core.train -d domain.yml -s stories.md -o models/dialogue

Thank you for your help, I really appreciate your effort.

Did you solve your errors ?

Yes I solved it. Thank you for your help. But I encountered another problem using slot. I tried making more than 20 examples for an intent but it is not working. I have intent: name and trying to get the name using slot as but it won't response right answers. It just reply's the name only written in the examples and does not recognize new names. It sometime respond with value None. Can you please help me out.

entities:

  • name
    slots:
    name:
    type: text

intent: name

I also tried refrencing starter pack of rasa but didn't work out.

class ActionName(Action):
def name(self):
# define the name of the action which can then be included in training stories
return "action_name"

def run(self, dispatcher, tracker, domain):
    name = tracker.get_slot('name')

    response = """Nice to meet you {}. Do you have account?""".format(name)

    dispatcher.utter_message(response)
    return []

Yes, I faced the same problem. This is due to lack of data, you need to train the model on much bigger data than 20, I used 400 to 500 fake email samples for data which i copied from fake email generator websites, then after training I started getting some results, not best results.

You can use wit.ai for recognizing intents like these, WIT has so many intents and has a very good accuracy, you just need the python API for WIT and the API Key which is available once you signup.

Then in rasa custom actions you need to get the user response and put that response in the WIT API and get back a JSON response, with that response you can check the match accuracy (something like this) and on the basis of that proceed with the bot response.

If nothing is detected you can utter a response like "Enter valid name" or similar to this.

It works perfectly fine making custom action, if we use spacy pipeline rather than using embedding_tensorflow.
I have made a new story as show below.

course_query path

  • greet
    • utter_greet
  • course
    • utter_course
  • goodbye
    • utter_goodbye

after running it; I am getting result as mentioned below. As shown in stories the should be providing course details but it is showing bye. I am not able to figure out what is wrong with it either the stories I made is wrong or bot is functioning abnormally??
me: hi
bot: hey
me: course offered
bot: BIT
me: course offered
bot: bye

have your retrained the bot models ?