# Choosing a Pipeline

In Rasa Open Source, incoming messages are processed by a sequence of components. These components are executed one after another in a so-called processing `pipeline` defined in your `config.yml`. Choosing an NLU pipeline allows you to customize your model and finetune it on your dataset.

- [How to Choose a Pipeline](https://legacy-docs-v1.rasa.com/1.10.0/nlu/choosing-a-pipeline/#how-to-choose-a-pipeline)

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

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

- [Choosing the Right Components](https://legacy-docs-v1.rasa.com/1.10.0/nlu/choosing-a-pipeline/#choosing-the-right-components)

- [Multi-Intent Classification](https://legacy-docs-v1.rasa.com/1.10.0/nlu/choosing-a-pipeline/#multi-intent-classification)
- [Comparing Pipelines](https://legacy-docs-v1.rasa.com/1.10.0/nlu/choosing-a-pipeline/#comparing-pipelines)

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

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

- [Pipeline Templates (deprecated)](https://legacy-docs-v1.rasa.com/1.10.0/nlu/choosing-a-pipeline/#pipeline-templates-deprecated)

## How to Choose a Pipeline

### The Short Answer

If your training data is in English, a good starting point is the following pipeline:

```yaml
language: "en"

pipeline:
  - name: ConveRTTokenizer
  - name: ConveRTFeaturizer
  - name: RegexFeaturizer
  - name: LexicalSyntacticFeaturizer
  - name: CountVectorsFeaturizer
  - name: CountVectorsFeaturizer
    analyzer: "char_wb"
    min_ngram: 1
    max_ngram: 4
  - name: DIETClassifier
    epochs: 100
  - name: EntitySynonymMapper
  - name: ResponseSelector
    epochs: 100
```

If your training data is not in English, start with the following pipeline:

```yaml
language: "fr"  # your two-letter language code

pipeline:
  - name: WhitespaceTokenizer
  - name: RegexFeaturizer
  - name: LexicalSyntacticFeaturizer
  - name: CountVectorsFeaturizer
  - name: CountVectorsFeaturizer
    analyzer: "char_wb"
    min_ngram: 1
    max_ngram: 4
  - name: DIETClassifier
    epochs: 100
  - name: EntitySynonymMapper
  - name: ResponseSelector
    epochs: 100
```

### A Longer Answer

We recommend using the following pipeline if your training data is in English:

```yaml
language: "en"

The pipeline contains the [ConveRTFeaturizer](https://legacy-docs-v1.rasa.com/1.10.0/nlu/components/#convertfeaturizer) that provides pre-trained word embeddings of the user utterance. Pre-trained word embeddings are helpful as they already encode some kind of linguistic knowledge.

If your training data is not in English, but you still want to use pre-trained word embeddings, we recommend using the following pipeline:

```yaml
language: "fr"  # your two-letter language code

pipeline:
  - name: SpacyNLP
  - name: SpacyTokenizer
  - name: SpacyFeaturizer
  - name: RegexFeaturizer
  - name: LexicalSyntacticFeaturizer
  - name: CountVectorsFeaturizer
  - name: CountVectorsFeaturizer
    analyzer: "char_wb"
    min_ngram: 1
    max_ngram: 4
  - name: DIETClassifier
    epochs: 100
  - name: EntitySynonymMapper
  - name: ResponseSelector
    epochs: 100
```

### Choosing the Right Components

There are components for entity extraction, intent classification, response selection, pre-processing, and others. A pipeline usually consists of three main parts:

- [Tokenization](https://legacy-docs-v1.rasa.com/1.10.0/nlu/choosing-a-pipeline/#tokenization)
- [Featurization](https://legacy-docs-v1.rasa.com/1.10.0/nlu/choosing-a-pipeline/#featurization)
- [Entity Recognition / Intent Classification / Response Selectors](https://legacy-docs-v1.rasa.com/1.10.0/nlu/choosing-a-pipeline/#entity-recognition-intent-classification-response-selectors)

### Tokenization

For tokenization of English input, we recommend the [ConveRTTokenizer](https://legacy-docs-v1.rasa.com/1.10.0/nlu/components/#converttokenizer).

### Featurization

You need to decide whether to use components that provide pre-trained word embeddings or not. The advantage of using pre-trained word embeddings in your 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.

### Entity Recognition / Intent Classification / Response Selectors

Depending on your data, you may want to only perform intent classification, entity recognition, or response selection. We recommend using [DIETClassifier](https://legacy-docs-v1.rasa.com/1.10.0/nlu/components/#diet-classifier) for intent classification and entity recognition and [ResponseSelector](https://legacy-docs-v1.rasa.com/1.10.0/nlu/components/#response-selector) for response selection.

### Multi-Intent Classification

You can use Rasa Open Source components to split intents into multiple labels.

## Comparing Pipelines

Rasa gives you the tools to compare the performance of multiple pipelines on your data directly. See [Comparing NLU Pipelines](https://legacy-docs-v1.rasa.com/1.10.0/user-guide/testing-your-assistant/#comparing-nlu-pipelines) for more information.

### Handling Class Imbalance

To mitigate the problem of class imbalance, you can use 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, still mimicking the fact that some classes are more frequent than others. Balanced batching is used by default.

### Component Lifecycle

Each component processes input and/or creates output. The order of the components is determined by the order they are listed in the `config.yml`; the output of a component can be used by any other component that comes after it in the pipeline.
