1

Teniendo dificultades con el tutorial oficial de Rasa Core, un framework para la construcción de software conversacional, soy atentamente el tutorial de Justina Petraityte. Puedes encontrar todos sus archivos que recodí siguiendo el tutorial sobre Github. Sin embargo, Al intentar iniciar el archivo train_online.py, el chatbot de conversación real capaz de enviar mensajes, hubo problemas

Rasa Core version:

(MoodbotEnv) mike@mike-thinks:~/Programing/Rasa_tutorial/moodbot4$ pip list :
...
rasa-core (0.9.0a3)
rasa-nlu (0.12.3)

Python version:

(MoodbotEnv) mike@mike-thinks:~/Programing/Rasa_tutorial/moodbot4$ python -V 
Python 3.5.2

Operating system :

Linux 16.04

Issue:

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import logging

from rasa_core.agent import Agent
from rasa_core.channels.console import ConsoleInputChannel
from rasa_core.interpreter import RegexInterpreter
from rasa_core.policies.keras_policy import KerasPolicy
from rasa_core.policies.memoization import MemoizationPolicy
from rasa_core.interpreter import RasaNLUInterpreter

logger = logging.getLogger(__name__)


def run_weather_online(input_channel, interpreter,
                          domain_file="weather_domain.yml",
                          training_data_file='data/stories.md'):
    agent = Agent(domain_file,
                  policies=[MemoizationPolicy(), KerasPolicy()],
                  interpreter=interpreter)

    agent.train_online(training_data_file,
                       input_channel=input_channel,
                       max_history=2,
                       batch_size=50,
                       epochs=200,
                       max_training_samples=300)

    return agent


if __name__ == '__main__':
    logging.basicConfig(level="INFO")
    nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/weathernlu')
    run_weather_online(ConsoleInputChannel(), nlu_interpreter)

Sin embargo, apareció el siguiente error:

(MoodbotEnv) mike@mike-thinks:~/Programing/Rasa_tutorial/moodbot4$ python train_online.py 
INFO:rasa_nlu.components:Added 'nlp_spacy' to component cache. Key 'nlp_spacy-en'.
Traceback (most recent call last):
  File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 508, in _unpickle
    obj = unpickler.load()
  File "/usr/lib/python3.5/pickle.py", line 1039, in load
    dispatch[key[0]](self)
  File "/usr/lib/python3.5/pickle.py", line 1177, in load_binstring
    self.append(self._decode_string(data))
  File "/usr/lib/python3.5/pickle.py", line 1159, in _decode_string
    return value.decode(self.encoding, self.errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x89 in position 36: ordinal not in range(128)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "train_online.py", line 37, in <module>
    nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/weathernlu')
  File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/rasa_core/interpreter.py", line 221, in __init__
    self._load_interpreter()
  File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/rasa_core/interpreter.py", line 237, in _load_interpreter
    self.interpreter = Interpreter.load(self.model_directory)
  File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/rasa_nlu/model.py", line 276, in load
    skip_validation)
  File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/rasa_nlu/model.py", line 303, in create
    model_metadata, **context)
  File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/rasa_nlu/components.py", line 398, in load_component
    cached_component, **context)
  File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/rasa_nlu/registry.py", line 131, in load_component_by_name
    return component_clz.load(model_dir, metadata, cached_component, **kwargs)
  File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/rasa_nlu/extractors/crf_entity_extractor.py", line 313, in load
    ent_tagger = joblib.load(model_file)
  File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 578, in load
    obj = _unpickle(fobj, filename, mmap_mode)
  File "/home/mike/Programing/Rasa_tutorial/moodbot4/MoodbotEnv/lib/python3.5/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 523, in _unpickle
    raise new_exc
ValueError: You may be trying to read with python 3 a joblib pickle generated with python 2. This feature is not supported by joblib.

Sé que significa que la compatibilidad entre versiones de Python no es totalmente compatible, pero no entiendo por qué y qué puedo hacer para enfrentarlo.

Solo para informarme intenté lanzar el código usando Python 2 explícitamente: y me dio:

(MoodbotEnv) mike@mike-thinks:~/Programing/Rasa_tutorial/moodbot4$ python2 train_online.py 
Traceback (most recent call last):
  File "train_online.py", line 37, in <module>
    nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/weathernlu')
  File "/home/mike/.local/lib/python2.7/site-packages/rasa_core/interpreter.py", line 219, in __init__
    self._load_interpreter()
  File "/home/mike/.local/lib/python2.7/site-packages/rasa_core/interpreter.py", line 234, in _load_interpreter
    from rasa_nlu.config import RasaNLUConfig
ImportError: cannot import name RasaNLUConfig

Que es un problema que ya trataron aquí, pero que es inesperado en cuanto a que mi versión rasa-core es una de las últimas.

Pienso que el problema es que desde que la autor ha desarollado su codigo, RasaNLUInterpreter ya no existe y ha sido reemplazado por esto

Le pregunté directamente la pregunta aquí

domain archivo :

action_factory: null
action_names:
- utter_greet
- utter_goodbye
- utter_ask_location
- action_weather
actions:
- utter_greet
- utter_goodbye
- utter_ask_location
- actions.ActionWeather
config:
  store_entities_as_slots: true
entities:
- location
intents:
- greet
- goodbye
- inform
slots:
  location:
    initial_value: null
    type: rasa_core.slots.TextSlot
templates:
  utter_ask_location:
  - text: In what location?
  utter_goodbye:
  - text: Talk to you later.
  - text: Bye bye :(
  utter_greet:
  - text: Hello! How can I help?
topics: []

1 respuesta 1

1

Diseñé una solución: en la medida en que el problema era que RasaNLUInterpreter no podía leer los archivos .pkl, solo creé la carpeta /models/nlu/default/ weathernlu/test y copié todos los archivos .json y modifiqué el principal en train_online. archivo py con:

nlu_interpreter = RasaNLUInterpreter ('./ models / nlu / default / weathernlu / test')

Y funcionó como un encanto.

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.