Passing extra parameters to the Http API to parse a message

We have a requirement to employ a “context-sensitive” NLU. That is, an NLU that is aware of where it is within a conversation. We are only using the NLU portion of Rasa and cannot use core currently.

With that in mind I see that the format for /model/parse only has a text and id field. I decided I can solve this by passing the context information in a specific format and pull out the data in the pipeline by doing preprocessing. For example the text of the message would appear like this:

“This is the message to be parsed.[[here is the context information]]”

Anything that is within the brackets can be parsed out. My question is, is there another way to do this? Is there a way to pass more than just text and id in the JSON sent to the Http API? Will other fields in that JSON be picked up in some way?

Thank you in advance.

Currently it is not possible to provide any further metadata to the endpoint model/parse. Why exactly do you need that extra content? I assume you do not want to extract entities from it. Should it be used to improve the intent classification? Can you please explain why do you need that extra information?

Sorry, maybe I wasn’t clear. I explained it. Due to certain constraints we cannot use Rasa core, only the NLU, and I want to pass information about where the chat bot is in the dialogue flow to augment the dialogue manager we must use.

The NLU model does not know anything about the dialogue history and we also do not want to add this kind of information there. The NLU model should not know anything about the conversation, just the current input message is relevant. Thus, I guess, the information you need cannot be retrieved from the model/parse endpoint.

@zeroangel, Did you get a solution for this yet?

I just passed extra information in the body of the text being sent to the model/parse endpoint like this:

{“text”: “Here is some user utterance.{{EXTRA INFORMATION}}”}

…and I just parsed that out with a custom pre-processor in the pipeline. This should work for any extra information.

Got the custom preprocessor part, but didn’t really understand {{extra information}} part. It’ll be great if you could provide a short example maybe? Thanks!

Not sure what you don’t understand. If you want to train a “context sensitive NLU,” as I have, you will need a custom pre-processor in the NLU pipeline to parse out the context information sent to the NLU both in training and when processing. You will also need a custom intent classifier in the pipeline behind the pre-processor that will accept this extra information.

The preprocessor will take the sample:

“Here is a user utterance{{CONTEXT_INFORMATION}}”

and convert the text to be trained on to “Here is a user utterance” alone, while sending the parsed out information “CONTEXT_INFORMATION” to the feature space of the algo that takes in that context information.

At the time of processing, the pre-processor will do the same. Problem solved.

So in what form you have used this context? Is fed even while training? I mean how are you changing the course of conversation based on context? Have you written your own model?

I convert the context to a one hot encoding which I then feed into a custom model I have written.

So you created your own model which uses the context and the text input together and not the one that RASA provides. Or you wrote a model which handles only context?

The former.

Okay, got it…thank you! :slight_smile: Another question to add, Suppose, you have 100 intents and 50 sentences per intent. So while training, you are appending each sentence with each context? That’s a pretty tough dataset right?

And the custom model that you have created predicts the next action? Or maybe helps the conversation to stay in that context?

@zeroangel I’m new to Rasa world, could you please provide the code?

No, I am sorry I cannot provide code. I am sure I am not allowed according to my company policy.

Farheen:

The custom model only predicts intent. As far as performance re, your example, I would say it depends on the example.

But here’s kind of what I am trying to accomplish:

Let’s say you have several “settings” intents, maybe “audio settings” or “video settings.”

So, which “settings” it is depends on the context. That is, if you were in the “Video” flow, the text might appear like this in the training set: “settings{{VIDEO}}” and that would correspond to “Video settings.”

…and yes, I absolutely understand and agree this is much easier to accomplish with a generic “settings” intent and allow the Rasa conversation dialogue manager to handle which “settings” menu is brought up. Sadly, as I have said in the opening, that option does not exist for me.

I would suggest that unless anyone else has my specific problem, that is, not being able to use Rasa core and having a specific requirement to pass information to the /model/parse HTTP API beyond just straight text (in this case, context), that you should not try and do what I am doing because it’s better handled using Rasa dialogue manager.