TNS
VOXPOP
Where are you using WebAssembly?
Wasm promises to let developers build once and run anywhere. Are you using it yet?
At work, for production apps
0%
At work, but not for production apps
0%
I don’t use WebAssembly but expect to when the technology matures
0%
I have no plans to use WebAssembly
0%
No plans and I get mad whenever I see the buzzword
0%
AI

Build a Q&A Application with Amazon Bedrock and Amazon Titan

This guide focuses on building a question-answering application based on Retrieval Augmented Generation (RAG).
Dec 22nd, 2023 6:00am by
Featued image for: Build a Q&A Application with Amazon Bedrock and Amazon Titan
Feature image by Mirko Fabian from Pixabay.

In the previous tutorial, we created an Amazon OpenSearch Serverless instance to store and retrieve the text embeddings generated from the Kaggle Academy Awards dataset.

This guide focuses on building a question-answering application based on Retrieval Augmented Generation (RAG). We will continue to use the same environment and the Jupyter Notebook we launched in the previous tutorial.

Step 1 – Build the Context Through Semantic Search

Our goal is to retrieve the top matches based on the prompt and then concatenate the text to create the context.

Let’s start with a prompt that will be asked by the user and convert that into vector embeddings by sending it to the Titan Embeddings models.


Based on this vector, we will now perform a semantic search.


Let’s create the context by concatenating the value of the nominee_text element.


Step 2 – Augmenting the Prompt with Context and Invoking the Titan Model

We will now create an augmented prompt from the context that includes the context and the original prompt.


With the final prompt in place, let’s invoke the model.


You can change the prompt and run this to see accurate responses from Titan.

For the prompt, “Which character did Brendan Fraser play in the film The Whale?” you get the below response, which is correct.

This concludes the tutorial on implementing RAG with Amazon Bedrock, Amazon Titan and Amazon OpenSearch Serverless.

Group Created with Sketch.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.