RasaHQ / rasa

💬 Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants
https://rasa.com/docs/rasa/
Apache License 2.0
18.66k stars 4.6k forks source link

Add new Deep Learning classifier #929

Closed oscalarr closed 6 years ago

oscalarr commented 6 years ago

I have developed a new classifier that uses a deep learning algorithm to extract intents.

Hi @tmbo, @omerarshad, please, could you review it?

922

omerarshad commented 6 years ago

I think there are infinite deep learning structures we can build to classify intents. So instead of adding different classifiers to RASA, we must give user option to customize available classifiers i.e. adding hidden layers, drop out etc.

tmbo commented 6 years ago

@omerarshad I don't think there is an easy way to abstract over all of these parameters (but maybe there is, e.g. a tensorflow model definition language?). Otherwise, a good solution is to provide a good initial setup (layers, dropout, ...) that works for most use cases allowing people with experience to change the model by subclassing the class.

oscalarr commented 6 years ago

It´s easy to extract the model to a function and reuse the rest of the code.

Model:

tf.reset_default_graph()

net = tflearn.input_data(shape=[None, len(self.train_x[0])]) net = tflearn.fully_connected(net, 32) net = tflearn.fully_connected(net, 32) net = tflearn.fully_connected(net, len(self.train_y[0]), activation='softmax') net = tflearn.regression(net) self.model = tflearn.DNN(net)

oscalarr commented 6 years ago

@tmbo, with this algorithm you can have a special intent (anythingelse) that is selected when the text doesn´t fit in one intent. Is it better to return this intent or return no intent?

oscalarr commented 6 years ago

I´m working in a keras version, is it ok?

amn41 commented 6 years ago

@oscalarr thank you for making the effort to create a new classifier! I would recommend first creating an issue describing what you hope to achieve with it. In our experiments so far, replacing the SVM with a neural net doesn't improve intent classification performance, and only introduces a number of hyperparameters which have to be tuned. I'm excited that you are looking to contribute, but as there is a good chance we wouldn't merge this contribution, please create an issue where we can discuss it before implementing anything

oscalarr commented 6 years ago

@amn41, I agree with you that is important to have an issue to discuss, but sometimes is better to have some code to play with. Currently we have a hybrid chatbot (Q&As + some slots in Spanish) developed using Watson Conversation (now Watson Assistant). In our case we have some "delicate" answers so for us it is important to "control" the intent classification. We use the special intent anythingelse ("I don´t understand you") and a threshold to do it. It allows us to manage anythingelse and provide different suggestions depeding on the context. So, for our case the current intent classifiers don´t fit well.

amn41 commented 6 years ago

I understand the need for better thresholds, but for a neural net to deliver that you will have to customise your loss function a bit. Please keep an eye on https://github.com/RasaHQ/rasa_nlu/pull/943 - aim to merge it soon and it probably already does what you want. It's explicitly a ranking model so the confidence should be more reliable

oscalarr commented 6 years ago

I have closed the issue because I´m testing the embedding classifier.

oscalarr commented 6 years ago

With the deep learning algorithm that the code use, adding an intent with the text "." improve the results and it allow you to cut using a 0.5 threshold.