Choosing a Pipeline

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

The Short Answer

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

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:

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

Choosing the Right Components

There are components for entity extraction, for intent classification, response selection, pre-processing, and others. You can learn more about any specific component on the Components page.

A pipeline usually consists of three main parts:

Tokenization

For tokenization of English input, we recommend the ConveRTTokenizer. You can process other whitespace-tokenized (words are separated by spaces) languages with the WhitespaceTokenizer.

Featurization

You need to decide whether to use components that provide pre-trained word embeddings or not.

Pre-trained Embeddings

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. We support a few components that provide pre-trained word embeddings:

  1. MitieFeaturizer
  2. SpacyFeaturizer
  3. ConveRTFeaturizer
  4. LanguageModelFeaturizer

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 for intent classification and entity recognition and ResponseSelector for response selection.

Handling Class Imbalance

Classification algorithms often do not perform well if there is a large class imbalance. To mitigate this problem, you can use a balanced batching strategy.

language: "en"

pipeline:
  - name: "DIETClassifier"
    batch_strategy: sequence

Component Lifecycle

Each component processes an input and/or creates an output. The order of the components is determined by the order they are listed in the config.yml.