# Can I have my own training or retrieving algorithms

**URL:** <https://forum.rasa.com/t/can-i-have-my-own-training-or-retrieving-algorithms/20533>\
**Category:** Getting Started with Rasa\
**Created:** [October 28, 2019, 8:41am UTC](https://forum.rasa.com/t/can-i-have-my-own-training-or-retrieving-algorithms/20533 "2019-10-28T08:41:55Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ColinOOOOOh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/colinoooooh/32/5771_2.png) [@ColinOOOOOh](https://forum.rasa.com/u/ColinOOOOOh)\
**Post date:** [October 28, 2019, 8:41am UTC](https://forum.rasa.com/t/can-i-have-my-own-training-or-retrieving-algorithms/20533/1 "2019-10-28T08:41:55Z")

</div>

Hey guys, I am just new to Rasa. I am doing a FAQ chatbot project using Rasa. I built a chatbot demo under Rasa framework (with actions.yml, nlu.md, stories.md, etc.) However, my said it is too simple and the performance seems not good enough. He aslo suggestted me to build my own training or retrieving algorithms. I dont know how can I get started since I dont know the way to modify the training code. Each time I train the model, I simply prepare the data use _rasa train_. It seems that I can do nothing with the Rasa core algorithms. I’ve done some machine learning and data retrival courses and know some algorithm that potentially can be used in this project.

Could anyone give me some idea?

---

<div class="post-metadata">

**Author:** ![Tanja](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tanja/32/4696_2.png) [@Tanja](https://forum.rasa.com/u/Tanja)\
**Post date:** [October 31, 2019, 8:38am UTC](https://forum.rasa.com/t/can-i-have-my-own-training-or-retrieving-algorithms/20533/2 "2019-10-31T08:38:53Z")

</div>

What exactly do you mean by retrieving algorithms?

Rasa is divided into two parts: NLU and Core. The NLU part is processing the message and extract entities and classifies the intent. You can define the components that you want to use for it, see [Choosing a Pipeline](https://rasa.com/docs/rasa/nlu/choosing-a-pipeline/) and [Components](https://rasa.com/docs/rasa/nlu/components/). If you want to write your own Entity Extractor or Intent Classifier, you can do so by writing your own component ([Custom NLU Components](https://rasa.com/docs/rasa/api/custom-nlu-components/#custom-nlu-components)). The Core part is responsible for predicting the next action. We have several policies in place, see [Policies](https://rasa.com/docs/rasa/core/policies/).

Does that help?

---

<div class="post-metadata">

**Author:** ![ColinOOOOOh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/colinoooooh/32/5771_2.png) [@ColinOOOOOh](https://forum.rasa.com/u/ColinOOOOOh)\
**Post date:** [October 31, 2019, 11:55am UTC](https://forum.rasa.com/t/can-i-have-my-own-training-or-retrieving-algorithms/20533/3 "2019-10-31T11:55:26Z")

</div>

Thank you. It helps me a lot. Btw, if I am not satisfied with the performance of the default rasa, which part should I consider to improve (add custom component) first? Or say what component added benefits the most?

---

<div class="post-metadata">

**Author:** ![Tanja](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tanja/32/4696_2.png) [@Tanja](https://forum.rasa.com/u/Tanja)\
**Post date:** [November 1, 2019, 8:02am UTC](https://forum.rasa.com/t/can-i-have-my-own-training-or-retrieving-algorithms/20533/4 "2019-11-01T08:02:10Z")

</div>

It depends. What part are you not satisfied with?

If you are not satisfied with the overall performance of your bot, I would recommend that you test your models to see what part is not working well. See [Evaluating Models](https://rasa.com/docs/rasa/user-guide/evaluating-models/) for that. You can also run your bot in `--debug` mode to see what the bot is predicting (entities, intents, actions) and what does not work that well.

The easiest way to modify your bot is to change the NLU pipeline. You can try out different components and configure them according to your needs ([Components](https://rasa.com/docs/rasa/nlu/components/?_ga=2.233099870.1512067997.1572251649-6187419.1552916589)). This will have impact on your NLU model. If the NLU model is more certain the bot might also make better prediction on the next action.

---

<div class="post-metadata">

**Author:** ![ColinOOOOOh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/colinoooooh/32/5771_2.png) [@ColinOOOOOh](https://forum.rasa.com/u/ColinOOOOOh)\
**Post date:** [November 2, 2019, 8:13am UTC](https://forum.rasa.com/t/can-i-have-my-own-training-or-retrieving-algorithms/20533/5 "2019-11-02T08:13:11Z")

</div>

Now I got the whole picture. Thank you so much.

I tried to add the sentiment analyzer to my pipeline. Basically it works. However, when I run _rasa shell nlu_ and input some messages which are the same as the sentences in nlu.md, the sentiment analyzer always gives me the same result and same confidence, no matter what I input.

I checked the input data and labels in train(), they zipped correctly. And the input message in process() is passed and preprocessed correctly as well.

Where would be the problem?

---

<div class="post-metadata">

**Author:** ![Tanja](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tanja/32/4696_2.png) [@Tanja](https://forum.rasa.com/u/Tanja)\
**Post date:** [November 4, 2019, 9:19am UTC](https://forum.rasa.com/t/can-i-have-my-own-training-or-retrieving-algorithms/20533/6 "2019-11-04T09:19:49Z")

</div>

Hard to tell without seeing the code. Can you share it?

What is your model returning? E.g. in process(): how do you save the result of the sentiment analyzer?

---

<div class="post-metadata">

**Author:** ![ColinOOOOOh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/colinoooooh/32/5771_2.png) [@ColinOOOOOh](https://forum.rasa.com/u/ColinOOOOOh)\
**Post date:** [November 5, 2019, 3:32am UTC](https://forum.rasa.com/t/can-i-have-my-own-training-or-retrieving-algorithms/20533/7 "2019-11-05T03:32:15Z")

</div>

The problem has been fixed by saving the model in disk and read it in process(). The code was exactly same as the sentiment analyzer of Rasa’s tutorial. The model was just saved in the class as a variable. I am not so familiar with the mechanism of Python, and I think maybe the reason is that once the train process is finish, the model in memory is free since the program terminated. Then the Rasa framework loads something wrong when the process() is called.

Anyway it works now,

In the next step I want to train my model with the output of some featurizer or tokenizer in my pipeline. However, I still recieve the raw text input in the train(…,training\_data,…) ,even if I add my requirements in requires=[]. How can I receive the output of other components?

---

<div class="post-metadata">

**Author:** ![Tanja](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tanja/32/4696_2.png) [@Tanja](https://forum.rasa.com/u/Tanja)\
**Post date:** [November 8, 2019, 9:23am UTC](https://forum.rasa.com/t/can-i-have-my-own-training-or-retrieving-algorithms/20533/8 "2019-11-08T09:23:07Z")

</div>

You need to specify the components in the pipeline ([Choosing a Pipeline](https://rasa.com/docs/rasa/nlu/choosing-a-pipeline/)) in your config.yml.

The `training_data` object you receive in `train()` contains a list of `message`. A `message` holds a dictionary. Each featurizer puts its output under a specific keyword to that dictionary. To obtain the output of a specific featurizer you need to call `message.get(<key>)`.

The `CountVectorsFeaturizer`, for example, provides `text_features`, `response_features` and `intent_features` ([rasa/count\_vectors\_featurizer.py at master · RasaHQ/rasa · GitHub](https://github.com/RasaHQ/rasa/blob/master/rasa/nlu/featurizers/count_vectors_featurizer.py#L42), [rasa/constants.py at master · RasaHQ/rasa · GitHub](https://github.com/RasaHQ/rasa/blob/master/rasa/nlu/constants.py)).

---

<div class="post-metadata">

**Author:** ![ColinOOOOOh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/colinoooooh/32/5771_2.png) [@ColinOOOOOh](https://forum.rasa.com/u/ColinOOOOOh)\
**Post date:** [November 10, 2019, 6:33am UTC](https://forum.rasa.com/t/can-i-have-my-own-training-or-retrieving-algorithms/20533/9 "2019-11-10T06:33:59Z")

</div>

The last problem was solved with the help of you. Thanks again. Now I am using the Rasa knowledge base. However, the bot keeps let me to rephrase if there is a knowledge base query. I am sure that the query was post to the action server correctly, which means nlu model works. Where would be the problem? I did a slightly change on the knowledgebot in examples. Here are the code:

domain

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/8/85cecdfcd483f9d32724d8f0d2b1ef4071cac3bd.png)

nlu.md:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/b/bdc3e003115dac1d3b53df3baaea237e0a6d0d48.png)

knowledgebase.json

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/4/470e27786a917690f31f2811defd72c9c4555189.png)

actions.py ![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/c/c5b6590fb7f0d1cd1d73763b3ad25ecbe28bf009.png)

client program

![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/3/376fe4d6646d27688a8c371ab9bcaac0d7833fa7.png)

---

<div class="post-metadata">

**Author:** ![Tanja](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tanja/32/4696_2.png) [@Tanja](https://forum.rasa.com/u/Tanja)\
**Post date:** [November 11, 2019, 7:49am UTC](https://forum.rasa.com/t/can-i-have-my-own-training-or-retrieving-algorithms/20533/10 "2019-11-11T07:49:13Z")

</div>

Can you run your bot in debug mode (`--debug`) and paste the log from Rasa and the action server here?

---

<div class="post-metadata">

**Author:** ![ColinOOOOOh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/colinoooooh/32/5771_2.png) [@ColinOOOOOh](https://forum.rasa.com/u/ColinOOOOOh)\
**Post date:** [November 11, 2019, 2:20pm UTC](https://forum.rasa.com/t/can-i-have-my-own-training-or-retrieving-algorithms/20533/11 "2019-11-11T14:20:07Z")

</div>

Here it is.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/f/f0b2841fd89d547f6e688475f86587d6f365e4a9.png)

---

<div class="post-metadata">

**Author:** ![Tanja](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tanja/32/4696_2.png) [@Tanja](https://forum.rasa.com/u/Tanja)\
**Post date:** [November 12, 2019, 7:29am UTC](https://forum.rasa.com/t/can-i-have-my-own-training-or-retrieving-algorithms/20533/12 "2019-11-12T07:29:18Z")

</div>

It seems like that your sentiment extractor overwrites the entities extracted from the CRF entity extractor. Can you please check that? The knoweldge base action depends on the entities. If no `car_insurance` entity is found, it cannot query the knoweldge base. The line `Received message ...` indicates that there is no `car\_insurance´ entity.
