How to Automatically Generate Answers to User Questions

About QnA

QnA is a feature that helps administrators automatically generate answers to unanswered user questions entered as search queries. See the image "Questions & Answers" below.

Note: Question and Answer provides functions to users similar to How to Personalize User Queries.

QnA differs from other SmartHub question features in that it enables you to set an intent for questions.

Intent

An example of the benefits of using intent (how to set up intent is shown below) in a question is below:

"What is Burt Neuborne's address"

With Intent set, the question can be asked with the same text in a more random order ("what is the address of Burt and Newborne"), with different punctuation, and still the answer will be found and returned to the user.

No Intent

With no intent set (how to set up intent is shown below), such as when using Delayed Answers or Featured Results, in the same question:

"What is Burt Neuborne's address"

The question text must be entered in the exact order as set in the Delayed Answers feature, with no change in text order or punctuation, in order for the answer to be found and returned to the user.

Question & Answers

QnA enables you to set an intent for questions.

  • This enables users to ask the same question in different ways, but still receive accurate answers.
  • For example, when a question contains a specified word or phrase, the bot can be set to return a specific message and answer.
  • Intent is set in the QnA administration settings.
    The settings page is shown below.

Questions & Answers is more flexible than Featured Results when it comes to questions asked by the user.

  • Featured Results requires the user ask a question using the exact text in the exact order as specified in the Featured Results configuration.
  • Questions & Answers uses the configured intent to answer questions. The user does not need to input questions using the exact text configured in SmartHub to receive an answer.
  1. First select "Questions & Answers".



  2. Intent is set on the line "When the user talks about...".
    1. "Add item" is an intent as set in your NLQ provider:
      1. "favorite movie," "last quarter's results," "my business results," etc.
      2. For ideas of most popular user intents in queries, use SmartHub Analytics such as How to Track User Queries and Selections.
    2. The bot message and answer can then be entered/selected.
    3. All questions that match the intent item you add here receive the selected message and answer. This behavior is unique to the QnA feature.
    4. Select Featured Results instead of Questions & Answers and an exact search query must be entered instead of an intent phrase.
      1. Any question entered by the user must exactly match the question set in SmartHub (see "Pending User Questions" under QnA) for an answer to be returned.

Questions & Answers



Featured Results

How do Users Use Question-and-Answers in SmartHub?

QnA can be used by users to automatically receive an answer to any question they ask using the Delayed Answers functionality.

In the example shown in the screenshot below,

User Answer Options

Administrators can configure automatic answers.

The predefined automatic answers are set as follows:

  • It's ok. I will ask for something else
    • The system will ignore the query and not trigger the delay answer capability
  • Find an answer for me
    • If a user chooses Find an answer for me, the question is entered into the admin queue of Pending User Questions.
    • The system can be either set up to automatically find answers or disabled and in this case the admin can click the Predict Answer button:

 

How to Test Questions and Answers

Once you have questions populated in your table, as shown below, you can test, or simulate, the answer SmartHub will provide if a user enters the question shown.

  1. To see the answer to a question, select "Predict Answer" from the Action column for a given question. See below:

    Predict Answer option


  2. The question is run against your NLQ service (LUIS, in this case), for a matching intent.
    The proposed answers, based on the intent matched, are returned and displayed.
    Select the desired answer and click Save.

    Proposed Answers to Prediction Request

Once you choose one of the suggested answers as correct, the system checks if:

  • There is an intent associated to this question and if so it will create a new entry under Questions & Answers
  • If no intent matches the question, the system will generate a Featured Result

Pending User Questions

  1. Select "Pending Questions" from the navigation menu to open a list of pending user question.

  2. Click Settings to open a dialogue box with the options to automatically generate Questions and Answers as well as modify the predefined QnA template.

  3. See the window below.

Automatic QnA

These automatically created entries can be found under "Questions And Answers" and "Featured Results."

The admin can also generate answers by:

  • Providing a list of questions
  • Using the questions identified by Analytics as being unsuccessful queries
  • Using the unanswered questions stored under Pending User Questions

  • If Review answers is checked, the admin will be automatically asked to review the answers and decide if the suggested answer is correct or delete it.
  • Both the answer and the context can be edited before accepting the answer.
  • The bulk update option on the top right will either accept or remove all suggested answers.

How to Set Up QnA

