Skip to content

S3 Vector, metadata error

0

Hello,

When I try to use S3 Vector with metadata like below:

s3vectors-embed put --vector-bucket-name "test-vector-bucket" --index-name "titan-vector-index" --model-id "amazon.titan-embed-text-v2:0" --text "\test.jsonl"  --metadata '{"category": "test", "source": "huggingface", "tasks": "sentence similarity", "languages": "english", "modalities": "text"}'

I got the error (first key from metadata JSON is eliminated and this error appears):

Error: Got unexpected extra arguments (test, source: huggingface, tasks: sentence similarity, languages: english, modalities: text}')

while the syntax is like here:

s3vectors-embed put \
  --vector-bucket-name my-bucket \
  --index-name my-index \
  --model-id amazon.titan-embed-text-v2:0 \
  --text "s3://my-bucket/sample.txt"
  --metadata '{"category": "technology", "version": "1.0"}'

Thank you,

2 Answers
0
Accepted Answer

The error you're encountering is related to how the metadata JSON is being parsed by the command line. When you use single quotes around your JSON metadata, the shell might still interpret certain characters within it, causing the JSON structure to break.

To fix this issue, you need to properly escape the quotes in your metadata JSON. Here are a couple of approaches you can try:

  1. Use double quotes around the entire JSON and escape the inner double quotes:
s3vectors-embed put --vector-bucket-name "test-vector-bucket" --index-name "titan-vector-index" --model-id "amazon.titan-embed-text-v2:0" --text "\test.jsonl" --metadata "{\"category\": \"test\", \"source\": \"huggingface\", \"tasks\": \"sentence similarity\", \"languages\": \"english\", \"modalities\": \"text\"}"
  1. Or save your metadata to a JSON file and reference it:
s3vectors-embed put --vector-bucket-name "test-vector-bucket" --index-name "titan-vector-index" --model-id "amazon.titan-embed-text-v2:0" --text "\test.jsonl" --metadata-file metadata.json

Remember that metadata in S3 Vectors can include various types like string, number, boolean, and lists. By default, all metadata is filterable unless explicitly specified as non-filterable, which allows you to filter your query results based on specific attributes.

Also, make sure your vector index is created with the correct dimension for the Titan embedding model you're using (amazon.titan-embed-text-v2:0). This model supports dimensions of 1024, 512, or 256, with 1024 being the standard choice for optimal performance.
Sources
S3 Vector, Bedrock embedding Error | AWS re:Post
Working with S3 Vectors and vector buckets - Amazon Simple Storage Service
Vectors - Amazon Simple Storage Service

answered a year ago

AWS
SUPPORT ENGINEER

reviewed a year ago

  • Thank you for the answer,
    It worked like at point 1, and there is no such option --metadata-file like at point 2

0

Hello,
After some tests, I noticed that the initial syntax works in Windows PowerShell, but not in Windows Command Prompt (cmd).

s3vectors-embed put --vector-bucket-name "test-vector-bucket" --index-name "titan-vector-index-2" --model-id "amazon.titan-embed-text-v2:0" --text-value "Hello Mr. Andersen !"  --metadata '{"category": "test", "source": "huggingface", "tasks": "sentence similarity", "languages": "english", "modalities": "text"}'

answered a year ago

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.