Why can only the entities in the intent be recognized?

I am practicing setting the response with variables. Using the example of rasa init, I have modified the following places. The result is that the user input is exactly the same as the entities of the intent before it can be recognized. If it is not the same, it will be replaced by non.

my files: nlu.yml (1.5 KB) domain.yml (740 Bytes)

Hi @gerrycheung ,

I’m not sure I understand your question? Do you mean that the named entity recognition only works with the names “Gerry”, “Tom” and “Alice”, which are present in your NLU data?

The Named entity recognition “component” of the NLU model is trained on your training data, just like for intent classification. In your case, your model has been trained on just 3 examples of the entity name, which is very little. If you want it to perform better for something as diverse as name, you’ll have to include a lot more examples.

For something like name, I would probably choose to use a pre-trained entity extractor like Spacy for the entity PERSON.

Hope that helps

1 Like

Hi @E-dC , Many thanks. This is exactly my question. How can I set config.yml to use Spacy to extract name? Sorry, I’m new to rasa.

Thank you.

Hi,
Make sure Spacy is installed (Installation), then you’ll need to set SpacyNLP (Components) and SpacyEntityExtractor (Components) in the config.yml. It’ll look something like that:

pipeline:
- name: "SpacyNLP"
  # language model to load
  model: "en_core_web_md"
  case_sensitive: False
  # Maybe some other components...
- name: "SpacyEntityExtractor"
  # dimensions to extract
  dimensions: ["PERSON"]
  # Maybe some other components...

Then add the entity in your domain:

entities:
   - PERSON

If you want to use the entity in responses, you’ll have to define a slot, with its mappings. It’s good to read the relevant docs (Domain), it’s easy to get confused with them when first starting out :slight_smile:

Hope that helps

Thank you, @E-dC . I’ll try it.

Hi, E-dC I tried your method and it doesn’t seem to work.

pipeline:
  - name: SpacyNLP
    model: en_core_web_md
    case_sensitive: False
  - name: SpacyTokenizer
  - name: SpacyFeaturizer
#  - name: RegexFeaturizer
  - name: LexicalSyntacticFeaturizer
  - name: CountVectorsFeaturizer
  - name: CountVectorsFeaturizer
    analyzer: "char_wb"
    min_ngram: 1
    max_ngram: 4
  - name: "SpacyEntityExtractor"
    dimensions: ["PERSON"]
  - name: DIETClassifier
    epochs: 100
  - name: EntitySynonymMapper
  - name: ResponseSelector
    epochs: 100

This is my domain.yml

entities:
  - PERSON

slots:
  name:
    type: any
    influence_conversation: false
    mappings:
    - type: from_entity
      entity: PERSON

responses:
  utter_greet:
  - text: "Hey, {name}. How are you?"

Is it because the sample is too small, or is it some other reason?

Thank you.

@E-dC I tried it again just now. After using your method, there are no names in the training data, but common English names still work. Thank you!

1 Like