UserWarning: Entity entity 'cheque_number' has only 1 training examples! The minimum is 2, because of this the training may fail

Hi, I am facing the above warning from RASA while training my model. I don’t have any idea how should I fix this. Note: I am creating a chatbot for English and another for Bangla language. However, I am not getting this warning for the english model. I am using DIETClassifier for entity extraction. In nlu.yml, I have almost 60 examples for this particular entity. Hope to get an answer soon from you guys and perdon my English (English is not my mother tongue). Here is my config.yml file:

version: "2.0"
    language: en
    pipeline:
      - name: WhitespaceTokenizer
      - name: RegexFeaturizer #RegexEntityExtractor the name of the regular expression should match the name of the entity you want to extract.
      - name: LexicalSyntacticFeaturizer
      - name: CountVectorsFeaturizer
      - name: CountVectorsFeaturizer
        analyzer: "char_wb"
        min_ngram: 1
        max_ngram: 4
      - name: DIETClassifier
        epochs: 100
      - name: FallbackClassifier
        threshold: 0.7
      - name: DucklingEntityExtractor
        url: http://localhost:8000
        dimensions:
        - amount-of-money
        - time
        - number
      - name: SpacyNLP
        model: "en_core_web_md"
        case_sensitive: false
      - name: "SpacyEntityExtractor"
        # Note: It is not possible to use the SpacyTokenizer + SpacyFeaturizer in 
        #       combination with the WhitespaceTokenizer, and as a result the
        #       PERSON extraction by Spacy is not very robust.
        #       Because of this, the nlu training data is annotated as well, and the
        #       DIETClassifier will also extract PERSON entities.
        dimensions: ["USERNAME"] #Replaced PERSON to USERNAME (by Rifat)
      - name: EntitySynonymMapper
    policies:
    - name: AugmentedMemoizationPolicy
    - name: TEDPolicy
      epochs: 40
    - name: RulePolicy
      core_fallback_threshold: 0.4
      core_fallback_action_name: "action_default_fallback"
      enable_fallback_prediction: True

I have already check the existing questions and answer but I think those are not answer my problem.

@Rifat Hi, Please provide more training examples for cheque_number, as the error saying it has only 1 training example, but its should have more the 2 or max at least 10 examples for the same.

@Rifat You another question regarding Bangla language chatbot using spacy, please check this link for supported languages https://spacy.io/models

@Rifat Even increased the TEDPolicy epochs to 100

Please delete all the older trained model and re-train it again.

I hope this will help you to solve your issue. Good Luck!

Hi, I have provided 60 training examples for cheque_number. But, still it’s not working and I have trained it by deleting all the older trained models too. No improvement at all. The full warning is

/home/financial_demo_ban/financial_demo_ban/ban_env/lib/python3.7/site-packages/rasa/shared/utils/io.py:97: UserWarning: Entity entity ‘cheque_number’ has only 1 training examples! The minimum is 2, because of this the training may fail.

@Rifat share me the nlu file or training example for this ‘cheque_number’

Here it is:

- intent: stop_cheque
  examples: |
    - cancel my cheque
    - stop cheque
    - confiscate my cheque
    - my cheque number is [65988745] (cheque_number), stop this
    - my cheque number is [65879745] (cheque_number), I want to cancel it
    - my cheque is [65879745] (cheque_number), prevent it
    - i want to cancel my cheque
    - need to cancel cheque

- intent: inform
  example: |
     - [87421545](cheque_number) cheque number
    - [10000](amount-of-money)
    - [65988745] (cheque_number)
    - my cheque number is [65988895] (cheque_number)
    - cheque number is [12786534](cheque_number)
    - cheque number [65988525] (cheque_number)
    - [65988545] (cheque_number)
    - [65999525] (cheque_number)
    - [69899525] (cheque_number)
    - [87215698] (cheque_number)
    - [32564578] (cheque_number)
    - [65985645] (cheque_number)
    - [23568954] (cheque_number)
    - [12657815] (cheque_number)
    - [59152648] (cheque_number)
    - [75356842] (cheque_number)
    - [42869137] (cheque_number)
    - [45698752] (cheque_number)
    - [12345987] (cheque_number)
    - [12356987] (cheque_number)
    - [45632541] (cheque_number)
    - [12398746] (cheque_number)
    - [65894231] (cheque_number)
    - [59875462] (cheque_number)
    - [45698524] (cheque_number)
    - [53795186] (cheque_number)
    - [95731462] (cheque_number)
    - [98756245] (cheque_number)
    - [59152648] (cheque_number)
    - cheque number [75356842] (cheque_number)
    - [42869137] (cheque_number) is the cheque number
    - cheque number [45698752] (cheque_number)
    - cheque number [12345987] (cheque_number)
    - cheque number [12356987] (cheque_number)
    - cheque number [45632541] (cheque_number)
    - [12398746] (cheque_number) is the cheque number
    - [65894231] (cheque_number) is the cheque number
    - [59875462] (cheque_number) is the cheque number
    - [45698524] (cheque_number) is the cheque number
    - [15548755] (cheque_number) cheque number
    - [32625356] (cheque_number) cheque number
    - [95865748] (cheque_number) cheque number
    - [12546546] (cheque_number)
    - [56644654] (cheque_number)
    - [45654654] (cheque_number)
    - [65465465] (cheque_number)
    - [46565231] (cheque_number)
    - [46587978] (cheque_number)
    - [78978965] (cheque_number)
    - [78546462] (cheque_number)
    - [78978978] (cheque_number)
    - [46545645] (cheque_number)
    - [46578978] (cheque_number)
    - [78978979] (cheque_number)
    - [98634565] (cheque_number)
    - [45678997] (cheque_number)
    - [12245643] (cheque_number)
    - [74158258] (cheque_number)
    - [78963217] (cheque_number)
    - [32598845] (cheque_number)
    - [21545989] (cheque_number)
    - [12356456] (cheque_number)
    - [45454545] (cheque_number)
    - [78787878] (cheque_number)

You need to remove the spaces between the number and the entity name :slight_smile:

[65988745] (cheque_number) --> [65988745](cheque_number)

You can see that only the first example in inform has no space between them, and this is the one the errors talks about.

Be glad you did it correctly only once! If you did it twice, there would have been no error!


By the way, I suggest using Regular Expressions for Entity Extraction since cheque_number is always an 8-digit number.

You will still need to provide 2 examples at least.

nlu:
- regex: cheque_number
  examples: |
    - \d{8}

- intent: inform
  example: |
    - [87421545](cheque_number) cheque number
    - [10000](amount-of-money)
    - my cheque number is [65988895](cheque_number)

If you don’t know Regex, you can learn it here.

As suggested by Chris, you need to follow the proper syntax for examples.

As your error showing ‘cheque_number’ has 1 training examples its because you only mention one example in proper syntax i.e

- intent: inform
  example: |
     - [87421545](cheque_number) cheque number

And, there is no further matching syntax, so you getting the above error.

But, it should have at least 2 minimum examples.

I hope you understand your error and as you update the error should gone. Good Luck!

Hi @nik202 and @ChrisRahme, Thanks for your help. And it is working perfectly. :heart_eyes:

1 Like

@Rifat Congratulations, and please close this thread as a solution for others; good luck!