snipsco/snips-nlu

Multiple Intents Detection

Opened this issue ยท 6 comments

Hi, I am working on a contextual chatbot. I need to use intent based on current context of user.

For ex: User's input is relevant with Intent1 and Intent2. Based on current context I would like to respond user either for Intent1 or Intent2.

Currently Snips detects only single intent with the highest probability.

Is there any way to see top most intents ?

Hey @harshitazilen ,
It is indeed not possible at the moment to get the top most intents, but we may add an API for that in the future.
In your use case, if Intent1 and Intent2 are close semantically, perhaps you could merge them into a single intent and respond to the user according to current context.

Cheers
Adrien

Thanks @adrienball for your response.

I am trying to implement a follow up intent feature. where Intent2 & Intent3 are similar but For a user input:

If previously bot detected Intent1 , then it must detect Intent 2.
If previously bot did not detect Intent1, it should detect intent 3.

I believe above can not be achieved by merging intents. Probably waiting for API may be a good option. I will make separate NLU engine specially for Intent2 (followup intents).

Hello ๐Ÿ‘‹ ,

I'm also very interested in an API to have an intents list.

Sometimes, two intents can be close (~5% probability score difference) and that would be great to have the power to handle ambiguous situations like that.

We could just set an ambiguity threshold and then compare the difference in probability score for the two top intents, for example.

That would be great ! :)

Thanks for the feedback, I'm adding this to our roadmap.
We'll try to implement it when we have a bit of time.

@harshitazilen I wrote the following function to get multiple intents from the snips module.

_def get_n_intents(my_nlu_engine, my_text, my_intent_list, no_of_intents):
    result = []
    temp_intent_list = my_intent_list
    for i in range(no_of_intents):
        parsing = my_nlu_engine.parse(text = my_text,
                                      intents = temp_intent_list)
        if parsing["intent"] is None:
            break
        result.append(parsing["intent"])
        temp_intent_list.remove(parsing["intent"]["intentName"])
    return result_

Like a temporary workaround.

@adrienball I was working on this feature because I needed multiple intent for one of my project and I can throw a pull request for this. Just wanted to clarify, if a list of intents should be returned with corresponding probabilities. Should the None intents be skipped, in return value?
Instead giving a list of non-null intents, even when their corresponding probabilities add up to number <<1