Retrieve multiple questions matching the search keyword in QnA Maker

谁都会走 提交于 2019-12-13 02:47:22

问题


I have a bot which uses LUIS and QnA Maker.

Now, I am able to send queries and get back response in my bot based on the search keyword. But in case my search keyword is used in multiple questions, QnA Maker just retrieves the first matching QnA pair.

Consider below QnA pair:

What is flexible working?   Flexibility to work from home
How to avail flexible working?  Get in touch with manager

If the user types the exact question and hits enter, the response would be the answer which matches the question. But, if the user types flexible working in this case the response would be just the first QnA answer. So in this case I would like retrieve both the questions and throw back to the user as a choice of questions to choose from.

I tried overriding the RespondFromQnAMakerResultAsync and also checked the QnA maker APIs. Unfortunately I didn't find any way to do this.

Any help on this please? Let me know if I can rephrase or clarify more on this.


回答1:


in case my search keyword is used in multiple questions, the QnA maker just retrieves the first matching QnA pair

You can try to specify the top parameter for QnAMakerAttribute, which controls the number of answers to return.

The definition of QnAMakerAttribute:

public QnAMakerAttribute(string subscriptionKey, string knowledgebaseId, string defaultMessage = null, double scoreThreshold = 0.3, int top = 1);

In your QnaDialog, you can specify it like this:

public QnaDialog() : base(new QnAMakerService(new QnAMakerAttribute("{subscriptionKey_here}", "{knowledgebaseId_here}", "Sorry, I couldn't find an answer for that", 0.5, 5)))
{
}

Edit:

The above approach worked for me, it can promote questions and show the answer for selected question.



来源:https://stackoverflow.com/questions/50326318/retrieve-multiple-questions-matching-the-search-keyword-in-qna-maker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!