Fails of training dialogue model

hello well this is my code from future import absolute_import from future import division from future import unicode_literals from future import unicode_literals

from rasa_core import utils

from rasa_core.agent import Agent from rasa_core.policies.keras_policy import KerasPolicy from rasa_core.policies.memoization import MemoizationPolicy from rasa_core.policies.sklearn_policy import SklearnPolicy

if name == ‘main’: utils.configure_colored_logging(loglevel=“DEBUG”)

training_data_file = './data/stories.md'
model_path = './models/dialogue'

agent = Agent('horoscope_domain.yml', policies = [MemoizationPolicy(), KerasPolicy()])
training_data = agent.load_data(training_data_file)

agent.train(
		training_data,
		augmentation_factor = 50,
		
		epochs = 500,
		batch_size = 10,
		validation_split = 0.2
)
		
agent.persist(model_path)

the problem that receive is Traceback (most recent call last): File “train_initialize.py”, line 20, in agent = Agent(‘horoscope_domain.yml’, policies = [MemoizationPolicy(), KerasPolicy()]) File “/Users/x/.local/lib/python3.6/site-packages/rasa_core/agent.py”, line 198, in init self.domain = self._create_domain(domain) File "/Users/x/reate_domain return Domain.load(domain) File “/Users/x/.local/lib/python3.6/site-packages/rasa_core/domain.py”, line 89, in load return cls.from_yaml(read_file(filename)) File “/Users/x/.local/lib/python3.6/site-packages/rasa_core/domain.py”, line 93, in from_yaml cls.validate_domain_yaml(yaml) File “/Users/x/.local/lib/python3.6/site-packages/rasa_core/domain.py”, line 123, in validate_domain_yaml source_data = utils.read_yaml_string(yaml) File “/Users/x/.local/lib/python3.6/site-packages/rasa_core/utils.py”, line 343, in read_yaml_string return yaml_parser.load(string) File “/Users/x/.local/lib/python3.6/site-packages/ruamel/yaml/main.py”, line 331, in load return constructor.get_single_data() File “/Users/x/.local/lib/python3.6/site-packages/ruamel/yaml/constructor.py”, line 109, in get_single_data node = self.composer.get_single_node() File “_ruamel_yaml.pyx”, line 706, in _ruamel_yaml.CParser.get_single_node File “_ruamel_yaml.pyx”, line 724, in _ruamel_yaml.CParser._compose_document File “_ruamel_yaml.pyx”, line 775, in _ruamel_yaml.CParser._compose_node File “_ruamel_yaml.pyx”, line 891, in _ruamel_yaml.CParser._compose_mapping_node File “_ruamel_yaml.pyx”, line 904, in _ruamel_yaml.CParser._parse_next_event ruamel.yaml.scanner.ScannerError: mapping values are not allowed in this context in “”, line 8, column 14 what should I do exactly thx for advanced

Hi, can you try validating your domain file with yamllint.com?

1 Like

(): mapping values are not allowed in this context at line 14 column 26 if name == ‘main’: my version is rasa_core==0.11.1

Sounds like you’re trying to incorporate python logic in a yaml file, which won’t work. Why are you using if name == main? Can you post the domain file?

1 Like
slots:
    horoscope_sign:
        type: text
    DD:
        type: text
    MM:
type: text
    subscribe:
        type: bool
intents:
    - greeting
    - get_horoscope
    - subscription
    - dob_intent
entities:
     - horoscope_sign
     - DD
     - MM
     - subscribe
     - dob_intent
128
templates:
    utter_greet:
        - 'Hello! How are you doing today?'
    utter_ask_horoscope_sign:
        - 'What is your horoscope sign?'
    utter_ask_dob:
        - 'What is your DOB in DD-MM format?'
    utter_subscribe:
        - 'Do you want to subscribe for daily updates?'
actions:
  - utter_greet
  - utter_ask_horoscope_sign
  - utter_ask_dob
  - utter_subscribe
  - get_todays_horoscope
  - subscribe_user

here it is

It looks like the indent/mapping is messed up for your slots. the issue is in like 8 which makes sense. try this:

slots:
    horoscope_sign:
        type: text
    DD:
        type: text
    MM:
        type: text
    subscribe:
        type: bool

also i don’t know what that 128 is, maybe just a copy/paste thing, but it shouldn’t be there either.

1 Like

after I run again I find could not determine a constructor for the tag ‘tag:yaml.org,2002:python/str’ Exception: Failed to load domain specification from ‘/Users/hajarchatoui/Desktop/horoscope/data/data/horoscope_domain.yml’. File not found! why they could not notice the file

