Question answering

Hi, I have a dataset that contains “Question” and “Answer”. A question can repeat itself in the dataset multiple times with different answer. Is it possible to use Rasa as question answering suggestions? what i mean is the user asks a question and Rasa will return 3 suggestions for answers for that question?

Do you want to show all answers at once or only one randomly?

In any case, you would have to create an intent for the question in nlu.yml, for example:

- intent: ask_language
  examples: |
    - What language do you speak?
    - Do you only handle English?
    - Can you speak French?
    - Do you know another language?

Now, if you want to randomly choose between three answers, do that in domain.yml:

responses:
  utter_language:
    - text: "I only speak English"
    - text: "Currently, I only know English"
    - text: "I can only understand English right now"

And if you want to show all three responses at once, do this instead:

responses:
  utter_language:
    - text: |-
        "I only speak English.

        Currently, I only know this language.

        Maybe one day I will understand a new one."

@yanagar25 Hi, can you tell us more about your dataset, do it’s in excel or database? when you say multiple times with different answer what you basically means by that. 1 question having multiple answers? if you can share some example, I can provide you better solution, else what Chris suggested that also solve you issue.

@ChrisRahme My dataset consists of a list 96k questions and answers. If a user asks a question i want the chat bot to be able to reply with 3 different messages as answers that are most frequent among the questions that are similar to what the user asked. (It is not clustered to groups of questions).

@nik202 my dataset is a json file containing a list of 96k objects that looks like this:

[{"Question": "How are you?", "Answer": "I'm good and you?", "Count": 2}, {"Question": "How are you?", "Answer": "I'm good thank you?", "Count": 4}]

1 question can have multiple answers yes.

@yanagar25 96k are questions with different multiple answer right? what you mean by object?

i.e 96K questions and 1 questions can have 1 answer or 4 answers .

Ah I get what you want to do.

Well, you will have to translate this JSON into Rasa format.

Of course, don’t do it manually. You can write code to transform your JSON objects into Rasa format.

Your example above will translate to:

  • nlu.yml:
- intent: intent_1
  examples: |
    - How are you?
  • domain.yml:
responses:
  utter_1:
    - text: "I'm good and you?"
    - text: "I'm good thank you"
// if "Count" in your objects represents the chance of the answer,
// you can duplicate the first text 1 time and the other one 3 times
  • rules.yml:
- rule: rule_1
  steps:
    - intent: intent_1
    - action: utter_1

To do it more cleanly, you can write code for a Rasa Training Data Importer.

1 Like

can anyone please tell how to connect rasa 3.1 to postgresql , i am facing lot of problem