Generative AI with Amazon Bedrock

Book description

Become proficient in Amazon Bedrock by taking a hands-on approach to building and scaling generative AI solutions that are robust, secure, and compliant with ethical standards

Key Features

  • Learn the foundations of Amazon Bedrock from experienced AWS Machine Learning Specialist Architects
  • Master the core techniques to develop and deploy several AI applications at scale
  • Go beyond writing good prompting techniques and secure scalable frameworks by using advanced tips and tricks
  • Purchase of the print or Kindle book includes a free PDF eBook

Book Description

The concept of generative artificial intelligence has garnered widespread interest, with industries looking to leverage it to innovate and solve business problems. Amazon Bedrock, along with LangChain, simplifies the building and scaling of generative AI applications without needing to manage the infrastructure.

Generative AI with Amazon Bedrock takes a practical approach to enabling you to accelerate the development and integration of several generative AI use cases in a seamless manner. You’ll explore techniques such as prompt engineering, retrieval augmentation, fine-tuning generative models, and orchestrating tasks using agents. The chapters take you through real-world scenarios and use cases such as text generation and summarization, image and code generation, and the creation of virtual assistants. The latter part of the book shows you how to effectively monitor and ensure security and privacy in Amazon Bedrock.

By the end of this book, you’ll have gained a solid understanding of building and scaling generative AI apps using Amazon Bedrock, along with various architecture patterns and security best practices that will help you solve business problems and drive innovation in your organization.

What you will learn

  • Explore the generative AI landscape and foundation models in Amazon Bedrock
  • Fine-tune generative models to improve their performance
  • Explore several architecture patterns for different business use cases
  • Gain insights into ethical AI practices, model governance, and risk mitigation strategies
  • Enhance your skills in employing agents to develop intelligence and orchestrate tasks
  • Monitor and understand metrics and Amazon Bedrock model response
  • Explore various industrial use cases and architectures to solve real-world business problems using RAG
  • Stay on top of architectural best practices and industry standards

Who this book is for

This book is for generalist application engineers, solution engineers and architects, technical managers, ML advocates, data engineers, and data scientists looking to either innovate within their organization or solve business use cases using generative AI. A basic understanding of AWS APIs and core AWS services for machine learning is expected.

