Closed antoinecomp closed 6 years ago
Hey. Thanks for checking out the tutorial! :) There have been quite a few updates on both Rasa NLU and Rasa Core since I have recorded the video so it's not surprising that the model needs some updates. Try to retrain the NLU model - in nlu_model.py uncomment the line
train_nlu('./data/data.json', 'config_spacy.json', './models/nlu')
and run the script. It will retrain the NLU model which should be compatible with the new instance.
Thank you for that really fast answer ! So I uncommented the line you told me to uncomment, which resulted in :
from rasa_nlu.converters import load_data
from rasa_nlu.config import RasaNLUConfig
from rasa_nlu.model import Trainer
from rasa_nlu.model import Metadata, Interpreter
def train_nlu(data, config, model_dir):
training_data = load_data(data)
trainer = Trainer(RasaNLUConfig(config))
trainer.train(training_data)
model_directory = trainer.persist(model_dir, fixed_model_name = 'weathernlu')
def run_nlu():
interpreter = Interpreter.load('./models/nlu/default/weathernlu', RasaNLUConfig('config_spacy.json'))
print(interpreter.parse("I am planning my holiday to Lithuania. I wonder what is the weather out there."))
if __name__ == '__main__':
train_nlu('./data/data.json', 'config_spacy.json', './models/nlu')
run_nlu()
And reran the script python dialogue_management_model.py
again but still that same issue.
Hmmm. That's odd. When you rerun nlu_model.py after uncommenting that line, did you get any errors? Can you see that NLU model was updated in ./models/nlu/default/weathernlu ? Also, can you tell me which Rasa NLU and Rasa Core versions are you using?
There is indeed an error there !
(envMoodbot2) mike@mike-thinks:~/Programing/Rasa_tutorial/Weatherbot_Tutorial/Full Code$ python nlu_model.py
Traceback (most recent call last):
File "nlu_model.py", line 1, in <module>
from rasa_nlu.converters import load_data
ImportError: No module named 'rasa_nlu.converters'
But I don't know why I can't install it :
(envMoodbot2) mike@mike-thinks:~/Programing/Rasa_tutorial/Weatherbot_Tutorial/Full Code$ python -m pip install rasa_nlu.converters
Collecting rasa_nlu.converters
Could not find a version that satisfies the requirement rasa_nlu.converters (from versions: )
No matching distribution found for rasa_nlu.converters
About the version I'm using :
(envMoodbot2) mike@mike-thinks:~/Programing/Rasa_tutorial/Weatherbot_Tutorial/Full Code$ pip list :
...
rasa-core 0.9.0a3
rasa-nlu 0.12.3
...
I assume you are using the latest Rasa NLU version... if that's the case then you will either have to use the older version of Rasa NLU (I think I used 0.11.0 for the video), or you can change few bits in nlu_model.py file (as I have mentioned, Rasa NLU had quite a few updates since I recorded the video so some things have changed):
from rasa_nlu.training_data import load_data
from rasa_nlu import config
from rasa_nlu.model import Trainer
from rasa_nlu.model import Metadata, Interpreter
def train_nlu(data, configs, model_dir):
training_data = load_data(data)
trainer = Trainer(config.load(configs))
trainer.train(training_data)
model_directory = trainer.persist(model_dir, fixed_model_name = 'weathernlu')
def run_nlu():
interpreter = Interpreter.load('./models/nlu/default/weathernlu')
print(interpreter.parse("I am planning my holiday to Lithuania. I wonder what is the weather out there."))
if __name__ == '__main__':
train_nlu('./data/data.json', 'config_spacy.json', './models/nlu')
run_nlu()
As you can see I only changed the config file in train_nlu function is loaded as well as how the interpreter is loaded. Try running this code instead and let me know if that helps :)
Yep, it is definitely because I used an older version of Rasa NLU. Try using the script above for retraining the NLU model.
This (almost) works !! :clinking_glasses: Amazing ! :
(envMoodbot2) mike@mike-thinks:~/Programing/Rasa_tutorial/Weatherbot_Tutorial/Full Code$ python dialogue_management_model.py
...
och 299/300
17/17 [==============================] - 0s 267us/step - loss: 0.2495 - acc: 1.0000 - val_loss: 1.0766 - val_acc: 0.6000
Epoch 300/300
17/17 [==============================] - 0s 271us/step - loss: 0.2920 - acc: 0.9412 - val_loss: 1.0710 - val_acc: 0.6000
/home/mike/Programing/Rasa_tutorial/moodbot2/envMoodbot2/lib/python3.5/site-packages/rasa_nlu/extractors/entity_synonyms.py:85: UserWarning: Failed to load synonyms file from './models/nlu/default/weathernlu/entity_synonyms.json'
"".format(entity_synonyms_file))
Bot loaded. Type a message and press enter:
Hey !
/home/mike/Programing/Rasa_tutorial/moodbot2/envMoodbot2/lib/python3.5/site-packages/sklearn/preprocessing/label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.
if diff:
Hello! How can I help?
What's the weather in Lithuania ?
/home/mike/Programing/Rasa_tutorial/moodbot2/envMoodbot2/lib/python3.5/site-packages/sklearn/preprocessing/label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.
if diff:
Hello ?
/home/mike/Programing/Rasa_tutorial/moodbot2/envMoodbot2/lib/python3.5/site-packages/sklearn/preprocessing/label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.
if diff:
There is just this warning message which will turn to an error one day. I do not know what you think about it. Another issue I'm facing is that I'm not able to ask for the weather in your country.
But that is another story, I think I can close the issue ?
Hi Justina, What version of Rasa NLU and Rasa Core did you use?
Hey @uchandr. If you are using the code from this repo then it is using the following:
Latest compatible Rasa NLU version: 0.12.3 Latest compatible Rasa Core version: 0.9.8
I will make an update so that it would work with the latest releases.
Hi @JustinaPetr Plese help me to fix this problem. I have used this code:
from rasa_nlu.training_data import load_data from rasa_nlu import config from rasa_nlu.model import Trainer from rasa_nlu.model import Metadata, Interpreter
def train_nlu(data, configs, model_dir): training_data = load_data(data) trainer = Trainer(config.load(configs)) trainer.train(training_data) model_directory = trainer.persist(model_dir, fixed_model_name = 'weathernlu')
def run_nlu(): interpreter = Interpreter.load('./models/nlu/default/weathernlu') print(interpreter.parse("I am planning my holiday to Lithuania. I wonder what is the weather out there."))
if name == 'main':
train_nlu('./data/data.json', 'config_spacy.json', './models/nlu')
run_nlu()
I have the same error. i.e
File "nlu_model.py", line 1, in
I am using rasa_core version=0.11.5, rasa_nlu version=0.11.5
I am having the exact same problem. I downloaded the latest code version. And have the following:
from rasa_nlu.training_data import load_data
from rasa_nlu import config
from rasa_nlu.model import Trainer
from rasa_nlu.model import Metadata, Interpreter
def train_nlu(data, configs, model_dir):
training_data = load_data(data)
trainer = Trainer(config.load(configs))
trainer.train(training_data)
model_directory = trainer.persist(model_dir, fixed_model_name = 'weathernlu')
def run_nlu():
interpreter = Interpreter.load('./models/nlu/default/weathernlu')
print(interpreter.parse("I am planning my holiday to Lithuania. I wonder what is the weather out there."))
if __name__ == '__main__':
train_nlu('./data/data.json', 'config_spacy.json', './models/nlu')
run_nlu()
And I get the same error:
File "nlu_model.py", line 1, in <module>
from rasa_nlu.training_data import load_data
ImportError: No module named rasa_nlu.training_data
Is this issue fixed?
Hi ! I just watch your video and wanted to test your model. Unfortunately when I tried to launch dialogue_management_model I had an issue I am also facing : model version your using is to old to be loaded by this Rasa NLU instance.
Do you know how to cope with it ?