Retrieval Augmented Generation(RAG)
Build an RAG chatbot using Knowledgebase
The lab guides you through developing a Retrieval-Augmented Generation (RAG) assistant, leveraging a knowledge base to provide accurate and context-aware responses. You will integrate a vector database, experiment with retrievers and LLM-based response generation for enhanced AI interactions.
Use case:
Create a product manual chatbot with layout-aware chunking.
Pre-requisites
S3 bucket with product manuals.
Step 1: Create a QnA prompt for Product QnA.
Create a Q&A prompt with the “Product Manuals Tech Support Q&A” template.
In the Test & Compare tab, choose the preferred models, assess their outputs, and identify the most optimal model. Subsequently, click "Select as Best Answer" to designate it as the Primary Model. Additionally, if necessary, you may assign an alternative model as the Fallback Model. However, selecting a Primary Model is mandatory.
Click "Save prompt run" button provided at the right corner.
Save and publish the prompt.
Step 2: Create a QnA Recipe.
Navigate to Recipe.
Click the Add new button in the top corner of Recipe.
Provide a suitable name and description of the recipe.
Select type QnA.
Add Source tile.
Select Amazon S3 as a connector in the Source tile. Enter Product manuals bucket path.
Add Dataset tile (Click + to create a new dataset).
Enter name of the dataset and keep type "text" and save it.
Enable OCR option and select Amazon Textract .
Connect the Source tile to the Dataset tile.
Add Knowledgebase tile.
Connect the Dataset tile to the Knowledgebase tile.
Use Layout aware chunking with 600 token size in Data Processing Preferences and select Embedding model(Amazon Titan Text Embeddings V2).
Add a prompt tile and select the prompt you have created from the dropdown.
Select “Context Generation” settings .
top_k = 3
Enable Reranker and top_n = 2
Select Multiquery rewrite in Advanced query reconstruction.
Connect the Knowledgebase tile to Prompt tile.
Add an output tile and label it as “Chat.”
Connect the Prompt tile to Chat tile.
Save the recipe.
Publish the recipe.
Run the recipe.
Click Test button on Chat tile to test the recipe.
Ask questions in the recipe Test.
What are the Welcome kit contents in F123?
How do you export a CFG file?
Step 3: Create a copilot.
Click the "Export" button located at the top-right corner of the recipe interface.
Click Add new button.
Configure the export form by referring to the sample resource recipe provided below.
Save the export form.
The Copilot will be displayed in the Copilot section of the interface.
Step 4: Ask Questions in the chatbot.
Go to the Copilot tab and open your chatbot.
Ask questions.
What are the Welcome kit contents in F123?
How do you export a CFG file?
Sample resources
Prompt: Tech Support Q&A
Recipe: Product Manuals
Copilot: ProductGuideBot
Refer to the following video to create recipe.
Last updated