我的wit.ai应用程序中有三个故事:
- order_pizza: typical pizza ordering with size and toppings
- reserve_table: book a table for a specific date and time
- fav_topping: query favourite pizza topping from historical data by date
第三个,fav_topping有点特别。用户可以问一下6月份我最喜欢的打算是什么?'。在得到答案之后,可以通过更改日期和“7月”以及7月份来再次提出问题吗?'。
更正式地说:让我说我有一个有多个实体(X和Y)的故事。用户询问一个带有几个参数的问题(一个用于X,一个用于Y),并得到答案。再问(c代表X),我的机器人通过将当前的参数与前面的参数混合来给出答案(c代表X,b代表Y)。
为了解决这个问题,我从头到尾回放了我最喜欢的故事: fav_topping story with a loop-back
工作完美,但我遇到了问题。它永远不会结束。因此无法阻止它,用户无法更改主题。这是来自我的node.js客户端的日志,使用交互模式:
> What was my favourite topping in June?
fav_topping
context in: {}
entities in: {"contact":[{"confidence":0.9965486088458536,"type":"value","value":"my","suggested":true}],"datetime":[{"confidence":0.9954243915206602,"type":"value","value":"2017-06-01T00:00:00.000-07:00","grain":"month","values":[{"type":"value","value":"2017-06-01T00:00:00.000-07:00","grain":"month"},{"type":"value","value":"2018-06-01T00:00:00.000-07:00","grain":"month"},{"type":"value","value":"2019-06-01T00:00:00.000-07:00","grain":"month"}]}],"intent":[{"confidence":0.9969200405818317,"value":"fav_topping"}]}
context out is: {"ft_answer":"Your favourite topping was tomato for sure :) *"}
sending... {"text":"Your favourite topping was tomato for sure :) "}
> and in June?
fav_topping
context in: {"ft_answer":"Your favourite topping was tomato for sure :) "}
entities in: {"datetime":[{"confidence":0.994470434703695,"type":"value","value":"2017-06-01T00:00:00.000-07:00","grain":"month","values":[{"type":"value","value":"2017-06-01T00:00:00.000-07:00","grain":"month"},{"type":"value","value":"2018-06-01T00:00:00.000-07:00","grain":"month"},{"type":"value","value":"2019-06-01T00:00:00.000-07:00","grain":"month"}]}]}
context out is: {"ft_answer":"Your favourite topping was tomato for sure :) "}
sending... {"text":"Your favourite topping was tomato for sure :) "}
> OK, I want a normal pizza with tomato and pepperoni
fav_topping
context in: {"ft_answer":"Your favourite topping was tomato for sure :) "}
entities in: {"contact":[{"confidence":0.5452832324099028,"type":"value","value":"I","suggested":true}],"pizza_size":[{"confidence":0.9769454518025678,"type":"value","value":"middle"}],"pizza_topping":[{"confidence":0.9934795348369287,"type":"value","value":"tomato"},{"confidence":0.9505825366331593,"type":"value","value":"pepperoni"}],"intent":[{"confidence":0.6669035510798399,"value":"order_pizza"}]}
context out is: {"ft_answer":"Your favourite topping was tomato for sure :) "}
sending... {"text":"Your favourite topping was tomato for sure :) "}
> Book me a table for 5 persons at 9pm
fav_topping
context in: {"ft_answer":"Your favourite topping was tomato for sure :) "}
entities in: {"contact":[{"confidence":0.8387365394318869,"type":"value","value":"me","suggested":true}],"number":[{"confidence":1,"type":"value","value":5}],"datetime":[{"confidence":1,"type":"value","value":"2016-07-07T21:00:00.000-07:00","grain":"hour","values":[{"type":"value","value":"2016-07-07T21:00:00.000-07:00","grain":"hour"},{"type":"value","value":"2016-07-08T21:00:00.000-07:00","grain":"hour"},{"type":"value","value":"2016-07-09T21:00:00.000-07:00","grain":"hour"}]}],"intent":[{"confidence":0.9997353858626356,"value":"reserve_table"}]}
context out is: {"ft_answer":"Your favourite topping was tomato for sure :) "}
sending... {"text":"Your favourite topping was tomato for sure :) *"}
问题是:如何手动/编程地告诉BE完成故事?或者,我如何设置故事来处理切换?
还有一点需要注意:正如您在我的日志中可以看到BE理解得很好,用户开始了一个新主题(认识到意图改为' order_pizza'' reserve_table') 。如果我能明确定义故事的意图,也许可以帮助很多。你怎么看? (对我们现在所拥有的东西没有太大的改变:定义故事的第一句话)
答案 0 :(得分:1)
感谢您的详细解释。这是目前Bot Engine的限制,我们正在以更优雅的方式来解决这个问题。与此同时,当意图不是“fav_topping”时,您可能希望删除“ft_answer”上下文密钥。
有关上下文的更多信息
Wit读取上下文以预测下一步。我们永远不会更新我们这方面的背景。您可以使用旁边的操作来更新上下文中的键。这些键可以反过来影响基于故事的预测,但也可以通过变量建立Bot答案。 Wit使用当前上下文(仅用于现在的键),上下文的状态(在交互N-1,N-2 ......)以及用户消息(特征实体)来预测下一个动作。