I’m assuming you don’t actually have it inside data/data/horoscope_domain.yml but probably rather data/horoscope_domain.yml. Make sure the arguments you pass are relative to the current directory you’re in. Are you running this from inside the data folder?

Or maybe the way is to pull it from ./horoscope_domain.yml instead of horoscope_domain.yml, like how you are doing ./data/stories.md

you are totally right yes I change the path to check if it works now I delete all I kept as it was but the second issue shows up here this all my code from future import absolute_import from future import division from future import print_function from future import unicode_literals from rasa_core import utils

from rasa_core.agent import Agent from rasa_core.policies.keras_policy import KerasPolicy from rasa_core.policies.memoization import MemoizationPolicy from rasa_core.policies.sklearn_policy import SklearnPolicy

if name == ‘main’: utils.configure_colored_logging(loglevel=“DEBUG”)

training_data_file = './data/stories.md'
model_path = './models/dialogue'
agent = Agent("horoscope_domain.yml", policies=[MemoizationPolicy()KerasPolicy()])
training_data = agent.load_data(training_data_file)

agent.train(
    training_data,
    augmentation_factor=50,
    epochs=500,
    batch_size=10,
    validation_split=0.2

) agent.persist(model_path) agent = Agent(“horoscope_domain.yml”, policies=[MemoizationPolicy()KerasPolicy()]) ^ SyntaxError: invalid syntax

i am so happy to tell you I solve the issue by using only that commands Epoch 487/500 74/74 [==============================] - 0s 906us/sample - loss: 0.0066 - acc: 1.0000 - val_loss: 4.5586e-05 - val_acc: 1.0000 Epoch 488/500 74/74 [==============================] - 0s 917us/sample - loss: 0.0186 - acc: 0.9865 - val_loss: 4.4061e-05 - val_acc: 1.0000 Epoch 489/500 74/74 [==============================] - 0s 885us/sample - loss: 0.0080 - acc: 1.0000 - val_loss: 4.2533e-05 - val_acc: 1.0000 Epoch 490/500 74/74 [==============================] - 0s 929us/sample - loss: 0.0143 - acc: 0.9865 - val_loss: 4.1014e-05 - val_acc: 1.0000 Epoch 491/500 74/74 [==============================] - 0s 915us/sample - loss: 0.0018 - acc: 1.0000 - val_loss: 3.9947e-05 - val_acc: 1.0000 Epoch 492/500 74/74 [==============================] - 0s 902us/sample - loss: 0.0063 - acc: 1.0000 - val_loss: 4.0230e-05 - val_acc: 1.0000 Epoch 493/500 74/74 [==============================] - 0s 890us/sample - loss: 0.0016 - acc: 1.0000 - val_loss: 4.1127e-05 - val_acc: 1.0000 Epoch 494/500 74/74 [==============================] - 0s 903us/sample - loss: 0.0055 - acc: 1.0000 - val_loss: 4.7421e-05 - val_acc: 1.0000 Epoch 495/500 74/74 [==============================] - 0s 917us/sample - loss: 0.0019 - acc: 1.0000 - val_loss: 4.5209e-05 - val_acc: 1.0000 Epoch 496/500 74/74 [==============================] - 0s 910us/sample - loss: 0.0047 - acc: 1.0000 - val_loss: 4.0886e-05 - val_acc: 1.0000 Epoch 497/500 74/74 [==============================] - 0s 847us/sample - loss: 0.0176 - acc: 0.9865 - val_loss: 4.5755e-05 - val_acc: 1.0000 Epoch 498/500 74/74 [==============================] - 0s 807us/sample - loss: 0.0025 - acc: 1.0000 - val_loss: 4.4927e-05 - val_acc: 1.0000 Epoch 499/500 74/74 [==============================] - 0s 878us/sample - loss: 0.0308 - acc: 0.9865 - val_loss: 4.5231e-05 - val_acc: 1.0000 Epoch 500/500 74/74 [==============================] - 0s 896us/sample - loss: 0.0017 - acc: 1.0000 - val_loss: 3.9627e-05 - val_acc: 1.0000 2019-05-23 22:06:41 INFO rasa_core.policies.keras_policy - Done fitting keras policy model 2019-05-23 22:06:41 INFO rasa_core.agent - Persisted model to ‘/Users/hajarchatoui/Desktop/horo/models/dialogue’ by writing pip install pykwalify==1.6.0

Happy you got it solved!