# Replacing the NLU Pipeline by a custom Interpreter in Rasa 2.0

**URL:** <https://forum.rasa.com/t/replacing-the-nlu-pipeline-by-a-custom-interpreter-in-rasa-2-0/36695>\
**Category:** Rasa Open Source\
**Created:** [November 5, 2020, 6:25pm UTC](https://forum.rasa.com/t/replacing-the-nlu-pipeline-by-a-custom-interpreter-in-rasa-2-0/36695 "2020-11-05T18:25:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![slapierre](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/slapierre/32/11616_2.png) [@slapierre](https://forum.rasa.com/u/slapierre)\
**Post date:** [November 5, 2020, 6:25pm UTC](https://forum.rasa.com/t/replacing-the-nlu-pipeline-by-a-custom-interpreter-in-rasa-2-0/36695/1 "2020-11-05T18:25:55Z")

</div>

Hello,

I am seeking your advice on how to replace the NLU pipeline in Rasa 2.0 and on an “interpreter injection” concern I noticed during the training phase.

First, let’s discuss the discrepancy between `rasa train core` and `rasa shell`.

The startup sequence of `rasa train core` and `rasa shell` is different: when running `rasa shell` the [create\_interpreter factory function](https://github.com/RasaHQ/rasa/blob/master/rasa/core/interpreter.py#L23) is called before the agent is created, the factory uses the `EndpointConfig` (from endpoints.yml) to instantiate our custom interpreter and forwards that interpreter to the Agent. When running `rasa train core`, the creation of the interpreter is delegated to the Agent, the `EndpointConfig` parameter is not forwarded to the Agent’s contructor, the Agent calls the factory and gets a RegexInterpreter.

My concern is that the [RegexInterpreter.featurize\_message](https://github.com/RasaHQ/rasa/blob/master/rasa/shared/nlu/interpreter.py#L29) method function would be called during policy training instead of our own featurization function. For now the `RegexInterpreter.featurize_message` “does nothing” so there would not be a mismatch in the featurization.

Please let me know what you think: from my perspective, the startup sequence of `rasa train` needs to be updated to allow instantiating a custom NLU (or a RasaNLUHttpInterpreter) to make sure that the core featurization introduced in [New core featurization #6296](https://github.com/RasaHQ/rasa/pull/6296) uses _the right interpreter_ when featurizing instead of RegexInterpreter’s featurization function.

- I found out that this major refactoring is in progress: [Refactor Agent / Processor / TrackerStore #5257](https://github.com/RasaHQ/rasa/issues/5257), so perhaps the “interpreter injection” concern I am raising will be addressed in-or-around this issue and for the moment I can experiment with my custom interpreter with the certainty that there is no featurization happening.

Now let’s discuss the best way to implement a custom NLU in Rasa 2.0.

I would like to confirm that 1.0 mechanics described in the _Legacy Docs_ is still supported and that it is still the recommended approach. I am referring to these articles:

- [User Guide: Deploying Custom Rasa Core or Rasa NLU Code](https://legacy-docs.rasa.com/docs/platform/dev/custom_stack/#deploying-custom-rasa-core-or-rasa-nlu-code)
- [API Reference: Endpoint Configuration](https://legacy-docs.rasa.com/docs/nlu/endpoint_configuration/#endpoint-configurtion)
- [HTTP API: Connecting Rasa NLU](https://legacy-docs.rasa.com/docs/core/server/#connecting-rasa-nlu)

I am able to instantiate a `RasaNLUHttpInterpreter` with the sample `endpoints.yml` below during the evaluation phase (`rasa shell`), therefore I believe that the legacy documentation is still valid.

```auto
# endpoints.yml
nlu:
  type: http
  url: http://my.nlu.server:5000/nlu

```

I have identified two other approaches:

1. Keep using the Rasa NLU pipeline and replace the components with a single, custom component that extends `rasa.nlu.components.Component`

2. Replace the Rasa NLU by a custom interpreter that extends `rasa.shared.nlu.interpreter.NaturalLanguageInterpreter` (or `RegexInterpreter`)

The second approach is very similar to using a `RasaNLUHttpInterpreter` except that I can skip a REST call to the server. It has the caveat that right now I can’t instantiate it during the traing phase.

Please let me know what you recommend.

Thanks for the help! Simon
