What's the best way to extract multiple entities within the same intent and retrieve its numerical value?

Hi! I’m new to Rasa and I’ve been looking at ways to extract values that fall into the same entity and convert them into a numerical value.

Using the following example I want to extract the quantity for the items retrieved in the intent.

“Give me two small pizzas with mushrooms and a large pepperoni”

This user’s intent could be divided into the following entities: Give me [two]{“entity”: “quantity”, “group”: “1”} [small]{“entity”: “size”, “group”: “1”} pizzas with [mushrooms]{“entity”: “topping”, “group”: “1”} and [a]{“entity”: “quantity”, “group”: “2”} [large]{“entity”: “size”, “group”: “2”} [pepperoni]{“entity”: “topping”, “group”: “2”}

But how would I go about obtaining a numerical value for the quantities? I could probably use a custom action with a duckling python wrapper like pyduckling but I don’t really want to have more dependencies than needed and I don’t feel like this is the right approach to the problem. At least, not the most Rasa way of doing things.

I have tried Rasa’s DucklingEntityExtractor but since I’m extracting two entities on the same intent, it essentially assigns a value to the slot with the first entity extraction, and then replaces the slot’s value with the value of the second entity. Making it so I cannot retrieve the value for each individyal entity.

What’s the best way to extract both quantity entities without losing any of them and retrieve its numerical value?

1 Like

So it looks like you’re successfully extracting the entities, your question seems to be more “how can I extract the same entity and store it to different slots in a single intent”, right?

You could use a list slot for this (there’s some discussion here: How to pupulate a slot of type list - #4 by ganeshv) but you’ll probably need to write a little custom code to assign the right qualities to the right order.

Another question to consider is: is this a pattern you’re seeing users try? If it is, then it definitely makes sense to try and address it now even if it takes a bit of finagling. If it’s not & something you think they might do, then I’d skip working on it until you have good evidence that it’s functionality that folks want. (As a just-in-case measure, you could include a rule that detects multiple intents and asks the user to list items in their order one-at-a-time.)

2 Likes