Configuring Grounding in FAQ+

Updated 

In this article, we will explore how you can configure grounding to ensure that the LLM’s responses are based on the knowledge content provided.

Note:

  • Grounding reduces, but does not complete eliminate the risk of hallucinations.

  • Brands will lost the ability to do small talk with FAQ+

The solution presented below is based on the understanding that if 'a' was to be referred for chunking the answer, then rawResponse component from the Generative AI API Response (More about locating the filed here ) would have references to it in the form of 【2】

Example

"rawResponse": "Yas Island is a vibrant destination offering a variety of activities. You can enjoy thrilling experiences at theme parks like Warner Bros. World™ Abu Dhabi, Yas Waterworld, and Ferrari World Abu Dhabi【9】. For outdoor fun, visit Yas Beach or stroll along Yas Marina【2】. The island also hosts exciting events and offers over 160 dining options【2】【1】. For a luxurious stay, consider W Abu Dhabi – Yas Island【7】. \n\n🚗 **Transportation Tip:** Use the complimentary Yas Express shuttle to explore the island effortlessly!" 

Steps to configure Grounding

  1. Configure Smart FAQ Node.

    Steps to configure: Deploying a Smart FAQ Model in a Dialogue Tree using Smart FAQ node.

  2. Add an Update properties Node to Parse the raw API response.
    Define a variable to parse the SMART_FAQ_RAW_RESPONSE.

    1. Variable Name: var1 (you can choose any name)

    2. Groovy Code:

      return JSON_UTILS.parseJson(SMART_FAQ_RAW_RESPONSE);

  3. Add an Update properties Node to check the value for iscited component.

    1. Variable Name: var2 (customizable)

    2. Groovy Code:

      return var1.results[0].details.suggestions[0].additional.isCited 

  4. Add a Decision Box Node to take a decision on the value for iscited component.

    If True, the response is grounded in knowledge content, and you can publish the repsonse to the end user.

    If False, treat the reposes as Fallback.

  5. Publish the response to the end user.

    Publish the Bot Response variable configured in the Smart FAQ Node in the path where iscited component equals true.

Grounding When Using FAQ Tool

  • Use the below script in Adapted Response

  • Print Adapt Response variable. 

    Groovy Code:

    def rawResponse = JSON_UTILS.parseJson(SMART_FAQ_RAW_RESPONSE);

    def suggestion = rawResponse?.results?.getAt(0)?.details?.suggestions?.getAt(0)

    def isCitedVal = suggestion?.additional?.isCited

    boolean isCited = (isCitedVal == true) || (isCitedVal?.toString()?.equalsIgnoreCase('true') == true)

    def out = isCited ? (suggestion?.text ?: "").toString().trim() : "Sorry, I didn't catch your drift."

    if (!out) out = "Sorry, I didn't catch your drift."return out

    Note: Replace "Sorry, I didn't catch your drift." with the fallback reply of your choice.