Entity are not detected by DIET


I have run rasa init and I added a few sentences into an intent named ask-want-drink. I added some entities named entity_drink. However, the result JSON array is always empty.

Here is my files:


recipe: default.v1
assistant_id: 20230407-124154-honest-gulch
language: en
# # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
# # If you'd like to customize it, uncomment and adjust the pipeline.
# # See https://rasa.com/docs/rasa/tuning-your-model for more information.
  - name: WhitespaceTokenizer
  - name: RegexFeaturizer
  - name: LexicalSyntacticFeaturizer
  - name: CountVectorsFeaturizer
  - name: CountVectorsFeaturizer
    analyzer: char_wb
    min_ngram: 1
    max_ngram: 4
  - name: DIETClassifier
    epochs: 100
    constrain_similarities: true
    entity_recognition: true
  - name: EntitySynonymMapper
  - name: ResponseSelector
    epochs: 100
    constrain_similarities: true
  - name: FallbackClassifier
    threshold: 0.3
    ambiguity_threshold: 0.1
# # No configuration for policies was provided. The following default policies were used to train your model.
# # If you'd like to customize them, uncomment and adjust the policies.
# # See https://rasa.com/docs/rasa/policies for more information.
  - name: MemoizationPolicy
  - name: RulePolicy
  - name: UnexpecTEDIntentPolicy
    max_history: 5
    epochs: 100
  - name: TEDPolicy
    max_history: 5
    epochs: 100
    constrain_similarities: true


version: "3.1"

  - greet
  - goodbye
  - affirm
  - deny
  - mood_great
  - mood_unhappy
  - bot_challenge
  - ask-want-drink:
        - entity_drink

  - text: "Hey! How are you?"

  - text: "Here is something to cheer you up:"
    image: "https://i.imgur.com/nGF1K8f.jpg"

  - text: "Did that help you?"

  - text: "Great, carry on!"

  - text: "Bye"

  - text: "I am a bot, powered by Rasa."

  session_expiration_time: 60
  carry_over_slots_to_new_session: true

  - entity_drink

nlu.yml (I only added an intent, the rest is as generated rasa init).

version: "3.1"


- intent: ask-want-drink
  examples: |
    - I like (schweppes){"entity":"entity_drink", "value":"schweppes"}, give me
    - I would like a (schweppes){"entity":"entity_drink", "value":"schweppes"}
    - I want to drink (schweppes){"entity":"entity_drink", "value":"schweppes"}
    - please give me a (schweppes){"entity":"entity_drink", "value":"schweppes"} drink
    - please (oasis){"entity":"entity_drink", "value":"oasis"}
    - I want to drink (7up){"entity":"entity_drink", "value":"7up"}
    - can I have a (perrier){"entity":"entity_drink", "value":"perrier"}
    - pass me the (badoit){"entity":"entity_drink", "value":"badoit"}
    - give (tea){"entity":"entity_drink", "value":"tea"}}
    - please give (sprite){"entity":"entity_drink", "value":"sprite"}
    - give me (water){"entity":"entity_drink", "value":"water"}

stories.yml (Likewise, I only added this story into stories.yml)

- story: want a drink path
  - intent: ask-want-drink
  - action: utter_goodbye

e.g, when sending the following sentences:

I want to drink schweppes

my entities array is always empty as follows:

    "text": "I want to drink schweppes",
    "intent": {
        "name": "ask-want-drink",
        "confidence": 0.9999985694885254
    "entities": [],
    "text_tokens": [
    "intent_ranking": [
            "name": "ask-want-drink",
            "confidence": 0.9999985694885254
            "name": "bot_challenge",
            "confidence": 5.609626896330155e-7
            "name": "affirm",
            "confidence": 3.2016720297178836e-7
            "name": "deny",
            "confidence": 2.465369561832631e-7
            "name": "mood_unhappy",
            "confidence": 1.1073560557406381e-7
            "name": "mood_great",
            "confidence": 7.839430793410429e-8
            "name": "goodbye",
            "confidence": 6.600657087574291e-8
            "name": "greet",
            "confidence": 8.942786067223096e-9
    "response_selector": {
        "all_retrieval_intents": [],
        "default": {
            "response": {
                "responses": null,
                "confidence": 0.0,
                "intent_response_key": null,
                "utter_action": "utter_None"
            "ranking": []

Please let me know how to fix this, and eventually if something is made wrong. Thank you!


I would suggest trying any one of the two fixes.

  1. Try adding CRF entity extractor to your pipeline, and retrain the model.
  2. Try to increase the epochs of diet classifier to say 200 and retain the model.


Hello, thank you for your answer. I have set the epochs to 200 and added the CRFEntityExtractor as you have mentioned it in my config.yml as follows:

- name: "CRFEntityExtractor"
    # BILOU_flag determines whether to use BILOU tagging or not.
    "BILOU_flag": True
    # features to extract in the sliding window
    "features": [
      ["low", "title", "upper"],
      ["low", "title", "upper"],
    # The maximum number of iterations for optimization algorithms.
    "max_iterations": 50
    # weight of the L1 regularization
    "L1_c": 0.1
    # weight of the L2 regularization
    "L2_c": 0.1
    # Name of dense featurizers to use.
    # If list is empty all available dense features are used.
    "featurizers": []
    # Indicated whether a list of extracted entities should be split into individual entities for a given entity type
      address: False
      email: True

It is as given in my docs. I likewise tested this:

- name: "CRFEntityExtractor"

However I am now facing a Failed to load CRFEntityExtractor from model storage. Resource 'train_CRFEntityExtractor9' doesn't exist. when running rasa run. As far as I know, there is no model to import according to the docs. Is there something I am still missing?

@jiji Did you retrained a new model after updating the config.yml ? If not, Please train a new model and try again.


Yes I did train the model. It seems like my component CRFEntityExtractor is not training because no loading is shown when executing rasa train --force. My number of epochs are 300.

Here is a screenshot:


Entity Annotation of looks incorrect. - pass me the (badoit){“entity”:“entity_drink”, “value”:“badoit”}

Entity should be within square brackets [badoit]

This particular line has to 2 ending brackets. - give (tea){"entity":"entity_drink", "value":"tea"}}

Please correct these and give a try.


Thank you, indeed the Entity Annotation was wrong, I used (name)[entity] instead of [name](entity). This fixed my problem.