Best way to add my own dialog manager in go bot?

I am looking to replace the policy network with my own. What I did was take the individual parts, the slot filler, and the templates and tried to use them outside of the ‘chainer’ context. I think in this case I am messing something up with the state tracker. Is there a more straightforward way to do this?

Hi, and welcome to our forums!

If you simply want to change the behavior of the Dialog Manager you can open go_bot class at https://github.com/deepmipt/DeepPavlov/blob/master/deeppavlov/models/go_bot/go_bot.py, dig into _infer() method, and change the way it works with policy_prediction and policy.

Here’s a deeper comment by our very own Oleg:

[comment]

Note that all the inference logic happens in the _infer method, when we ask policy to predict the correct action (link):

  • we take the features representation of the utterance of type BatchDialoguesFeatures (obtained with extract_features_from_utterance_text a couple of lines above),

  • we feed them (and NN states but that’s sort of legacy) into the policy,

  • and then the policy responds with prediction of type PolicyPrediction.


That’s said, it would be great to implement your enhancements in the following way:

Your own policy will be used instead of the provided one, and:

  • it will be showing the same signatures that ours does. you’ll probably mock all the irrelevant methods via returning smth meaningless, while ensuring that the __call__ method performs the way you want it: i.e. given the utterance info it predicts the action you want it to

  • and since the __call__ method of the policy has a signature that wants a BatchDialoguesFeatures instance, you should also implement your own version of extract_features_from_utterance_text that will return all the info you are using in policy. It seems like your extract_features_from_utterance_text should return smth inherited from BatchDialoguesFeatures to keep proper signatures.

It seems to me that the described above will allow you to as little changes as it is possible: the only method modified in the GoalOrientedBot class is the modification of extract_features_from_utterance_text and the policy that has to be instantiated in the GoalOrientedBot is now yours and not the one we use.

[/comment]

All in all, though, we would love to learn more about your use case. We are working on further updates to the Go-Bot and your feedback would be crucial for us.

Best Regards,
Daniel

1 Like