# Detecting multiple entities of the same type

**URL:** <https://forum.rasa.com/t/detecting-multiple-entities-of-the-same-type/9208>\
**Category:** Rasa Open Source\
**Created:** [May 1, 2019, 11:18am UTC](https://forum.rasa.com/t/detecting-multiple-entities-of-the-same-type/9208 "2019-05-01T11:18:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![spiralswimmer](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@spiralswimmer](https://forum.rasa.com/u/spiralswimmer)\
**Post date:** [May 1, 2019, 11:18am UTC](https://forum.rasa.com/t/detecting-multiple-entities-of-the-same-type/9208/1 "2019-05-01T11:18:34Z")

</div>

I want to detect multiple entities of the same type in the sentence:

Order 2 bananas 3 oranges and 5 apples Order 5 cases of spinach 16 ounces 7 kgs of fuji apples 12 packs of milk

Entities above are:

1. Count - 2/3/5/7
2. Products - bananas/oranges/spinach 16 ounces/fuji apples
3. Units - cases/kgs/packs

While I can train the model really well to pick n different types of entities I am facing issues with having multiple entities of multiple types in the same utterance.

I have tried to generate training data using chatito but the permutation and combinations run into 10s of millions.

Any suggestions around this?

---

<div class="post-metadata">

**Author:** ![Leo\_Sal](https://avatars.discourse-cdn.com/v4/letter/l/b782af/32.png) [@Leo\_Sal](https://forum.rasa.com/u/Leo_Sal)\
**Post date:** [May 1, 2019, 4:10pm UTC](https://forum.rasa.com/t/detecting-multiple-entities-of-the-same-type/9208/2 "2019-05-01T16:10:37Z")

</div>

Hi @spiralswimmer, when you day that you are having issues, do you mean that the NLU is not extracting all the entities correctly from the user message?

---

<div class="post-metadata">

**Author:** ![spiralswimmer](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@spiralswimmer](https://forum.rasa.com/u/spiralswimmer)\
**Post date:** [May 3, 2019, 4:59pm UTC](https://forum.rasa.com/t/detecting-multiple-entities-of-the-same-type/9208/3 "2019-05-03T16:59:46Z")

</div>

Yes that is correct. The behaviour is inconsistent. It is extracting them sometimes and other times it is not. It kind of depends on what the entities are. Some combinations are okay while some others are not and extract less than the total number of entities.

---

<div class="post-metadata">

**Author:** ![frankfcool](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/frankfcool/32/3907_2.png) [@frankfcool](https://forum.rasa.com/u/frankfcool)\
**Post date:** [August 7, 2019, 1:28am UTC](https://forum.rasa.com/t/detecting-multiple-entities-of-the-same-type/9208/5 "2019-08-07T01:28:43Z")

</div>

Have you got the answer how to fix this issue? I have the same issue but don’t know how to fix it.

---

<div class="post-metadata">

**Author:** ![pankti23](https://avatars.discourse-cdn.com/v4/letter/p/bc8723/32.png) [@pankti23](https://forum.rasa.com/u/pankti23)\
**Post date:** [January 7, 2020, 5:53am UTC](https://forum.rasa.com/t/detecting-multiple-entities-of-the-same-type/9208/6 "2020-01-07T05:53:40Z")

</div>

@spiralswimmer Have you found a solution to this yet? I am having a similar issue with certain pairs of entities are extracted but other are not.

---

<div class="post-metadata">

**Author:** ![mloubser](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mloubser/32/13021_2.png) [@mloubser](https://forum.rasa.com/u/mloubser)\
**Post date:** [March 18, 2020, 1:45am UTC](https://forum.rasa.com/t/detecting-multiple-entities-of-the-same-type/9208/7 "2020-03-18T01:45:59Z")

</div>

This sounds like a case where a [lookup table](https://rasa.com/docs/rasa/nlu/training-data-format/#lookup-tables) could be useful. Part of the problem with many entities in the same sentence like this is that the possible contexts for each entity are very many, and both sentence context and the word itself inform `CRFEntityExtractor` (\<Rasa1.7)/`DIETClassifier`(\>Rasa1.8) .

Also, in the case of numbers, you could use a pretrained extractor like `DucklingHTTPExtractor` or `SpacyEntityExtractor` instead, which should be a lot more accurate (with no requirement for training data). Same for other dimensions supported by duckling or spacy; if you can use them, it’s often more reliable than providing your own training data.
