Skip to content

Amazon Bedrock Converse API: Actual maximum file size limit

0

Hello everyone,

I've encountered an issue while using the Amazon Bedrock Converse API. When trying to process a file, I received the following exception: An error occurred (ValidationException) when calling the ConverseStream operation: The maximum document size is 4.5 MB. Reduce the size of your document and retry your request.

This aligns with the documentation found here: converse - Boto3 1.35.36 documentation

However, my file is only 4.32 MB in size, which is less than 4.5 * 1024 * 1024 bytes (4.5 MB).

My question is: What is the actual maximum file size that can be used with the Converse API? Is there a discrepancy between the stated limit and the actual limit?

I'd appreciate any insights or experiences others might have had with file size limits in the Converse API.

Thanks in advance for your help!

Best regards, Daniel

asked 2 years ago9K views

5 Answers
0

The Amazon Bedrock Converse API does indeed have a stated maximum document size limit of 4.5 MB per document. However, it's important to note that there might be some nuances in how file sizes are calculated or interpreted by the system.

The error message you received suggests that the system is enforcing this 4.5 MB limit strictly. Given that your file is 4.32 MB, which is below the stated limit, there could be a few explanations for this discrepancy:

  1. Encoding or metadata: The system might be including additional metadata or applying some form of encoding to the file, which could slightly increase its effective size.

  2. Measurement discrepancies: There could be differences in how file sizes are measured or rounded by different systems (e.g., binary vs. decimal megabytes).

  3. Safety margin: The system might have a small safety margin below the stated limit to account for potential variations or overhead.

To work around this issue, you might consider:

  1. Further reducing your file size to be comfortably under the limit, perhaps aiming for 4.2 MB or less.

  2. Splitting larger documents into smaller chunks if possible.

  3. Compressing the content if feasible for your use case.

It's also worth noting that the Converse API allows up to five documents per request, each with this size limit. If your content can be logically divided, you might be able to split it across multiple document entries in a single request.

If you continue to experience issues with file sizes very close to but under the stated limit, it would be advisable to contact AWS support for clarification on the exact implementation of the size limit in the Converse API.
Sources
Using the Converse API - Amazon Bedrock

answered 2 years ago

EXPERT

reviewed 2 years ago

0

I'm willing to lower the file size limit in my application to ensure smooth operation. However, rather than experimenting with different values, I'd prefer to implement a definitively safe limit.

Could you please recommend a specific, conservative file size limit that would guarantee no size-related errors when using the Converse API? I'm looking for a value that I can confidently use in my production environment without risking any issues.

Thank you for your help in establishing a reliable solution for my use case.

Best regards, Daniel

answered 2 years ago

0

Hi,

Which is the kind of your file: image, text, etc ?

If you use images, be aware that the SDK will encode them with base64 (as per https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-call.html) which significantly increase the size of the initial image.

This article gives hints about potential size increase (33% they say): https://en.wikipedia.org/wiki/Data_URI_scheme

Best,

Didier

EXPERT

answered 2 years ago

0

Ah, ok. It's about the encoded bytes sent in the converse call.

The bytes in the content_block are 4,539,212. This is still below 4.5x1024x1024 but I understand it's not about the size of the original file.

Best regards, Daniel

answered 2 years ago

0

It depends on what document type you are using. For example, I tried the following to replicate the issue:

  1. when uploading a document to the Chat interface of the Amazon Bedrock playground, I get the error message "The maximum document size is 4.5 MB. Reduce the size of your document and retry your request." However, my excel file is only 1.2MB in size. If I save the SAME excel file in .csv format, the actual file size is close to 11MB in size. I believe this is because .xlsx is a compressed file format, and it might be using the uncompressed file size.

  2. I reduce the .xlsx file size from 1.2MB to 427KB and try again. This time, the uncompressed file is under the 4.5MB limit. However, I get another error labeled "network error". The reason for this is that the number of input tokens has exceeded what the model can support, even though the document size is under the allowed limit.

Solution: process the file in "chunks", possibly using certain frameworks to pre-calculate the token count of the "chunk" before trying to send the API request.

Hope this helps.

AWS

answered 2 years 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.