Custom Response Selector

Hello, I’m trying to build a custom response selector component. To my knowledge there do not exist any tutorials on that, so at the moment I am trying to figure out how the rasa response selector works during prediction time. I have watched the master class but it does not go into coding details.

My question is how can I access all response candidates in the process method of my component to find the most similar one compared to the usser utterance ( = message object)?

The model I am trying to implement is a baseline and therefore quite simple: It just calculates the cosine similarity between the mean token embedding vector of the user utterance and a response candidate.

PS.: Of course I have been looking into the Rasa github repo but I have not figured out how everything works so far.

Hi @Chris38 , all response candidates are stored along with the model just after training. When the component is loaded from a trained model, these responses are also loaded and made available in the process method of the component.

Hi @dakshvar22, thank you for your quick reply. How is it if I do not train any model, since the responses are just select by comparing message features via cosine distance?

You can still implement a train method which stores the responses from training data object and then a persist and load which appropriately stores and restores these responses. You can take a look at the source code of to get a better idea of how this is being done there.