Friday, June 9, 2023
HomeArtificial IntelligenceAutomate and implement model management for Amazon Kendra FAQs

Automate and implement model management for Amazon Kendra FAQs


Amazon Kendra is an clever search service powered by machine studying (ML). Amazon Kendra reimagines enterprise seek for your web sites and purposes so your staff and prospects can simply discover the content material they’re on the lookout for, even when it’s scattered throughout a number of places and content material repositories inside your group.

Amazon Kendra FAQs enable customers to add incessantly requested questions with their corresponding solutions. This helps to persistently reply frequent queries amongst end-users. As of this writing, once you need to replace FAQs, you could delete the FAQ and create it once more. On this submit, we current an easier, quicker method for updating your Amazon Kendra FAQs (with versioning enabled). Our methodology eliminates the handbook steps of making and deleting FAQs once you replace their contents.

Overview of resolution

We use a completely deployable AWS CloudFormation template to create an Amazon Easy Storage Service (Amazon S3) bucket, which turns into the supply to retailer your Amazon Kendra FAQs. Every index-based FAQ is maintained within the folder with a prefix regarding the Amazon Kendra index.

This resolution makes use of an AWS Lambda operate that will get triggered by an Amazon S3 occasion notification. Once you add an FAQ to the S3 folder mapped to a particular Amazon Kendra index, it creates a brand new model of the FAQ on your index. Older variations of FAQs are deleted solely after the brand new FAQ index model is created, reaching near-zero downtime of index looking.

The next determine exhibits the workflow of how our methodology creates and deletes a brand new model of an Amazon Kendra FAQ.

The workflow steps are as follows:

  1. The person uploads the Amazon Kendra FAQ doc to the S3 bucket mapped to the Amazon Kendra index.
  2. The Amazon S3 PutObject occasion triggers the Lambda operate, which reads the occasion particulars.
  3. The Lambda operate creates a brand new model of the FAQ for the goal index for every uploaded doc and deletes the older variations of the FAQ.
  4. The Lambda operate then publishes a message to Amazon Easy Notification Service (Amazon SNS), which sends an electronic mail to the person notifying them that the FAQ has been efficiently up to date.

Conditions

Earlier than you start the walkthrough, you want an AWS account (should you don’t have one, you’ll be able to join one). You additionally have to create the information containing the pattern FAQs:

  • primary.csv – The next code is the pattern FAQ CSV template:
    What number of free clinics are in Spokane WA?, 13, https://www.freeclinics.com/
    What number of free clinics are there in Mountain View Missouri?, 7, https://www.freeclinics.com/

  • demo.json – The next code is the pattern FAQ JSON template:
    {
      "SchemaVersion": 1,
      "FaqDocuments": [
        {
          "Question": "How many free clinics are in Spokane WA?",
          "Answer": "13"
        },
        {
          "Question": "How many free clinics are there in Mountain View Missouri?",
          "Answer": "7",
          "Attributes": {
            "_source_uri": "https://www.freeclinics.com",
            "_category": "Charitable Clinics"
          }
        }
      ]
    }

  • header_demo.csv – The next code is the pattern FAQ CSV template with header:
    _question,_answer,_last_updated_at
    What number of free clinics are in Spokane WA?, 13, 2012-03-25T12:30:10+01:00
    What number of free clinics are there in Mountain View Missouri?, 7, 2012-03-25T12:30:10+01:00

Deploy the answer

The CloudFormation templates that create the assets utilized by this resolution can discovered within the GitHub repository. Observe the directions within the repository to deploy the answer. AWS CloudFormation creates the next assets in your account:

  • An S3 bucket that would be the supply for the Amazon Kendra FAQ.
  • An Amazon Kendra index.
  • An AWS Identification and Entry Administration (IAM) function for the Amazon Kendra FAQ to learn (GetObject) from the S3 bucket.
  • A Lambda operate that’s configured to get triggered by an Amazon S3 occasion. The operate is created exterior of an Amazon VPC.

Word that useful resource creation can take roughly half-hour.

After you run the deployment, you’ll obtain an electronic mail prompting you to substantiate the subscription on the approver electronic mail handle. Select Verify subscription.

Amazon SNS subscription Email

You’re redirected to a web page confirming your subscription.

SNS Subscription Confirmation

Confirm that the Amazon Kendra index is listed on the Amazon Kendra console. On this submit, we named the Amazon Kendra index sample-kendra-index.

Amazon Kendra index as seen from the Amazon Kendra console

Add a pattern FAQ doc to Amazon S3

Within the earlier step, you efficiently deployed the CloudFormation stack. We use the output of the stack within the following steps:

  1. On the Outputs tab of the CloudFormation stack, observe the values for S3Bucket (kendra-faq-<random-stack-id>) and KendraIndex.
    AWS CloudFormation Output
  2. On the Amazon S3 console, navigate to the S3 bucket created from the CloudFormation stack.
  3. Select Create folder and create a folder referred to as faq-<index-id>. For index-id, use the worth you famous for the CloudFormation parameter KendraIndex. After the folder is created, this turns into the prefix for the sample-kendra-index FAQ.
    Create S3 folder prefixed with faq
  4. Add the demo.json FAQ doc to that folder.
    Upload the demo.json FAQ document in that folder