This functionality depends on different providers and SmartHub's integration with Haystack.

To install and configure Haystack, follow the recommendations listed here.

To set up a QnA provider in SmartHub use the following steps:

  1. Open the SmartHub Administration page at http(s)://<web-app-url>/_admin

  2. Go to QnA → Settings. See the left-side navigation menu in the screenshot below.

Note: Without a Tika extractor endpoint configured, only files with .txt extension will be accepted on 

Feed the Index

Haystack will use the documents pushed into its index to find answers to the user questions

To feed this index:

  1. Go to QnA → Feed And Index.

  2. Drag-and-drop text documents (files must have extension .txt) into the box.


Remove all files from index

All pushed files into Haystack can be deleted.

Right after this action, the QnA system will not be able to answer to any question. 

Removing all files cannot be undone!

To purge the index:

  1. Go to QnA → Feed And Index.

  2. Click on Remove under Remove files from QnA provider system.

Set Up Using an AutoClassifier Pipeline Stage

As an alternative to feed the index is at crawl time using Connectivity Hub and AutoClassifier.

In AutoClassifier, add a SmartHub QnA Document Feeder stage. 

The stage assumes Haystack is set up to use Elasticsearch for indexing.

Parameters required include:

  • Elasticsearch address
    and
  • Index name

Source document property name represents the metadata name from ConnectivityHub.

 

The connection between ConnectivityHub and AutoClassifier is done through the enrichment component.

See here how to set it up.

How to Install Haystack

Prerequisites

  • An Elastic Index is required
  • Python v3.7
  • Torch v1.9.1 - see "Install Torch v1.9.1" below
  • Microsoft Visual C++ 2015-2019 is required
  • Supported Haystack versions:
    • v1.2 only

Install Torch v1.9.1

  1. Open a web browser.

  2. Download Torch (torch-1.9.1+cpu-cp37-cp37m-win_amd64) from https://download.pytorch.org/whl/torch_stable.html.
    1. Ensure the version of Torch matches your processor architecture – typically, win_amd64.

  3. Open a command prompt with Admin privileges if it is not already open.

  4. Using the cd command, navigate to the location where the torch installation file is stored.
    1. For example, cd "C:\Users\admin_account\Downloads\"

  5. Next, run the following command (alter the file name and path, as necessary):

    pip install "C:\Users\admin_account\Downloads\torch-1.9.1+cpu-cp37-cp37m-win_amd64.whl"



  6. Next, run the command pip install --editable .



  7. Next, run the command:

    uvicorn rest_api.application:app --host 0.0.0.0
  8. Open a web browser and enter the URL: http://127.0.0.1:8000/docs.

  9. If the installation was successful, the page below appears:



Install Haystack

Installation steps:

  1. Download the Haystack .zip package from GIT. Unblock the file. Extract the contents of the .zip file.

  2. Open a command prompt with Admin privileges.

  3. Using the cd command, navigate to the haystack installation directory (where the zip file contents reside).
    1. For example, cd "C:\Users\admin_account\Downloads\haystack-master\haystack-master"

  4. Next, run the command:

    pip install farm-haystack -f "https://download.pytorch.org/whl/torch_stable.html"



  5. Lastly, run the command:
      pip install --editable .

Make sure to include the training "." at the end of the command above as it is essential

How to Run Haystack

Once all prerequisites are satisfied and all required programs are installed, use the following steps to run Haystack:

  1. Open a command prompt with Admin privileges if it is not already open.

  2. Navigate to the Haystack installation directory (where you extracted the .zip file).

  3. Run the command:
      uvicorn rest_api.application:app --host 0.0.0.0

  4. If everything is running correctly your command prompt should show something similar to this:




  5. Haystack runs as long as the command prompt remains open

  6. If the command prompt is closed, perform steps 1-3 above, again.

How to Verify Haystack is Running

To verify Haystack is running, use the following steps:

  1. Open the URL: http://localhost:8000/docs

  2. The Swagger API documentation for Haystack is displayed.

  3. This verifies Haystack is running.

  4. If the Swagger API documentation for Haystack is not displayed:
    1. Verify the command prompt running Haystack is open.
    2. If the command prompt running Haystack is not open, follow the steps in "How to Run Haystack" above.

How to Restart Haystack

  1. Close the current command prompt where Haystack is running and follow the steps in "How to Run Haystack" above.