Skip to the content.
N
Notezio
/ AWS Certified AI Practitioner (AIF-C01)

Amazon Bedrock

What is Amazon Bedrock?

Amazon Bedrock

Foundation Models

How to choose a foundation model?

Key Selection Factors

The choice of foundation model depends on multiple factors:

Important Considerations

Model-Specific Details

Amazon Titan
Llama-2 (Meta)
Claude (Anthropic)
Stable Diffusion (Stability AI)

Selection Strategy

  1. Identify Your Requirements: Determine if you need text, images, or multimodal capabilities
  2. Check Language & Context Needs: Do you need 100+ language support or large context windows?
  3. Consider Use Cases: Match model strengths to your specific applications
  4. Factor in Cost: Balance capabilities with pricing for your projected usage
  5. Test Thoroughly: Validate model performance with your actual inputs and expected outputs before committing to production

Fine-Tuning a Model

Types of Fine-Tuning

1. Instruction-Based Fine-Tuning

Example:

Prompt: what is aws?
Completion: AWS stands for Amazon Web Services — it’s Amazon’s cloud computing platform that provides a wide range of on-demand IT services over the internet.

2. Continued Pre-training

3. Single-Turn and Multi-Turn Messaging

Example Structure:

System: You are a helpful customer service assistant.
User: What are your support hours?
Assistant: We're available 24/7 to assist you.
User: How do I reset my password?
Assistant: You can reset your password by clicking "Forgot Password" on the login page.

Transfer Learning

Use Cases for Fine-Tuning

Common scenarios where fine-tuning is beneficial:

  1. Chatbot Personalization
    • Create a chatbot with a particular persona, tone, or brand voice
    • Example: Customer service bot with friendly, empathetic tone
  2. Purpose-Specific Adaptation
    • Adapt a model for specific business purposes
    • Examples: Customer assistance, advertisement creation, technical support
  3. Proprietary Data Integration
    • Train with exclusive data the foundation model doesn’t have access to
    • Examples: Historical emails, internal messages, customer service records, company procedures
  4. Targeted Tasks
    • Specialized applications like text categorization or accuracy assessment
    • Domain-specific classification tasks

Evaluating Foundation Models

Automatic Evaluation

Human Evaluation

What is RAG (Retrieval-Augmented Generation)?

How RAG Works with Amazon Bedrock

  1. Data Source Input
    • Your data is stored in external sources (e.g., Amazon S3, Confluence, SharePoint)
    • Example: Company documents, product information, customer records
  2. Knowledge Base Creation
    • Amazon Bedrock automatically processes your data from the source
    • Data is converted into vector embeddings via a vector database
    • Creates a searchable index of your data
  3. User Query
    • User asks: “Who is the product manager for John?”
    • Foundation model may not have this company-specific information in its training data
  4. Retrieval Process
    • A search is performed within the knowledge base
    • Relevant information is fetched from the vector database using similarity matching
    • Example results: John’s details, support contacts, product manager: Bob, engineer: Sara
  5. Augmented Prompt Creation
    • Retrieved information is combined with the original user query
    • Augmented prompt now contains both the question and relevant context
    • This enriched prompt is sent to the foundation model
  6. Generation
    • Foundation model generates a response based on the augmented prompt
    • Response: “Jessie Smith is the product manager for John.”

RAG-flow

Benefits of RAG

What is a Vector Database?

Available Vector Database Options

Service Description Best For
Amazon OpenSearch Service Serverless/managed clusters, real-time search & analytics Production RAG, millions of embeddings, scalable KNN search
Amazon Aurora Relational database with vector support Relational data structures, existing Aurora environments
Amazon Neptune Analytics Graph database service Graph-based RAG (GraphRAG), relationships between entities
Amazon S3 Vectors Cost-effective vector storage in S3 Cost-optimized scenarios, sub-second query performance

Data Sources Supported by Amazon Bedrock

Amazon Bedrock can ingest data from multiple sources:

Vector Embeddings and Document Processing

Use Cases for Amazon Bedrock with RAG

RAG vs Fine-Tuning Comparison

Aspect RAG Fine-Tuning
Data Update Frequency Real-time Requires retraining
Implementation Speed Immediate Time-consuming
Cost Lower (no retraining) Higher (computation)
Data Size Can handle large datasets Limited by training data
Model Changes No model modification Model weights updated
Best For Dynamic, frequently-updated data Static, domain-specific knowledge

When to Use RAG vs Fine-Tuning

Guardrails

Bedrock Agents

Bedrock - Other Features

Amazon Bedrock & CloudWatch

Pricing

Pricing Modes

Cost Impact of Model Improvement Approaches

Approach Cost Details
Prompt Engineering Very Low No fine-tuning needed, optimize prompts only
RAG Moderate Costs for vector database and access system
Instruction-Based Fine-Tuning Medium Less intensive computation, labeled data
Full Fine-Tuning High Most expensive, domain-specific training, unlabeled data

Cost Optimization Strategies