Confirm that the index FAQ is created

To verify that the index FAQ is created, full the next steps:

  1. On the Amazon Kendra console, navigate to the index sample_kendra_index, which was created as a part of the deployment.
  2. Navigate to the FAQs web page for this index to test if an FAQ is listed.

The index has the naming conference <file-name>-faq-<Date-Time>.

Resulting FAQ created by the automation solution

When the FAQ is efficiently created, you’ll obtain one other electronic mail informing you about it. It’s possible you’ll add new variations of the FAQ after you might have obtained this electronic mail.

Receiving email for successful FAQ creation

Word that the automation identifies the file format that it should use whereas creating the FAQ by studying the uploaded file extension and as an exception case by the prefix of header_ for the CSV doc with a header. The goal Amazon Kendra index is recognized by the S3 bucket folder title, which has the index ID because the suffix; for instance, faq-1f01abb8-341c-4921-ad16-139ee517a845.

Add extra FAQ paperwork

Amazon Kendra FAQ helps three forms of file format: CSV, CSV_WITH_HEADER, and JSON. Guarantee that once you add a CSV file with the header, the file title ought to have a prefix with header_ (that is solely when utilizing the CSV file format with a header in its contents). To add your FAQ paperwork, full the next steps:

  1. Add the header_demo.csv file to the identical folder.
    Upload the heder_demo.csv FAQ document in that folder
  2. Confirm that the FAQ is created on the Amazon Kendra console.
    Verify that the FAQ is created

FAQ creation is case-sensitive to the file format of the FAQ doc that you just add. For instance, should you add demo.json and demo.JSON, each are handled as distinctive objects in Amazon S3. Due to this fact, this motion creates two FAQs, corresponding to demo-json-faq-22-09-2022-20-09-11 and demo-JSON-faq-22-09-2022-20-09-11.

  1. Add demo.JSON.
    demo.json and demo.JSON are uploaded to the S3 bucket
  2. Confirm that the FAQ for demo.JSON is created on the Amazon Kendra console.
    Case sensitive file names result in 2 new FAQs created

Create a brand new model of the index FAQ

Now the answer is self-sufficient and capable of work independently everytime you add a brand new model of the FAQ doc in Amazon S3.

To check this, add a brand new up to date model of your demo.json FAQ doc to the faq-<index-id> folder. Once you navigate to the FAQ for the index, there might be an FAQ named <file-name>-faq-<Date-Time>.

This resolution creates a brand new model of the FAQ for the brand new model of the FAQ doc that was uploaded in Amazon S3. When the FAQ is energetic, it deletes the older model of the FAQ for a similar doc.

Verify that only the latest version of the FAQ exists in the index

Create an FAQ with an outline

This resolution additionally helps creating an FAQ with an outline when information are named in a particular method: <document_name>-desc-<your faq description>.fileformat[json|csv]. For instance, demo-desc-hello world.json. Add this FAQ doc to the faq-<index-id> folder.

Upload the file with the description in its name to S3

After you add the doc, the FAQ might be created and it’ll have the outline as talked about within the file title.

FAQ created with description

It’s best to solely use -desc- when you could add an outline to an FAQ. In the event you add a file with the identical document_name prefix, it should delete the outdated FAQ created from the document_name.fileformat FAQ doc and create a brand new FAQ with the outline.

Clear up

To scrub up, carry out the next actions:

  1. Empty the S3 bucket that was created by the CloudFormation stack to retailer the FAQ paperwork. For directions, confer with Emptying a bucket.
  2. Delete the CloudFormation stack. For directions, confer with Deleting a stack on the AWS CloudFormation console.

Conclusion

On this submit, we launched an automatic strategy to handle your Amazon Kendra FAQs. After implementing this resolution, it is best to be capable to create and delete FAQs simply by importing them to an S3 bucket. This manner, you save time by avoiding repetitive handbook adjustments and troubleshooting inconsistent points which might be attributable to surprising operational incidents. You may also audit Amazon Kendra FAQs throughout your group with confidence.

Do you might have suggestions about this submit? Submit your feedback within the feedback part. You may also submit questions on the AWS re:Submit discussion board.


Concerning the Writer

debobhadDebojit is a DevOps guide who focuses on serving to prospects ship safe and dependable options utilizing AWS providers. He concentrates on infrastructure growth and constructing serverless options with AWS and DevOps. Aside from work, Debojit enjoys watching films and spending time together with his household.

glennchiGlenn is a Cloud Architect at AWS. He makes use of expertise to assist prospects ship on their desired outcomes of their cloud adoption journey. His present focus is DevOps and growing open-source software program.

shalabhShalabh is a Senior Guide primarily based in London. His principal focus helps corporations ship safe, dependable, and quick options utilizing AWS providers. He will get very enthusiastic about prospects innovating with AWS and DevOps. Exterior of labor, Shalabh is a cricket fan and a passionate singer.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

Recent Comments