Table of contents

  1. Generative AI with Amazon Bedrock
  2. Contributors
  3. About the authors
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Conventions used
    6. Get in touch
    7. Share Your Thoughts
    8. Download a free PDF copy of this book
  6. Part 1: Amazon Bedrock Foundations
  7. Chapter 1: Exploring Amazon Bedrock
    1. Understanding the generative AI landscape
    2. What are FMs?
    3. What is Amazon Bedrock?
    4. FMs in Amazon Bedrock
      1. Amazon Titan FMs
      2. AI21 Labs – Jurassic-2
      3. Anthropic Claude
      4. Cohere
      5. Meta Llama 2 and Llama 3
      6. Mistral AI
      7. Stability AI – Stable Diffusion
    5. Evaluating and selecting the right FM
    6. Generative AI capabilities of Amazon
      1. Amazon SageMaker
      2. Amazon Q
    7. Generative AI use cases with Amazon Bedrock
    8. Summary
  8. Chapter 2: Accessing and Utilizing Models in Amazon Bedrock
    1. Technical requirements
    2. Accessing Amazon Bedrock
      1. Chat playground
      2. Text playground
      3. Image playground
      4. API-based approach
    3. Using Amazon Bedrock APIs
      1. ListFoundationModels
      2. GetFoundationModel
      3. InvokeModel
      4. InvokeModelWithResponseStream
    4. Converse API
    5. Amazon Bedrock integration points
      1. Amazon Bedrock with LangChain
      2. Creating a LangChain custom prompt template
      3. PartyRock
    6. Summary
  9. Chapter 3: Engineering Prompts for Effective Model Usage
    1. Technical requirements
    2. What is prompt engineering?
      1. Components of prompts
      2. Prompt engineering applications
    3. Unlocking prompt engineering techniques
      1. Zero-shot prompting
      2. Few-shot prompting
      3. Chain-of-thought prompting
      4. ReAct prompting
    4. Designing prompts for Amazon Bedrock models
      1. Prompting Anthropic Claude 3
      2. Prompting Mistral models
      3. Prompt guidance for Amazon Titan text models
      4. AI21 Labs – instruct models
      5. Prompting Meta Llama models
      6. Prompt guidance for Stability AI – Stable Diffusion
    5. Understanding best practices in prompt engineering
    6. Summary
  10. Chapter 4: Customizing Models for Enhanced Performance
    1. Technical requirements
    2. Why is customizing FMs important?
    3. Understanding model customization
      1. PEFT
      2. Hyperparameter tuning
    4. Preparing the data
    5. Creating a custom model
      1. Components of model customization
      2. APIs
    6. Analyzing the results
      1. Metrics for training and validation
      2. Inference
    7. Guidelines and best practices
    8. Summary
  11. Chapter 5: Harnessing the Power of RAG
    1. Technical requirements
    2. Decoding RAG
      1. What is RAG?
      2. Importance of RAG
      3. Key applications
      4. How does RAG work?
      5. Components of RAG
    3. Implementing RAG with Amazon Bedrock
      1. Amazon Bedrock Knowledge Bases
      2. Amazon Bedrock Knowledge Base setup
      3. API calls
    4. Implementing RAG with other methods
      1. Using LangChain
      2. Other GenAI systems
    5. Advanced RAG techniques
      1. Query handler – query reformulation and expansion
      2. Hybrid search and retrieval
      3. Embedding and index optimization
      4. Retrieval re-ranking and filtering
    6. Limitations and future directions
    7. Summary
  12. Part 2: Amazon Bedrock Architecture Patterns
  13. Chapter 6: Generating and Summarizing Text with Amazon Bedrock
    1. Technical requirements
    2. Generating text
      1. Text generation applications
      2. Text generation systems with Amazon Bedrock
      3. Generating text using prompt engineering
    3. Summarizing text
      1. Summarization of small files
      2. Summarization of large files
    4. Creating a secure serverless solution
    5. Summary
  14. Chapter 7: Building Question Answering Systems and Conversational Interfaces
    1. Technical requirements
    2. QA overview
      1. Potential QA applications
      2. QA systems with Amazon Bedrock
    3. Document ingestion with Amazon Bedrock
      1. QA on small documents
      2. QA for large documents on knowledge bases
      3. QA implementation patterns with Amazon Bedrock
    4. Conversational interfaces
      1. Chatbot using Amazon Bedrock
      2. Empowering chatbot development with Amazon Bedrock and the LangChain framework
      3. Crafting context-aware conversational interfaces – the fundamental pillars
      4. A context-aware chatbot architectural flow
    5. Summary
  15. Chapter 8: Extracting Entities and Generating Code with Amazon Bedrock
    1. Technical requirements
    2. Entity extraction – a comprehensive exploration
      1. Deep learning approaches
      2. Rule-based systems
      3. Hybrid approaches
    3. Industrial use cases of entity extraction – unleashing the power of unstructured data
    4. Entity extraction with Amazon Bedrock
      1. Structuring prompts for entity extraction
      2. Incorporating context and domain knowledge
      3. Leveraging few-shot learning
      4. Iterative refinement and evaluation
    5. Code generation with LLMs – unleashing the power of AI-driven development
      1. The code generation process
      2. Benefits of code generation with Amazon Bedrock
      3. Limitations and considerations
      4. Use cases and examples
      5. Prompt engineering examples with Amazon Bedrock
    6. Summary
  16. Chapter 9: Generating and Transforming Images Using Amazon Bedrock
    1. Technical requirements
    2. Image generation overview
      1. What are GANs and VAEs?
      2. Real-world applications
    3. Multimodal models
      1. Stable Diffusion
      2. Titan Image Generator G1
      3. Titan Multimodal Embeddings
      4. Anthropic Claude 3 – Sonnet, Haiku, and Opus
    4. Multimodal design patterns
      1. Text-to-image
      2. Image search
      3. Image understanding
      4. Image-to-image patterns
    5. Ethical considerations and safeguards
    6. Summary
  17. Chapter 10: Developing Intelligent Agents with Amazon Bedrock
    1. Technical requirements
    2. What are Agents?
      1. Features of agents
      2. Practical applications of Agents – unleashing the potential
    3. GenAI agent personas, roles, and use-case scenarios
    4. Amazon Bedrock integration with LangChain Agents
    5. Agents for Amazon Bedrock
      1. Unveiling the inner workings of GenAI agents with Amazon Bedrock
      2. Advancing reasoning capabilities with GenAI – a primer on ReAct
      3. Practical use case and functioning with Amazon Bedrock Agents
    6. Deploying an Agent for Amazon Bedrock
    7. Summary
  18. Part 3: Model Management and Security Considerations
  19. Chapter 11: Evaluating and Monitoring Models with Amazon Bedrock
    1. Technical requirements
    2. Evaluating models
      1. Using Amazon Bedrock
      2. Automatic model evaluation
      3. Model evaluation results
      4. Using human evaluation
    3. Monitoring Amazon Bedrock
      1. Amazon CloudWatch
      2. Bedrock metrics
      3. Model invocation logging
      4. AWS CloudTrail
      5. EventBridge
    4. Summary
  20. Chapter 12: Ensuring Security and Privacy in Amazon Bedrock
    1. Technical requirements
    2. Security and privacy overview
    3. Data encryption
    4. AWS IAM
      1. Deny access
      2. Principle of least privilege
      3. Model customization
    5. Securing the network
    6. Network flow
      1. On-demand architecture
      2. Provisioned throughput architecture
      3. Model customization architecture
    7. Ethical practices
      1. Veracity
      2. Intellectual property
      3. Safety and toxicity
    8. Guardrails for Amazon Bedrock
      1. How does Guardrails for Amazon Bedrock work?
      2. Content filters
      3. Denied topics
      4. Word filters
      5. Sensitive information filters
      6. Blocked messaging
      7. Testing and deploying guardrails
      8. Using guardrails
    9. Summary
  21. Index
    1. Why subscribe?
  22. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts
    3. Download a free PDF copy of this book

Product information

  • Title: Generative AI with Amazon Bedrock
  • Author(s): Shikhar Kwatra, Bunny Kaushik
  • Release date: July 2024
  • Publisher(s): Packt Publishing
  • ISBN: 9781803247281