# Components

Note

For clarity, we have renamed the pre-defined pipelines to reflect what they _do_ rather than which libraries they use as of Rasa NLU 0.15. The `tensorflow_embedding` pipeline is now called `supervised_embeddings`, and `spacy_sklearn` is now known as `pretrained_embeddings_spacy`. Please update your code if you are using these.

This is a reference of the configuration options for every built-in component in Rasa NLU. If you want to build a custom component, check out [Custom NLU Components](https://legacy-docs-v1.rasa.com/1.6.2/api/custom-nlu-components/#custom-nlu-components).

## Word Vector Sources

### [MitieNLP](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#mitienlp)  
**Short**
MITIE initializer

**Outputs**
nothing

**Requires**
nothing

**Description**
Initializes mitie structures. Every mitie component relies on this, hence this should be put at the beginning of every pipeline that uses any mitie components.

**Configuration**
```yaml
pipeline:
- name: "MitieNLP"
  # language model to load
  model: "data/total_word_feature_extractor.dat"
```

For more information where to get that file from, head over to [installing MITIE](https://legacy-docs-v1.rasa.com/1.6.2/user-guide/installation/#install-mitie).

### [SpacyNLP](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#spacynlp)  
**Short**
spacy language initializer

**Outputs**
nothing

**Requires**
nothing

**Description**
Initializes spacy structures. Every spacy component relies on this, hence this should be put at the beginning of every pipeline that uses any spacy components.

**Configuration**
```yaml
pipeline:
- name: "SpacyNLP"
  # language model to load
  model: "en_core_web_md"

# when retrieving word vectors, this will decide if the casing
  # of the word is relevant. E.g. `hello` and `Hello` will
  # retrieve the same vector, if set to `false`. For some
  # applications and models it makes sense to differentiate
  # between these two words, therefore setting this to `true`.
  case_sensitive: false
```

## Text Featurizers

### [MitieFeaturizer](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#mitiefeaturizer)  
**Short**
MITIE intent featurizer

**Outputs**
nothing, used as an input to intent classifiers that need intent features (e.g. `SklearnIntentClassifier`)

**Requires**
[MitieNLP](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#mitienlp)

**Type**
Dense featurizer

**Description**
Creates features for intent classification using the MITIE featurizer.

**Note**
NOT used by the `MitieIntentClassifier` component. Currently, only `SklearnIntentClassifier` is able to use precomputed features.

**Configuration**
```yaml
pipeline:
- name: "MitieFeaturizer"
```

### [SpacyFeaturizer](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#spacyfeaturizer)  
**Short**
spacy intent featurizer

**Outputs**
nothing, used as an input to intent classifiers that need intent features (e.g. `SklearnIntentClassifier`)

**Requires**
[SpacyNLP](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#spacynlp)

**Type**
Dense featurizer

**Description**
Creates features for intent classification using the spacy featurizer.

**Configuration**
```yaml
pipeline:
- name: "SpacyFeaturizer"
```

### [ConveRTFeaturizer](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#convertfeaturizer)  
**Short**
Creates a vector representation of user message and response (if specified) using
[ConveRT](https://github.com/PolyAI-LDN/polyai-models) model.

**Outputs**
nothing, used as an input to intent classifiers and response selectors that need intent features and response features respectively (e.g. `EmbeddingIntentClassifier` and `ResponseSelector`)

**Requires**
nothing

**Type**
Dense featurizer

**Description**
Creates features for intent classification and response selection.
Uses the [default signature](https://github.com/PolyAI-LDN/polyai-models#tfhub-signatures) to compute vector representations of input text.

**Warning**
Since `ConveRT` model is trained only on an english corpus of conversations, this featurizer should only be used if your training data is in english language.

**Configuration**
```yaml
pipeline:
- name: "ConveRTFeaturizer"
```

## Intent Classifiers

### [MitieIntentClassifier](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#mitieintentclassifier)  
**Short**
MITIE intent classifier (using a
[text categorizer](https://github.com/mit-nlp/MITIE/blob/master/examples/python/text_categorizer_pure_model.py))

**Outputs**
`intent`

**Requires**
A tokenizer and a featurizer

**Output-Example**
```json
{
    "intent": {"name": "greet", "confidence": 0.98343}
}
```

**Description**
This classifier uses MITIE to perform intent classification. The underlying classifier is using a multi-class linear SVM with a sparse linear kernel (see
[MITIE trainer code](https://github.com/mit-nlp/MITIE/blob/master/mitielib/src/text_categorizer_trainer.cpp#L222)).

**Configuration**
```yaml
pipeline:
- name: "MitieIntentClassifier"
```

### [SklearnIntentClassifier](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#sklearnintentclassifier)  
**Short**
sklearn intent classifier

**Outputs**
`intent` and `intent_ranking`

**Requires**
A featurizer

**Output-Example**
```json
{
    "intent": {"name": "greet", "confidence": 0.78343},
    "intent_ranking": [
        {
            "confidence": 0.1485910906220309,
            "name": "goodbye"
        },
        {
            "confidence": 0.08161531595656784,
            "name": "restaurant_search"
        }
    ]
}
```

**Description**
The sklearn intent classifier trains a linear SVM which gets optimized using a grid search. In addition to other classifiers it also provides rankings of the labels that did not “win”. The spacy intent classifier needs to be preceded by a featurizer in the pipeline. This featurizer creates the features used for the classification.

**Configuration**
```yaml
pipeline:
- name: "SklearnIntentClassifier"
  # Specifies the list of regularization values to
  # cross-validate over for C-SVM.
  # This is used with the ``kernel`` hyperparameter in GridSearchCV.
  C: [1, 2, 5, 10, 20, 100]
  # Specifies the kernel to use with C-SVM.
  # This is used with the ``C`` hyperparameter in GridSearchCV.
  kernels: ["linear"]
```

### [EmbeddingIntentClassifier](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#embeddingintentclassifier)  
**Short**
Embedding intent classifier

**Outputs**
`intent` and `intent_ranking`

**Requires**
A featurizer

**Output-Example**
```json
{
    "intent": {"name": "greet", "confidence": 0.8343},
    "intent_ranking": [
        {
            "confidence": 0.385910906220309,
            "name": "goodbye"
        },
        {
            "confidence": 0.28161531595656784,
            "name": "restaurant_search"
        }
    ]
}
```

**Description**
The embedding intent classifier embeds user inputs and intent labels into the same space.
Supervised embeddings are trained by maximizing similarity between them.
This algorithm is based on [StarSpace](https://arxiv.org/abs/1709.03856).
However, in this implementation the loss function is slightly different and additional hidden layers are added together with dropout.
This algorithm also provides similarity rankings of the labels that did not “win”.
The embedding intent classifier needs to be preceded by a featurizer in the pipeline. This featurizer creates the features used for the embeddings.

**Configuration**
```yaml
pipeline:
- name: "EmbeddingIntentClassifier"
```

## Entity Extractors

### [MitieEntityExtractor](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#mitieentityextractor)  
**Short**
MITIE entity extraction (using a [MITIE NER trainer](https://github.com/mit-nlp/MITIE/blob/master/mitielib/src/ner_trainer.cpp))

**Outputs**
appends `entities`

**Requires**
[MitieNLP](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#mitienlp)

**Output-Example**
```json
{
    "entities": [{"value": "New York City",
                  "start": 20,
                  "end": 33,
                  "confidence": null,
                  "entity": "city",
                  "extractor": "MitieEntityExtractor"}]
}
```

**Description**
This uses the MITIE entity extraction to find entities in a message. The underlying classifier is using a multi class linear SVM with a sparse linear kernel and custom features.
The MITIE component does not provide entity confidence values.

**Configuration**
```yaml
pipeline:
- name: "MitieEntityExtractor"
```

### [SpacyEntityExtractor](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#spacyentityextractor)  
**Short**
spaCy entity extraction

**Outputs**
appends `entities`

**Requires**
[SpacyNLP](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#spacynlp)

**Output-Example**
```json
{
    "entities": [{"value": "New York City",
                  "start": 20,
                  "end": 33,
                  "entity": "city",
                  "confidence": null,
                  "extractor": "SpacyEntityExtractor"}]
}
```

**Description**
Using spaCy this component predicts the entities of a message. spaCy uses a statistical BILOU transition model.
As of now, this component can only use the spaCy builtin entity extraction models and can not be retrained.
This extractor does not provide any confidence scores.

**Configuration**
```yaml
pipeline:
- name: "SpacyEntityExtractor"
  # dimensions to extract
  dimensions: ["PERSON", "LOC", "ORG", "PRODUCT"]
```

### [EntitySynonymMapper](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#entitysynonymmapper)  
**Short**
Maps synonymous entity values to the same value.

**Outputs**
modifies existing entities that previous entity extraction components found

**Requires**
nothing

**Description**
If the training data contains defined synonyms (by using the `value` attribute on the entity examples).
this component will make sure that detected entity values will be mapped to the same value.

### [CRFEntityExtractor](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#crfentityextractor)  
**Short**
conditional random field entity extraction

**Outputs**
appends `entities`

**Requires**
A tokenizer

**Output-Example**
```json
{
    "entities": [{"value":"New York City",
                  "start": 20,
                  "end": 33,
                  "entity": "city",
                  "confidence": 0.874,
                  "extractor": "CRFEntityExtractor"}]
}
```

**Description**
This component implements conditional random fields to do named entity recognition.
CRFs can be thought of as an undirected Markov chain where the time steps are words and the states are entity classes. 
If POS features are used (pos or pos2), spaCy has to be installed.

**Configuration**
```yaml
pipeline:
- name: "CRFEntityExtractor"
  # The features are a ``[before, word, after]`` array with
  # before, word, after holding keys about which
  # features to use for each word, for example, ``"title"``
  features: [["low", "title"], ["bias", "suffix3"], ["upper", "pos", "pos2"]]

# The flag determines whether to use BILOU tagging or not.
  # BILOU tagging is more rigorous however
  # requires more examples per entity. Rule of thumb: use only
  # if more than 100 examples per entity.
  BILOU_flag: true

# This is the value given to sklearn_crfcuite.CRF tagger before training.
  max_iterations: 50

# This is the value given to sklearn_crfcuite.CRF tagger before training.
  # Specifies the L1 regularization coefficient.
  L1_c: 0.1

# This is the value given to sklearn_crfcuite.CRF tagger before training.
  # Specifies the L2 regularization coefficient.
  L2_c: 0.1
```

### [DucklingHTTPExtractor](https://legacy-docs-v1.rasa.com/1.6.2/nlu/components/#ducklinghttpextractor)  
**Short**
Duckling lets you extract common entities like dates,
amounts of money, distances, and others in a number of languages.

**Outputs**
appends `entities`

**Requires**
nothing

**Output-Example**
```json
{
    "entities": [{"end": 53,
                  "entity": "time",
                  "start": 48,
                  "value": "2017-04-10T00:00:00.000+02:00",
                  "confidence": 1.0,
                  "extractor": "DucklingHTTPExtractor"}]
}
```

**Description**
To use this component you need to run a duckling server.
