Experimental
@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
VectorType Enum
The data type for the vectors when using a model to convert text into vector embeddings.
The model must support the specified data type for vector embeddings. Floating-point (float32) is the default data type, and is supported by most models for vector embeddings. See Supported embeddings models for information on the available models and their vector data types.
| Stability | Experimental |
|---|---|
| Source | bedrock/models.ts |
Example
ts
declare const collection: opensearchserverless.ICollectionRef;
declare const role: iam.Role;
declare const multimodalBucket: s3.IBucket;
new bedrock.KnowledgeBase(this, 'KnowledgeBase', {
knowledgeBaseName: 'product-documentation',
description: 'Product manuals and release notes',
type: bedrock.KnowledgeBaseType.vector({
embeddingsModel: bedrock.BedrockFoundationModel.COHERE_EMBED_MULTILINGUAL_V3,
// Store binary vectors: less precise, but cheaper to store and search
vectorType: bedrock.VectorType.BINARY,
vectorStore: bedrock.VectorStore.openSearchServerless({
collection,
vectorIndexName: 'bedrock-knowledge-base-default-index',
vectorField: 'bedrock-knowledge-base-default-vector',
textField: 'AMAZON_BEDROCK_TEXT_CHUNK',
metadataField: 'AMAZON_BEDROCK_METADATA',
}),
// Where images, audio and video extracted from multimodal documents are stored
supplementalDataStorageBucket: multimodalBucket,
}),
// Bring your own service role; the model and vector store permissions are added to it
role,
tags: {
Team: 'Documentation',
},
});
python
# collection: opensearchserverless.ICollectionRef
# role: iam.Role
# multimodal_bucket: s3.IBucket
bedrock.KnowledgeBase(self, "KnowledgeBase",
knowledge_base_name="product-documentation",
description="Product manuals and release notes",
type=bedrock.KnowledgeBaseType.vector(
embeddings_model=bedrock.BedrockFoundationModel.COHERE_EMBED_MULTILINGUAL_V3,
# Store binary vectors: less precise, but cheaper to store and search
vector_type=bedrock.VectorType.BINARY,
vector_store=bedrock.VectorStore.open_search_serverless(
collection=collection,
vector_index_name="bedrock-knowledge-base-default-index",
vector_field="bedrock-knowledge-base-default-vector",
text_field="AMAZON_BEDROCK_TEXT_CHUNK",
metadata_field="AMAZON_BEDROCK_METADATA"
),
# Where images, audio and video extracted from multimodal documents are stored
supplemental_data_storage_bucket=multimodal_bucket
),
# Bring your own service role; the model and vector store permissions are added to it
role=role,
tags={
"Team": "Documentation"
}
)
java
ICollectionRef collection;
Role role;
IBucket multimodalBucket;
KnowledgeBase.Builder.create(this, "KnowledgeBase")
.knowledgeBaseName("product-documentation")
.description("Product manuals and release notes")
.type(KnowledgeBaseType.vector(VectorKnowledgeBaseTypeProps.builder()
.embeddingsModel(BedrockFoundationModel.COHERE_EMBED_MULTILINGUAL_V3)
// Store binary vectors: less precise, but cheaper to store and search
.vectorType(VectorType.BINARY)
.vectorStore(VectorStore.openSearchServerless(OpenSearchServerlessVectorStoreProps.builder()
.collection(collection)
.vectorIndexName("bedrock-knowledge-base-default-index")
.vectorField("bedrock-knowledge-base-default-vector")
.textField("AMAZON_BEDROCK_TEXT_CHUNK")
.metadataField("AMAZON_BEDROCK_METADATA")
.build()))
// Where images, audio and video extracted from multimodal documents are stored
.supplementalDataStorageBucket(multimodalBucket)
.build()))
// Bring your own service role; the model and vector store permissions are added to it
.role(role)
.tags(Map.of(
"Team", "Documentation"))
.build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
ICollectionRef collection;
Role role;
IBucket multimodalBucket;
new KnowledgeBase(this, "KnowledgeBase", new KnowledgeBaseProps {
KnowledgeBaseName = "product-documentation",
Description = "Product manuals and release notes",
Type = KnowledgeBaseType.Vector(new VectorKnowledgeBaseTypeProps {
EmbeddingsModel = BedrockFoundationModel.COHERE_EMBED_MULTILINGUAL_V3,
// Store binary vectors: less precise, but cheaper to store and search
VectorType = VectorType.BINARY,
VectorStore = VectorStore.OpenSearchServerless(new OpenSearchServerlessVectorStoreProps {
Collection = collection,
VectorIndexName = "bedrock-knowledge-base-default-index",
VectorField = "bedrock-knowledge-base-default-vector",
TextField = "AMAZON_BEDROCK_TEXT_CHUNK",
MetadataField = "AMAZON_BEDROCK_METADATA"
}),
// Where images, audio and video extracted from multimodal documents are stored
SupplementalDataStorageBucket = multimodalBucket
}),
// Bring your own service role; the model and vector store permissions are added to it
Role = role,
Tags = new Dictionary<string, string> {
{ "Team", "Documentation" }
}
});
go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
var collection ICollectionRef
var role Role
var multimodalBucket IBucket
bedrock.NewKnowledgeBase(this, jsii.String("KnowledgeBase"), &KnowledgeBaseProps{
KnowledgeBaseName: jsii.String("product-documentation"),
Description: jsii.String("Product manuals and release notes"),
Type: bedrock.KnowledgeBaseType_Vector(&VectorKnowledgeBaseTypeProps{
EmbeddingsModel: bedrock.BedrockFoundationModel_COHERE_EMBED_MULTILINGUAL_V3(),
// Store binary vectors: less precise, but cheaper to store and search
VectorType: bedrock.VectorType_BINARY,
VectorStore: bedrock.VectorStore_OpenSearchServerless(&OpenSearchServerlessVectorStoreProps{
Collection: *Collection,
VectorIndexName: jsii.String("bedrock-knowledge-base-default-index"),
VectorField: jsii.String("bedrock-knowledge-base-default-vector"),
TextField: jsii.String("AMAZON_BEDROCK_TEXT_CHUNK"),
MetadataField: jsii.String("AMAZON_BEDROCK_METADATA"),
}),
// Where images, audio and video extracted from multimodal documents are stored
SupplementalDataStorageBucket: multimodalBucket,
}),
// Bring your own service role; the model and vector store permissions are added to it
Role: Role,
Tags: map[string]*string{
"Team": jsii.String("Documentation"),
},
})
Members
| Member | Description |
|---|---|
FLOATING_POINT | FLOATING_POINT convert the data to floating-point (float32) vector embeddings (more precise, but more costly). |
BINARY | BINARY convert the data to binary vector embeddings (less precise, but less costly). |
Referenced by
BedrockFoundationModel.supportedVectorTypesupported_vector_typesupportedVectorTypeSupportedVectorTypeSupportedVectorTypeBedrockFoundationModelProps.supportedVectorTypesupported_vector_typesupportedVectorTypeSupportedVectorTypeSupportedVectorTypeKnowledgeBaseEmbeddingsModelProps.vectorTypevector_typevectorTypeVectorTypeVectorTypeVectorKnowledgeBaseTypeProps.vectorTypevector_typevectorTypeVectorTypeVectorType