1

In Dialogflow (ES version), we have an intent for detecting product names and optional quantities. E.g. Do you have Pepsi or I need 4 apples. We also have some training examples that contain more than one product. E.g: I need 2 brush and 3 chocolates.

The general idea is to make the entity extraction generic so that we can query with n number of products. For example, 1 Pepsi, 2 eggs, 5 ice cream, and 4 tomatoes will extract the 4 different products correctly.

But we did some manual testing and found that the entity extraction does not generally extend to an arbitrary number of entities. Is that a limitation of Dialogflow or do we need to tune our training data to include more examples with 4/5+ products?

I am looking for suggestions on handling this type of query with an arbitrary amount of entities.

Dialogflow Setup:

ML Threshold: 0.3

Entities:

Product: Some product names as training data. **Automated expansion** and **Fuzzy matching** enabled.
Product-count: @sys.number. All options disabled 

Product_Query intent parameters:

+----------------+----------------+------+
| Parameter Name |     Entity     | Type |
+----------------+----------------+------+
| products       | @Products      | List |
| product-count  | @Product-count | List |
+----------------+----------------+------+
Jahir
  • 630
  • 1
  • 11
  • 25
  • Hi Jahirul, could you include some screenshots of your parameter setup in dialogflow? It makes it easier to advice you with your question if we know more about how you setup the entity extraction. – Jordi Oct 29 '20 at 14:20
  • Sure. I'm adding my entity and intent configuration in the post – Jahir Oct 29 '20 at 14:22
  • Hi, @Jordi, I've updated the post with some Dialogflow setup. Let me know if more info is required. Thanks – Jahir Oct 29 '20 at 14:32
  • Ah, sorry for posting an incorrect answer, I misunderstood the question. As far as I know there isn't a specific limit to the amount of entities that can go in a list. Have you tried testing this with a simple usecase, say by trying to detect 10 numbers? – Jordi Oct 29 '20 at 15:10
  • No worries. Thanks for the effort. I did try and the results were hit and miss. That's why I wanted some advice from others who have more Dialogflow knowledge – Jahir Oct 29 '20 at 15:12
  • If this were to be a limitation of Dialogflow, I think you would have 2 possible work arounds, 1) change your flow to always ask the user to confirm the extracted products after they enter the products and ask them if there is anything else they would like to add. 2) Work with @sys.any and extract the raw values from a string using code Note: This is difficult, unpredictable, hard to maintain, not recommended and shouldn't be used unless it is a very final effort. – Jordi Oct 29 '20 at 15:18
  • Yeah. I am keeping this option as a later resort. – Jahir Oct 29 '20 at 16:14
  • Hello, I added training phrases with more than 7 products and it detects all the entities, however the actions and parameters looks quite different than yours. – Kim Dec 03 '20 at 10:06
  • @kim that's awesome. I think it'll be helpful if you can add some example phrase and entity configuration as an answer – Jahir Dec 03 '20 at 10:41

1 Answers1

1

I created two entities: @products and @count:

@products         @count       *it sounds dumb to use this @count but is useful for 
banana            1             this example
apple             2
pepsi             3
cocacola          4 
pear              5
orange            6
juice             7
book              8 

Then I created an intent called products_detection and I added the training phrase:

I want 1 banana, 2 apples, 3 juices, 4 pear, 5 orange, 6 book, 7 cocacola, 8 pepsi

Once you click enter Dialogflow matches the sentence words with the entities and assigns each of them a different value. He also takes the entities from apples and juices although they are plural in the training phrase.

I just wanted to try if it could work with a single training sentence and it worked surprisingly good. First I tried with the same training sentence and the result is:

"parameters": {
      "count2": "3",
      "count14": "7",    <-------------
      "count": "1",                    | You can see that the product and count
      "products14": "cocacola",   <----  matches for all products
      "products13": "book",
      "products12": "orange",
      "count12": "5",
      "count21": "8",
      "count11": "4",
      "count1": "2",
      "products21": "pepsi",
      "count13": "6",
      "products2": "juice",
      "products": "banana",
      "products1": "apple",
      "products11": "pear"
    },

Then I mixed the numbers and products and tried with the phrase:

I want 5 banana, 8 apples, 7 juices, 3 pepsi, 1 cocacola, 2 orange, 4 book, 6 pear

And I get:

"parameters": {
      "count1": "8",
      "count12": "1",
      "count14": "4",
      "count21": "6",
      "products13": "orange",
      "count11": "3",
      "products14": "book",
      "products2": "juice",
      "count": "5",
      "products21": "pear",
      "products1": "apple",
      "products12": "cocacola",
      "count2": "7",
      "products": "banana",
      "products11": "pepsi",
      "count13": "2"
    },

As you can see the products are still matching with the counts, and here there are more than 5 products.

Kim
  • 326
  • 1
  • 5
  • Thanks for the answer. But would it work if the product is not included in the entity list. For example, if I say "I want 2 big mac, 3 fanta and 1 book". – Jahir Dec 03 '20 at 12:14
  • I was just pointing an example with more than 5 entity extractions but this way products not included in the entity list won't be recognized. I don't even know if it would work if there are repeated numbers in the query. Which training phrases did you have in your initial approach? – Kim Dec 03 '20 at 14:28