Amazon Bedrock is a service that allows you to securely customize foundational models (FMs) with your own data, and to use these models without having to build complex infrastructure management. With Amazon Bedrock, users can access FMs from a variety of vendors through a single API, streamlining the process of creating generative artificial intelligence (AI).

Amazon Bedrock allows you to choose Redis Cloud as the vector database for your models. After your database is set up and connected to Amazon Bedrock, it will import text data from an Amazon Simple Storage Service (S3) bucket into Redis Cloud and use it to extract relevant information when prompted.

For more information about the Redis integration with Amazon Bedrock, see the Amazon Bedrock integration blog post.

Set up Redis for Bedrock

You need to set up your Redis Cloud database before you can set it as the vector database in Amazon Bedrock. To do this, you need to:

  1. Create a subscription and database in Redis Cloud
  2. Enable Transport Layer Security (TLS) for the database and save the certificates
  3. Store database credentials in AWS secrets manager
  4. Create a vector index in your database for Bedrock to use

After you set up the database, you can use the database information to set it as your Bedrock database.

Create a subscription and database

To set up a Redis Cloud instance for Bedrock:

  1. If you’re new to Redis Cloud, sign up for Redis Cloud using the AWS Marketplace integration.

  2. Create a flexible subscription. In the Sizing tab, when creating your first database, make sure to have the following settings:

    • Add the RediSearch and RedisJSON advanced capabilities to your database.
    • Set the size of the database based on the amount of data that will be pulled from your Simple Storage Service (S3) bucket. See Find out the size of your S3 buckets to find out how much training data is stored in your S3 bucket and pick the closest size from the table below.
    Total Size of Documents in S3 Database size without replication Database size with replication
    10,000 kb 135 Mb 270 Mb
    100,000 kb 1.35 Gb 2.7 Gb
    1,000,000 kb 13.5 Gb 27 Gb
    10,000,000 kb 135 Gb 270 Gb

    For more information on sizing, see the Bedrock integration blog post.

Get TLS certificates

  1. Enable Transport Layer Security (TLS) for your database. Select TLS client authentication to require client authentication. Download the client certificates before saving your changes.

  2. If you do not have the Redis Cloud server certificates, download them from the admin console.

Store database credentials in AWS secrets manager

In the AWS Management Console, use the Services menu to locate and select Security, Identity, and Compliance > Secrets Manager. Create a secret with the following fields:

  • username: Database username
  • password: Database password
  • serverCertificate: Contents of the server certificate (redis_ca.pem)
  • clientCertificate: Contents of the client certificate (redis_user.crt)
  • clientPrivateKey: Contents of the client private key (redis_user_private.key)

After you store this secret, you can view and copy the Amazon Resource Name (ARN) of your secret on the secret details page.

Create a vector index in your database

After your database is set up, create an index with a vector field using FT.CREATE as your knowledge base for Amazon Bedrock.

RedisInsight

RedisInsight is a free Redis GUI that allows you to visualize and optimize your data in Redis.

Follow the steps in this dedicated guide to create your vector index with RedisInsight.

redis-cli

The redis-cli command-line utility lets you connect and run Redis commands directly from the command line. To use redis-cli, you can install Redis.

Follow the instructions to connect to your database with TLS certificates and create an index using FT.CREATE. Replace <index_name> with the name of your index and <field_name> with the vector field name.

FT.CREATE <index_name>                   // Index name
    ON HASH                               // Indicates the type of data to index
    SCHEMA
        "<field_name>"  VECTOR FLAT       // Vector field name and index type
            6                             // 6 index parameters follow
            "TYPE" "FLOAT32"              // only FLOAT32 is currently supported by Bedrock
            "DIM" 1536                    // Each vector will have 1536 dimensions
            "DISTANCE_METRIC" "COSINE"    // Other values could be "IP" "L2"

Set Bedrock vector database

On the Amazon Bedrock console, follow the steps to create your models.

When you reach the Vector database section, select Redis Enterprise Cloud, and fill in the fields with the following information:

More info