Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

意图 inform_case 和 SearchCase区别 #8

Open
jiangdongguo opened this issue Jun 8, 2019 · 3 comments
Open

意图 inform_case 和 SearchCase区别 #8

jiangdongguo opened this issue Jun 8, 2019 · 3 comments

Comments

@jiangdongguo
Copy link

您好!在rasa_dataset_training.json文件中,意图 inform_case 和 SearchCase有什么区别?为什么不用一个SearchCase包括这两个意图的样本?另外,如果把这两个意图的样本都归纳到form:case_form,即命名一个case_form意图,这样不是不好构建story吗?现在遇到一些问题想不通,麻烦能够解释下原因吗?谢谢!

@jiangdongguo
Copy link
Author

我现在有这么一个场景:当我们输入“”查询车牌号码粤A12345“”,rasa core能够返回请求的数据给我,但当我再次输入“”再帮我查一下身份证号码“”时,rasa core却把上一次车牌的结果返回给我,而没有问我继续输入身份证号码,请问是什么原因导致的呢?期待解答!谢谢!

Rasa Core logs:

192.168.0.110 - - [2019-06-08 11:44:37] "POST /webhooks/rest/webhook HTTP/1.1" 200 452 1.066897
2019-06-08 11:44:51 DEBUG    rasa_core.tracker_store  - Recreating tracker for id '152869574032212890:123'
2019-06-08 11:44:52 DEBUG    rasa_core.processor  - Received user message '查询车牌号码粤 A12345' with intent '{'name': 'request_number', 'confidence': 0.964844109378438}' and entities
'[{'entity': 'item', 'value': '车牌', 'start': 2, 'end': 6, 'confidence': None, 'extractor': 'ner_mitie', 'processors': ['ner_synonyms']}, {'entity': 'number', 'value': 'A12345', 'st
art': 6, 'end': 13, 'confidence': None, 'extractor': 'ner_mitie'}]'
2019-06-08 11:44:52 DEBUG    rasa_core.processor  - Logged UserUtterance - tracker now has 170 events
2019-06-08 11:44:52 DEBUG    rasa_core.processor  - Current slot values:
        business: None
        item: None
        number: None
        requested_slot: None
