- Newest
- Most votes
- Most comments
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:
-
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.
-
Measurement discrepancies: There could be differences in how file sizes are measured or rounded by different systems (e.g., binary vs. decimal megabytes).
-
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:
-
Further reducing your file size to be comfortably under the limit, perhaps aiming for 4.2 MB or less.
-
Splitting larger documents into smaller chunks if possible.
-
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
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
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
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
It depends on what document type you are using. For example, I tried the following to replicate the issue:
-
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.
-
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.
answered 2 years ago
Relevant content
asked 2 years ago
- AWS OFFICIALUpdated 12 days ago
