How to access to previous slots?


(王旭峰(Xufeng Wang)) #1

I have a problem while trying to build a rasa bot. I have tree slots, tracks entities which I use as keys for a dictionary data. Very primitive, but it the only way I can think of for my task–QA problem. It can answer questions in this sequence:

user: ‘who is lebron james?’ bot: ‘a NBA player, currently playing the los angeles lakers’ user: ‘how tall is he?’ bot: ‘lebron is 6’8’’ tall’

but right after this sequence, when user asks:

user: ‘who is Kevin Love’
bot: ‘Love is 6’10" tall’

I only have the slot ‘person’ to track the person in the topic. I want to solve this by tracking the change of person slot. If the person in the Person slot changes from ‘lebron’ to ‘kevin’, I would reset the second slot instead of leaving it as ‘height’ (it’s not ideal, as user may ask ‘how about kevin love’ and the ‘love is 6’10" tall’ would be the right answer, but I still like to have this option to manipulate the dialogue).

I can spend more time digging the docs and the source code, but if anyone can give me some pointers, I would appreciate it very much.

Besides the access to previous slots technique, if anyone can give me some advise about how to store the not too big knowledge better than a dictionary, I thank you in advance.

(Akela Drissner) #2

What do your stories currently look like?

(王旭峰(Xufeng Wang)) #3

Thanks for replying.

Sorry for the Chinesed character, but the intents are obvious, I think. I am not distrust rasa‘s inference power. It is just that sometimes, given a Chinese sentence, it hard to tell whether it’s asking questions or stating facts without knowing the previous dialogue context. There is no reordering of subject and predicate like it is in English. I am not an expert of Chinese grammar, and my store is poorly designed. I think accessing to the previous slots is a little bit useful.

(马健) #4

If your conversation has only two rounds, you can add a custom function in the last round to clear all slots. There is really no good solution at the moment.

(王旭峰(Xufeng Wang)) #5

Thanks for replying.

I set an additional slot called ‘last_obj’ with some initial value. Everytime when custom action is invoked, I would load the obj slot and compare it with the last_obj slot. If the new obj does not equal to the last_obj, all slots get reset and the last_obj gets assigned with the new obj value.

I have some nlu problems too. As my train value gets larger, my nlu trainer does not get trained very well. It can’t recognize greetings and goobyes such as ‘hello’, '你好’,‘88’ etc。

by the way, would you like to add my wechat_id: MaDaOSimon? @majian We can help each other out (mainly and probably you help me), if you are interested. My profile picture is the Starry Night painting in a coffee mug. Sorry, if i have the wrong assumption that you maybe a Chinese and use wechat.

(Akela Drissner) #6

Could you post your stories in the markdown format? I don’t think you need to clear the slots really.

(王旭峰(Xufeng Wang)) #8

Sorry, it’s very messy.


  • greet
  • utter_greet


  • full_question{‘对象’:‘土豆’,‘内容’:‘土豆’,‘细节’:‘定义’}
  • action_knowledge_retrieve


  • greet
  • utter_greet
  • full_question{‘对象’:‘土豆’,‘内容’:‘土豆’,‘细节’:‘定义’}
  • action_knowledge_retrieve


  • full_question{‘对象’:‘土豆’}
  • action_knowledge_retrieve
  • provide_content{‘内容’:‘土豆’}
  • action_knowledge_retrieve


  • provide_obj{‘对象’:‘土豆’}
  • action_knowledge_retrieve
  • provide_content{‘内容’:‘土豆’}
  • action_knowledge_retrieve
  • provide_detail{‘细节’:‘定义’}
  • action_knowledge_retrieve


  • full_question{‘对象’:‘土豆’,‘内容’:‘土豆’}
  • action_knowledge_retrieve
  • provide_detail{‘细节’:‘定义’}
  • action_knowledge_retrieve


  • inform_problem{‘对象’:‘手表’,‘内容’:‘不能用了’}
  • utter_ask_explaination
  • provide_content{‘内容’:‘显示屏无显示’}
  • action_knowledge_retrieve


  • done
  • utter_other_concern


  • bye
  • utter_bye
  • action_reset_slots


  • utter_unclear


  • rage_leave
  • utter_sorry

(Akela Drissner) #9

You should probably have different intents, like e.g. ask_about_height or ask_about_player. This means you can distinguish based on context, and won’t have the problem to have to figure out what response to give within the action_knowledge_retrieve action

(王旭峰(Xufeng Wang)) #10

That’s a great idea. That will make my knowledge dictionary a lot simpler. Thank you Akelad. I will try it out tomorrow.