rasa_core.policies.ensemble.InvalidPolicyConfig: You didn't define any policies. Please define them under 'policies:' in your policy configuration file.

Created on 1 Mar 2019  路  3Comments  路  Source: RasaHQ/rasa

Rasa Core version:0.13.0

Python version: Python 3.6.8
Operating system (windows, osx, ...): Ubuntu 16.04 LTS

Issue: rasa_nlu and rasa_core training error :-
INFO:rasa_nlu.training_data.loading:Training data format of nlu.md is md
INFO:rasa_nlu.training_data.training_data:Training data stats:
- intent examples: 188 (15 distinct intents)
- Found intents: 'about_OPP', 'city_name', 'OPP_Phones_Price', 'goodbye', 'CustomerCare_info', 'provide_founder', 'brand_info', 'mood_deny', 'greet', 'model_name_lookout', 'Official_Website', 'CEO_info', 'mood_affirm', 'Service_Center_OR_Factory', 'Opp_store_location'
- entity examples: 99 (7 distinct entities)
- found entities: 'workshop_location', 'shop_location', 'web_address', 'model', 'information', 'customer_location', 'PERSON'

DEBUG:rasa_nlu.training_data.training_data:Validating training data...
Traceback (most recent call last):
File "bot_enhancement_updated.py", line 53, in
trainer = Trainer(config.load('config_mitie_sklearn.yml'))
File "/home/arghya/anaconda3/envs/myenv/lib/python3.6/site-packages/rasa_core/config.py", line 22, in load
return PolicyEnsemble.from_dict(config_data)
File "/home/arghya/anaconda3/envs/myenv/lib/python3.6/site-packages/rasa_core/policies/ensemble.py", line 222, in from_dict
raise InvalidPolicyConfig("You didn't define any policies. "
rasa_core.policies.ensemble.InvalidPolicyConfig: You didn't define any policies. Please define them under 'policies:' in your policy configuration file.

Content of policy.yml
'''yaml
policies:

  • name: KerasPolicy
    epochs: 50
    max_history: 6
  • name: AugmentedMemoizationPolicy
    max_history: 6
  • name: TwoStageFallbackPolicy
    nlu_threshold: 0.8
    core_threshold: 0.3
  • name: FormPolicy
    '''
    Content of nlu_congif.yml(name of the file :- )

'''yaml
language: "en"

pipeline:

  • name: "nlp_mitie"
    model: "/home/arghya/mitie_models/MITIE-models/english/total_word_feature_extractor.dat"
  • name: "tokenizer_mitie"
  • name: "ner_mitie"
  • name: "ner_synonyms"
  • name: "intent_entity_featurizer_regex"
  • name: "intent_featurizer_mitie"
  • name: "intent_classifier_sklearn"
    '''

bot logic for rasa_nlu and rasa_core training :-

-- coding: utf-8 --

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

rasa nlu imports

import logging
import warnings
from rasa_nlu.training_data import load_data
from rasa_nlu.config import RasaNLUModelConfig
from rasa_nlu.model import Interpreter, Trainer
from rasa_nlu import config
from rasa_nlu.training_data.loading import load_data_from_endpoint
from rasa_nlu.utils import EndpointConfig, read_endpoints

rasa core imports

import rasa_core
from rasa_core import config, cli
from rasa_core import utils
from rasa_core.agent import Agent
from rasa_core.run import AvailableEndpoints
from rasa_core.policies import FallbackPolicy, KerasPolicy, MemoizationPolicy
from rasa_core.interpreter import NaturalLanguageInterpreter
from rasa_core.domain import Domain
from rasa_core.utils import EndpointConfig
from rasa_core.run import serve_application
from rasa_core.tracker_store import RedisTrackerStore
from rasa_core.tracker_store import MongoTrackerStore

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
warnings.filterwarnings('ignore')

##training nlu

if the probability of the intent/action is too low , we will strop predicting and use a default action.

global_fallback = FallbackPolicy(fallback_action_name='utter_unclear',
core_threshold=0.3,
nlu_threshold=0.8)

training_data = load_data('nlu.md')

trainer to educate our pipeline

trainer = Trainer(config.load('config_mitie_sklearn.yml'))

training the nlu model

interpreter = trainer.train(training_data)

storing the model for future use

global_model_directory = trainer.persist('./models/nlu',
fixed_model_name='current')

training nlg -------------------->

domain = Domain.load('domain.yml')

global_db_mg = MongoTrackerStore(
domain,
host='mongodb://localhost:27017',
db='rasa',
username=None,
password=None,
collection='conversations',
event_broker=None,
)

def train_dialogue(
domain='domain.yml',
model_path='models/dialogue',
training_data_file='stories.md',
endpoints=AvailableEndpoints(),
policy_config=None,
):

Train a dialogue model

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

policies = config.load('policy.yml')
nlu_interpreter = global_model_directory
endpoints = '/home/arghya/rasa_test/data/place_finder/endpoints.yml'
agent = Agent(
    domain=domain,
    policies=policies,
    interpreter=nlu_interpreter,
    generator=None,
    tracker_store=global_db_mg,
    action_endpoint=endpoints,
    fingerprint=None,
    )
data = agent.load_data(training_data_file)
agent.train(data, epochs=400, batch_size=50, validation_split=0.2)
agent.persist(model_path)
return agent

if __name__ == '__main__':
agent = train_dialogue()
rasa_core.run.serve_application(agent, channel='cmdline')

extract list of events and print its names

events = global_db_mg.retrieve('default').as_dialogue().events
for event in events:
    print(event.as_story_string())

Content of domain file (if used & relevant):


The issue is with the training logic since policy.yml is available and configured and I am able to run rasa_nlu and rasa_core training using

1)python3 -m rasa_nlu.train -c config_mitie_sklearn.yml --fixed_model_name current --data nlu.md -o models --project nlu --verbose
2)python3 -m rasa_core.train -d domain.yml -s stories.md -c policy.yml --debug -o models/dialogue.

I have just upated the rasa_core version to 0.13.0 and not able to figure out how to pass the policy.yml for training.
Expert guidance is much appreciated.

Most helpful comment

Hi! What seems to be happening here is that when you call

trainer = Trainer(config.load('config_mitie_sklearn.yml'))

it's pulling config.load() from core, not nlu. This is because you have from rasa_nlu import config but this is overwritten by from rasa_core import config, cli. I think the easiest fix here would be to rename one of them, for example from rasa_nlu import config as nlu_config (and then use this name when you call the load function)

All 3 comments

Thanks for raising this issue, @erohmensing will get back to you about it soon.

Hi! What seems to be happening here is that when you call

trainer = Trainer(config.load('config_mitie_sklearn.yml'))

it's pulling config.load() from core, not nlu. This is because you have from rasa_nlu import config but this is overwritten by from rasa_core import config, cli. I think the easiest fix here would be to rename one of them, for example from rasa_nlu import config as nlu_config (and then use this name when you call the load function)

Hi @erohmensing , corrected the logical flaw.Thanks for the help.

Was this page helpful?
0 / 5 - 0 ratings