Skip to content

S3 Vector, Bedrock embedding Error

0

Hello,

I tried to use S3 Vectors with the command:

s3vectors-embed put --vector-bucket-name test-vector-bucket --index-name test-vector-index --model-id amazon.titan-embed-text-v2:0 --text-value "Hello, Mr. Anderson !" 

and I've got the Bedrock error:

Error: Bedrock embedding failed: An error occurred (ValidationException) when calling the InvokeModel operation: Malformed input request: #: only 1 subschema matches out of 2, please reformat your input and try again.

Could you please specify why this error occurred ?

Thank you,

2 Answers
1
Accepted Answer

I noticed that the error you're encountering is related to the dimension configuration for your chosen model (amazon.titan-embed-text-v2:0). Let me explain how to resolve this.

When creating an S3 vector index, it's crucial to align the dimension value with what your chosen model supports. For the amazon.titan-embed-text-v2:0 model, you have three dimension options:

  • 1024 dimensions
  • 512 dimensions
  • 256 dimensions

Here's how you can create your vector index with the appropriate dimension:

aws s3vectors create-index --vector-bucket-name test200720250754 --index-name test-vector-index --dimension 1024

I recommend using 1024 dimensions as it's the standard choice that provides optimal performance and accuracy for most use cases. However, you can choose 512 or 256 if your specific use case requires it.

Once you've created the index with the correct dimension, your original command should work smoothly:

s3vectors-embed put --vector-bucket-name test-vector-bucket --index-name test-vector-index --model-id amazon.titan-embed-text-v2:0 --text-value "Hello, Mr. Anderson !"

Please try this and let me know if you need any clarification or run into other issues.

References:

  1. S3 Vectors Embed CLI Model Compatibility Documentation
AWS
EXPERT

answered a year ago

AWS
EXPERT

reviewed a year ago

  • Thank you a lot for your solution,
    When I ran command:

    s3vectors-embed put --vector-bucket-name "test-vector-bucket" --index-name "titan-vector-index" --model-id "amazon.titan-embed-text-v2:0" --text-value "Hello, mr. anderson !"
    

    the SUCCESSFUL output was:

    {
      "key": "2b323e7f-bc4f-4401-bb9a-967963feab53",
      "bucket": "test-vector-bucket",
      "index": "titan-vector-index",
      "model": "amazon.titan-embed-text-v2:0",
      "contentType": "text",
      "embeddingDimensions": 1024,
      "metadata": {
        "S3VECTORS-EMBED-SRC-CONTENT": "Hello, mr. anderson !"
      }
    }
    

    When I ran the query:

    s3vectors-embed query --vector-bucket-name test-vector-bucket --index-name titan-vector-index --model-id amazon.titan-embed-text-v2:0 --query-input "query text"  --k 10
    

    The SUCCESSFUL output was:

    {
      "results": [
        {
          "key": "2b323e7f-bc4f-4401-bb9a-967963feab53",
          "metadata": {
            "S3VECTORS-EMBED-SRC-CONTENT": "Hello, mr. anderson !"
          }
        }
      ],
      "summary": {
        "queryType": "text",
        "model": "amazon.titan-embed-text-v2:0",
        "index": "titan-vector-index",
        "resultsFound": 1,
        "queryDimensions": 1024
      }
    }
    
0

This error is occurring because the input format for the Amazon Bedrock Titan embedding model is incorrect. When invoking the Amazon Bedrock model amazon.titan-embed-text-v2:0, you need to ensure that the input request is properly formatted according to what the model expects.

The error message "Malformed input request: #: only 1 subschema matches out of 2, please reformat your input and try again" indicates that the input format doesn't match the expected schema for the Titan embedding model.

When using the Titan embedding model with the InvokeModel operation, the input should be formatted with the text in the "inputText" field. The correct format would be:

{
"inputText": "Hello, Mr. Anderson !"
}

The s3vectors-embed CLI tool should handle this formatting for you, but there might be an issue with how it's constructing the request. Make sure you're using the latest version of the tool, or alternatively, you could write a custom script using the AWS SDK as shown in examples where you explicitly format the request body correctly:

body = json.dumps({"inputText": text})
response = bedrock.invoke_model(
modelId='amazon.titan-embed-text-v2:0',
body=body
)

This would ensure that the input is properly formatted for the Titan embedding model when generating vector embeddings for S3 Vectors.
Sources
Resolve validation exception errors | AWS re:Post
Tutorial: Getting started with S3 Vectors - Amazon Simple Storage Service
Vectors - Amazon Simple Storage Service

answered a year ago

  • The specified format in documentation is:

    s3vectors-embed put
    --vector-bucket-name my-bucket
    --index-name my-index
    --model-id amazon.titan-embed-text-v2:0
    --text-value "Hello, world!"

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.