Build generative AI applications using Amazon Titan Text Premier, Amazon Bedrock, and AWS CDK

Applications of AI


Amazon Titan Text Premier, the newest addition to the Amazon Titan family of large-scale language models (LLMs), is now generally available on Amazon Bedrock. Amazon Bedrock is a fully managed service that provides high-performance foundational models (FM) from leading artificial intelligence (AI) companies such as AI21 Labs, Anthropic, Cohere, Meta, Stability AI, and Amazon through a single API. Broad feature set for building generative AI applications with security, privacy, and responsible AI.

Amazon Titan Text Premier is an advanced, high-performance, cost-effective software designed to deliver superior performance for enterprise-grade text generation applications, including search augmented generation (RAG) and agent-optimized performance. This is an LLM. This model is built from the ground up following safe, secure, reliable and responsible AI practices and excels at delivering superior AI text generation capabilities at scale.

Exclusive to Amazon Bedrock, the Amazon Titan Text model supports a wide range of text-related tasks, including summarization, text generation, classification, question answering, and information extraction. Amazon Titan Text Premier brings new levels of efficiency and productivity to your text generation needs.

This post walks you through building and deploying two sample applications using Amazon Titan Text Premier. To accelerate development and deployment, use his open source AWS Generative AI CDK Constructs (presented by Werner Vogels at AWS re:Invent 2023). AWS Cloud Development Kit (AWS CDK) configurations accelerate application development by providing developers with reusable infrastructure patterns that they can seamlessly incorporate into their applications, allowing them to focus on differentiating their applications.

Document Explorer sample application

The Document Explorer sample generative AI application helps you quickly understand how to build end-to-end generative AI applications on AWS. It includes examples of key components needed for generative AI applications, including:

  • Data ingestion pipeline – Ingests documents, converts them to text, and stores them in a knowledge base for retrieval. This enables use cases like RAG to tailor generated AI applications to data.
  • Document Summarization – Summarize PDF documents using Amazon Titan Premier through Amazon Bedrock.
  • Question answering – Answer natural language questions by retrieving relevant documents from your knowledge base and using LLMs such as Amazon Titan Premier through Amazon Bedrock.

Follow the instructions in the README to clone the application and deploy it to your account. The application deploys all the required infrastructure, as shown in the following architecture diagram.

After you deploy your application, choose to upload a sample PDF file to your input Amazon Simple Storage Service (Amazon S3) bucket. Select document in the navigation pane. For example, you can download Amazon's annual shareholder letters from 1997 to 2023 and upload them using the web interface. In the Amazon S3 console, you can see that the files you uploaded are in S3 buckets whose names begin with . persistencestack-inputassets.

After uploading the file, open the document and verify that it displays in your browser.

choose Q&A In the navigation pane, select your desired model (in this example, Amazon Titan Premier). You can now ask questions about uploaded documents.

The following image shows a sample workflow in Document Explorer.

Don't forget to delete your AWS CloudFormation stack to avoid unexpected charges. First, be sure to delete all data from your S3 bucket, especially all data in buckets whose names begin with . persistencestack. Then run the following command from your terminal:

Amazon Bedrock Agent and Custom Knowledge Base Sample Application

The Amazon Bedrock Agent and Custom Knowledge Base sample generation AI application is a chat assistant designed to answer literature questions using RAGs from Project Gutenberg books.

This app deploys the Amazon Bedrock agent that can browse the Amazon Bedrock knowledge base, which supports Amazon OpenSearch Serverless as a vector store. An S3 bucket is created to store the knowledge base books.

Follow the instructions in the README to clone the sample application into your account. The following diagram shows the architecture of the deployed solution.

Update the file that defines the underlying model used when creating agents.

const agent = new bedrock.Agent(this, 'Agent', {
      foundationModel: bedrock.BedrockFoundationModel.AMAZON_TITAN_PREMIER_V1_0
,
      instruction: 'You are a helpful and friendly agent that answers questions about literature.',
      knowledgeBases: [kb],
    });

Follow the instructions in the README to deploy the code sample to your account and include the sample documentation.

Go to. Agent Visit the Amazon Bedrock console page for your AWS Region and find your newly created agent.of AgentId Found in the CloudFormation stack output section.

You can ask some questions here. You may need to tell the agent which book you want to ask about, or renew the session if you want to ask about a different book. Below are some examples of frequently asked questions.

  • What are the most popular books in the library?
  • Who is Mr. Bingley infatuated with at the Meryton ball?

The following screenshot shows an example workflow.

Don't forget to remove your CloudFormation stack to avoid unexpected charges. Delete all data from your S3 bucket and run the following command from your terminal.

conclusion

Amazon Titan Text Premier is currently available in the US East (N. Virginia) Region. Custom tweaks for Amazon Titan Text Premier are also available in preview today in the US East (N. Virginia) region. Check the complete region list for future updates.

For more information about the Amazon Titan family of models, please visit the Amazon Titan product page. For pricing details, see Amazon Bedrock Pricing. For more information about available constructs and additional documentation, visit the AWS Generative AI CDK Constructs GitHub repository. Check out the AWS samples repository for practical examples to get started.


About the author

alan clock I'm a senior solutions architect with a passion for new technologies. His past experience includes designing and implementing his IIoT solutions for the oil and gas industry and working on robotics projects. When he's not designing software, he enjoys pushing limits and being passionate about his sport of extremes.

Rais Al Sadun Lead Prototyping Architect on the Prototyping and Cloud Engineering (PACE) team. He builds prototypes and solutions using generative AI, machine learning, data analytics, IoT and edge computing, and full-stack development to solve real-world customer challenges. In his free time, he enjoys outdoor activities such as fishing, photography, flying drones, and hiking.

Justin Lewis He leads AWS' emerging technology accelerator. Justin and his team help customers build with emerging technologies like generative AI by providing open source software samples to inspire their own innovation. He lives in the San Francisco Bay Area with his wife and son.

Anupam Dewan is a senior solutions architect with a passion for generative AI and its real-life applications. He and his team help Amazon Builders build customer-facing applications using generative AI. He lives in the Seattle area and loves going hiking and enjoying nature when he's not working.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *