# Choosing a Pipeline

Choosing an NLU pipeline allows you to customize your model and finetune it on your dataset.

## [The Short Answer](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#the-short-answer)

If you have less than 1000 total training examples, and there is a spaCy model for your language, use the `pretrained_embeddings_spacy` pipeline:

```
language: "en"

pipeline: "pretrained_embeddings_spacy"
```

If you have 1000 or more labelled utterances, use the `supervised_embeddings` pipeline:

```
language: "en"

pipeline: "supervised_embeddings"
```

## [A Longer Answer](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#a-longer-answer)

The two most important pipelines are `supervised_embeddings` and `pretrained_embeddings_spacy`. The biggest difference between them is that the `pretrained_embeddings_spacy` pipeline uses pre-trained word vectors from either GloVe or fastText. The `supervised_embeddings` pipeline, on the other hand, doesn’t use any pre-trained word vectors, but instead fits these specifically for your dataset.

### [pretrained_embeddings_spacy](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#pretrained-embeddings-spacy)

The advantage of the `pretrained_embeddings_spacy` pipeline is that if you have a training example like: “I want to buy apples”, and Rasa is asked to predict the intent for “get pears”, your model already knows that the words “apples” and “pears” are very similar. This is especially useful if you don’t have very much training data.

### [supervised_embeddings](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#supervised-embeddings)

The advantage of the `supervised_embeddings` pipeline is that your word vectors will be customised for your domain. For example, in general English, the word “balance” is closely related to “symmetry”, but very different to the word “cash”. In a banking domain, “balance” and “cash” are closely related and you’d like your model to capture that. This pipeline doesn’t use a language-specific model, so it will work with any language that you can tokenize (on whitespace or using a custom tokenizer).

### [MITIE](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#mitie)

You can also use MITIE as a source of word vectors in your pipeline. The MITIE backend performs well for small datasets, but training can take very long if you have more than a couple of hundred examples. However, we do not recommend that you use it as mitie support is likely to be deprecated in a future release.

### [Comparing different pipelines for your data](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#comparing-different-pipelines-for-your-data)

Rasa gives you the tools to compare the performance of both of these pipelines on your data directly. Intent classification is independent of entity extraction. So sometimes NLU will get the intent right but entities wrong, or the other way around. You need to provide enough data for both intents and entities.

## [Class imbalance](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#class-imbalance)

Classification algorithms often do not perform well if there is a large class imbalance, for example if you have a lot of training data for some intents and very little training data for others. To mitigate this problem, rasa’s `supervised_embeddings` pipeline uses a `balanced` batching strategy. This algorithm ensures that all classes are represented in every batch, or at least in as many subsequent batches as possible. Balanced batching is used by default. In order to turn it off and use a classic batching strategy include `batch_strategy: sequence` in your config file.

```
language: "en"

pipeline:
- name: "CountVectorsFeaturizer"
- name: "EmbeddingIntentClassifier"
  batch_strategy: sequence
```

## [Multiple Intents](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#multiple-intents)

If you want to split intents into multiple labels, e.g. for predicting multiple intents or for modeling hierarchical intent structure, you can only do this with the supervised embeddings pipeline.

## [Understanding the Rasa NLU Pipeline](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#understanding-the-rasa-nlu-pipeline)

In Rasa NLU, incoming messages are processed by a sequence of components. These components are executed one after another in a so-called processing pipeline. Each component processes the input and creates an output. The output can be used by any component that comes after this component in the pipeline.

## [Component Lifecycle](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#component-lifecycle)

Every component can implement several methods from the `Component` base class; in a pipeline these different methods will be called in a specific order.

## [The “entity” object explained](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#the-entity-object-explained)

After parsing, the entity is returned as a dictionary. There are two fields that show information about how the pipeline impacted the entities returned: the `extractor` field of an entity tells you which entity extractor found this particular entity, and the `processors` field contains the name of components that altered this specific entity.

## [Pre-configured Pipelines](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#pre-configured-pipelines)

A template is just a shortcut for a full list of components. Below is a list of all the pre-configured pipeline templates with customization information.

### [supervised_embeddings](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#section-supervised-embeddings-pipeline)

To train a Rasa model in your preferred language, define the `supervised_embeddings` pipeline as your pipeline in your `config.yml` or other configuration file:

```
language: "en"

pipeline: "supervised_embeddings"
```

### [pretrained_embeddings_spacy](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#section-pretrained-embeddings-spacy-pipeline)

To use the `pretrained_embeddings_spacy` template:

```
language: "en"

pipeline: "pretrained_embeddings_spacy"
```

### [MITIE](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#section-mitie-pipeline)

To use the MITIE pipeline, you will have to train word vectors from a corpus.

### [Custom pipelines](https://legacy-docs-v1.rasa.com/1.4.6/nlu/choosing-a-pipeline/#custom-pipelines)

You don’t have to use a template, you can also run a fully custom pipeline by listing the names of the components you want to use:

```
pipeline:
- name: "SpacyNLP"
- name: "CRFEntityExtractor"
- name: "EntitySynonymMapper"
```

👋 I can help you get started with Rasa and answer your technical questions.