2019-06-08 11:44:52 DEBUG    rasa_core.policies.memoization  - Current tracker state [None, None, None, {}, {'entity_item': 1.0, 'entity_number': 1.0, 'prev_action_listen': 1.0, 'inten
t_request_number': 1.0}]
2019-06-08 11:44:52 DEBUG    rasa_core.policies.memoization  - There is no memorised next action
2019-06-08 11:44:52 DEBUG    rasa_core.policies.form_policy  - There is no active form
2019-06-08 11:44:52 DEBUG    rasa_core.policies.ensemble  - Predicted next action using policy_1_MobilePolicy
2019-06-08 11:44:52 DEBUG    rasa_core.processor  - Predicted next action 'number_form' with prob 0.99.
2019-06-08 11:44:52 DEBUG    rasa_core.actions.action  - Calling action endpoint to run action 'number_form'.
2019-06-08 11:44:52 WARNING  py.warnings  - E:\ComPython\LittleTeligen\RasaCore\venv\lib\site-packages\urllib3\connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request i
s being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)

2019-06-08 11:44:52 DEBUG    rasa_core.processor  - Action 'number_form' ended with events '['Form(number_form)', 'SlotSet(key: item, value: 车牌)', 'SlotSet(key: number, value:粤A12345)', 'SlotSet(key: item, value: None)', 'Form(None)', 'SlotSet(key: requested_slot, value: None)']'
2019-06-08 11:44:52 DEBUG    rasa_core.processor  - Bot utterance 'BotUttered(text: {"method": "queryCarInfo", "wccpproxy": "{\"result\": 1, \"resultMsg\": \"none\", \"list\": [{\"owne
rName\": \"\\u5f20\\u4e09\", \"idCard\": \"450981199305174536\", \"color\": \"\\u9ec4\\u8272\", \"firstRegDate\": \"2019-03-23\", \"brand\": \"BMW\", \"model\": \"x3\", \"carType\": \"
normal\", \"numType\": \"plate\", \"carNum\": \"\\u7ca4a12345\"}]}"}, data: {
  "elements": null,
  "buttons": [],
  "attachment": null
})'
2019-06-08 11:44:52 DEBUG    rasa_core.policies.memoization  - Current tracker state [None, None, {}, {'entity_item': 1.0, 'entity_number': 1.0, 'prev_action_listen': 1.0, 'intent_requ
est_number': 1.0}, {'entity_item': 1.0, 'entity_number': 1.0, 'prev_number_form': 1.0, 'intent_request_number': 1.0}]
2019-06-08 11:44:52 DEBUG    rasa_core.policies.memoization  - There is no memorised next action
2019-06-08 11:44:52 DEBUG    rasa_core.policies.form_policy  - There is no active form
2019-06-08 11:44:52 DEBUG    rasa_core.policies.ensemble  - Predicted next action using policy_1_MobilePolicy
2019-06-08 11:44:52 DEBUG    rasa_core.processor  - Predicted next action 'action_listen' with prob 1.00.
2019-06-08 11:44:52 DEBUG    rasa_core.processor  - Action 'action_listen' ended with events '[]'

192.168.0.110 - - [2019-06-08 11:44:52] "POST /webhooks/rest/webhook HTTP/1.1" 200 1184 1.067888
2019-06-08 11:44:58 DEBUG    rasa_core.tracker_store  - Recreating tracker for id '152869574032212890:123'
2019-06-08 11:44:59 DEBUG    rasa_core.processor  - Received user message '帮我查一下身份证号码 with intent '{'name': 'request_number', 'confidence': 0.9043155210530247}' and entities '[{'e
ntity': 'item', 'value': '身份证', 'start': 2, 'end': 7, 'confidence': None, 'extractor': 'ner_mitie', 'processors': ['ner_synonyms']}]'
2019-06-08 11:44:59 DEBUG    rasa_core.processor  - Logged UserUtterance - tracker now has 180 events
2019-06-08 11:44:59 DEBUG    rasa_core.processor  - Current slot values:
        business: None
        item: None
        number: 粤A12345
        requested_slot: None
2019-06-08 11:44:59 DEBUG    rasa_core.policies.memoization  - Current tracker state [None, {}, {'entity_item': 1.0, 'entity_number': 1.0, 'prev_action_listen': 1.0, 'intent_request_nu
mber': 1.0}, {'entity_item': 1.0, 'entity_number': 1.0, 'prev_number_form': 1.0, 'intent_request_number': 1.0}, {'entity_item': 1.0, 'prev_action_listen': 1.0, 'intent_request_number':
 1.0}]
2019-06-08 11:44:59 DEBUG    rasa_core.policies.memoization  - There is no memorised next action
2019-06-08 11:44:59 DEBUG    rasa_core.policies.form_policy  - There is no active form
2019-06-08 11:44:59 DEBUG    rasa_core.policies.ensemble  - Predicted next action using policy_1_MobilePolicy
2019-06-08 11:44:59 DEBUG    rasa_core.processor  - Predicted next action 'number_form' with prob 1.00.
2019-06-08 11:44:59 DEBUG    rasa_core.actions.action  - Calling action endpoint to run action 'number_form'.
2019-06-08 11:44:59 WARNING  py.warnings  - E:\ComPython\LittleTeligen\RasaCore\venv\lib\site-packages\urllib3\connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request i
s being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)

2019-06-08 11:44:59 DEBUG    rasa_core.processor  - Action 'number_form' ended with events '['Form(number_form)', 'SlotSet(key: number, value: 粤12345)', 'SlotSet(key: item, value: None)', 'Form(None)', 'SlotSet(key: requested_slot, value: None)']'
2019-06-08 11:44:59 DEBUG    rasa_core.processor  - Bot utterance 'BotUttered(text: {"method": "queryCarInfo", "wccpproxy": "{\"result\": 1, \"resultMsg\": \"none\", \"list\": [{\"owne
rName\": \"\\u5f20\\u4e09\", \"idCard\": \"450981199305174536\", \"color\": \"\\u9ec4\\u8272\", \"firstRegDate\": \"2019-03-23\", \"brand\": \"BMW\", \"model\": \"x3\", \"carType\": \"
normal\", \"numType\": \"plate\", \"carNum\": \"\\u7ca4a12345\"}]}"}, data: {
  "elements": null,
  "buttons": [],
  "attachment": null
})'
2019-06-08 11:44:59 DEBUG    rasa_core.policies.memoization  - Current tracker state [{}, {'entity_item': 1.0, 'entity_number': 1.0, 'prev_action_listen': 1.0, 'intent_request_number':
 1.0}, {'entity_item': 1.0, 'entity_number': 1.0, 'prev_number_form': 1.0, 'intent_request_number': 1.0}, {'entity_item': 1.0, 'prev_action_listen': 1.0, 'intent_request_number': 1.0},
 {'entity_item': 1.0, 'prev_number_form': 1.0, 'intent_request_number': 1.0}]
2019-06-08 11:44:59 DEBUG    rasa_core.policies.memoization  - There is no memorised next action
2019-06-08 11:44:59 DEBUG    rasa_core.policies.form_policy  - There is no active form
2019-06-08 11:44:59 DEBUG    rasa_core.policies.ensemble  - Predicted next action using policy_1_MobilePolicy
2019-06-08 11:44:59 DEBUG    rasa_core.processor  - Predicted next action 'action_listen' with prob 1.00.
2019-06-08 11:44:59 DEBUG    rasa_core.processor  - Action 'action_listen' ended with events '[]'
192.168.0.110 - - [2019-06-08 11:44:59] "POST /webhooks/rest/webhook HTTP/1.1" 200 1184 1.083746

story:

# happy with request number
* greet
    - utter_answer_greet
* request_number
    - number_form
    - form{"name": "number_form"}
    - form{"name": null}
* thanks
    - utter_answer_thanks

action code:

class NumberForm(FormAction):

    def name(self):
        """Request Number action唯一标识"""
        return "number_form"

    def validate_number(self, value, dispatcher, tracker, domain):
        pass


    def validate_item(self, value, dispatcher, tracker, domain):
        pass


    @staticmethod
    def required_slots(tracker):
        number = tracker.get_slot('number')
        if number is not None:
            return ["number"]

        return ["item", "number"]


    def submit(self, dispatcher, tracker, domain):
        inputItem = tracker.get_slot("item")
        inputNum = tracker.get_slot("number")

        print("##### current slot:item={0},number={1}".format(inputItem, inputNum))
        
        return []

train core model configs:

def train_dialogue_keras_form(domain_file="configs/core/domain_form.yml",
                         model_path="models/dialogue_keras_form_new",
                         training_data_file="data/stories_data/form"):
    fallback = FallbackPolicy(
        fallback_action_name="action_default_fallback",
        nlu_threshold=0.4,
        core_threshold=0.3
    )

    agent = Agent(domain_file,
                  policies=[MemoizationPolicy(max_history=5),
                            MobilePolicy(epochs=100, batch_size=16),
                            FormPolicy(), fallback])

    training_data = agent.load_data(training_data_file)
    agent.train(
        training_data,
        validation_split=0.2
    )

    agent.persist(model_path)
    return agent

domain.yml:

forms:
  - number_form

intents:
  - affirm
  - deny
  - greet
  - goodbye
  - thanks
  - whoareyou
  - whattodo
  - whereyoufrom
  - mod_happy
  - mod_unhappy
  - mod_angry
  - mod_worried
  - request_number
  - request_business
  - search_item
  - say_jokes
  - ask_age
  - ask_sex
  - out_of_scope
  - welcome

slots:
  item:
    type: unfeaturized
    auto_fill: false
  number:
    type: unfeaturized
    auto_fill: false
  business:
    type: unfeaturized
    auto_fill: false

entities:
  - item
  - number
  - business

@xiaoxiong74
Copy link
Owner

您好!在rasa_dataset_training.json文件中,意图 inform_case 和 SearchCase有什么区别?为什么不用一个SearchCase包括这两个意图的样本?另外,如果把这两个意图的样本都归纳到form:case_form,即命名一个case_form意图,这样不是不好构建story吗?现在遇到一些问题想不通,麻烦能够解释下原因吗?谢谢!

当时这么做的意图是为了先通过SearchCase进入本轮对话,再用inform_case 采集信息,这样有利于会话的切换。比如inform_case中有时间字段,当我直接输入一个时间字段时,是直接进入案件这个会话呢还是进入话费咨询这个会话,特别是有共同的字段时,比如时间、地点。所以,这里是先通过SearchCase、request_search这些来先判断进入哪一个会话,进入会话后再采集各自的信息。

@xiaoxiong74
Copy link
Owner

number_form

这个问题,显然是车牌号码与身份证号码都是用的 number_form(FormAction)来填的曹,你第一次用车牌号填充了并没有清空,所以第二次查身份证号码时,里面已经有值了就直接返回了。要么用不同的FormAction(不同的业务会话建议用不同的FormAction),要么每次用完了就清空曹(return [AllSlotsReset()])。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants