# How to exclude certain entities from DIETClassifier (or prioritise based on confidence)

**URL:** <https://forum.rasa.com/t/how-to-exclude-certain-entities-from-dietclassifier-or-prioritise-based-on-confidence/65225>\
**Category:** Rasa Open Source\
**Created:** [January 15, 2025, 12:31pm UTC](https://forum.rasa.com/t/how-to-exclude-certain-entities-from-dietclassifier-or-prioritise-based-on-confidence/65225 "2025-01-15T12:31:03Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![dahlia96](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/dahlia96/32/24942_2.png) [@dahlia96](https://forum.rasa.com/u/dahlia96)\
**Post date:** [January 15, 2025, 12:31pm UTC](https://forum.rasa.com/t/how-to-exclude-certain-entities-from-dietclassifier-or-prioritise-based-on-confidence/65225/1 "2025-01-15T12:31:03Z")

</div>

I am using RegexEntityExtractor to extract certain entities (amount / account\_number), but they end up going through DIETClassifier and I’m not sure why. Here is my regex / nlu.yml for amount:

```auto
 regex: amount
    examples: |
      - \b\d{1,6}(\.\d{1,2})?\b
  - intent: inform
    examples: |
      - [1,000](amount) [dólares]{"entity":"currency", "value":"USD"}

```

(plus more examples

Here is my regex / nlu.yml for account\_number:

```auto
nlu:
  - regex: account_number
    examples: |
      - (?=(?:\D*\d){7,18}\D*)([\d\s-]{7,40})
  - intent: inform
    examples: |
      - [2242171377602651](account_number)
      - [2334234324543243](account_number)

```

plus more examples.

The problem is that, certain messages like “my account number is 12345678” are not. being extracted via the Regex, but via the DIETClassifier?

this is part of my pipeline:

- name: RegexFeaturizer case\_sensitive: true use\_word\_boundaries: true
- name: LexicalSyntacticFeaturizer
- name: CountVectorsFeaturizer
- name: CountVectorsFeaturizer analyzer: word
- name: RegexEntityExtractor case\_sensitive: false use\_lookup\_tables: true use\_regexes: true use\_word\_boundaries: true confidence: 1.0
- name: DIETClassifier constrain\_similarities: true excluded\_entities:
  - amount
  - account\_number

What am i doing wrong? why are messages that contain the regex, end up going to the DIETClassifier instead of the regex? For context, what I want to achieve is:

1. Try the regex. if it finds something, take that as the entity.
2. If not, go through the DIETClassifier. I thought Rasa already by default picks the higher confidence extraction between regex and DIET, but it seems the regex isn’t even working in the first place?

---

_[View the full topic](https://forum.rasa.com/t/how-to-exclude-certain-entities-from-dietclassifier-or-prioritise-based-on-confidence/65225)._
